Changeset f7f536b in nscp for trunk/include
- Timestamp:
- 02/25/05 21:47:45 (8 years ago)
- Children:
- cab471b
- Parents:
- 107bd0f
- Location:
- trunk/include
- Files:
-
- 5 edited
-
NSCAPI.h (modified) (2 diffs)
-
NSCHelper.cpp (modified) (1 diff)
-
NSCHelper.h (modified) (2 diffs)
-
PDHCounter.h (modified) (1 diff)
-
thread.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/NSCAPI.h
re0705d4 rf7f536b 2 2 3 3 namespace NSCAPI { 4 5 // Various Nagios codes 6 const int returnCRIT = 2; 7 const int returnOK = 0; 8 const int returnWARN = 1; 9 const int returnUNKNOWN = 4; 10 typedef int returnCodes; 4 11 5 12 // Various Return codes … … 16 23 const int critical = -10; // Critical error 17 24 const int warning = 1; // Warning 18 const int debug = 666; // Deb aug message25 const int debug = 666; // Debug message 19 26 20 27 typedef int messageTypes; // Message type -
trunk/include/NSCHelper.cpp
r079055f rf7f536b 56 56 return "unknown"; 57 57 } 58 std::string NSCHelper::translateReturn(NSCAPI::returnCodes returnCode) { 59 if (returnCode == NSCAPI::returnOK) 60 return "OK"; 61 else if (returnCode == NSCAPI::returnCRIT) 62 return "CRITICAL"; 63 else if (returnCode == NSCAPI::returnWARN) 64 return "WARNING"; 65 else 66 return "UNKNOWN"; 67 } 68 58 69 59 70 -
trunk/include/NSCHelper.h
r079055f rf7f536b 10 10 std::list<std::string> makelist(const unsigned int argLen, char **argument); 11 11 std::string translateMessageType(NSCAPI::messageTypes msgType); 12 std::string translateReturn(NSCAPI::returnCodes returnCode); 13 inline std::string returnNSCP(NSCAPI::returnCodes returnCode, std::string str) { 14 return translateReturn(returnCode) + "&" + str; 15 } 16 17 /* 18 / * ************************************************************************** 19 * max_state(STATE_x, STATE_y) 20 * compares STATE_x to STATE_y and returns result based on the following 21 * STATE_UNKNOWN < STATE_OK < STATE_WARNING < STATE_CRITICAL 22 * 23 * Note that numerically the above does not hold 24 **************************************************************************** / 25 26 int 27 max_state (int a, int b) 28 { 29 if (a == STATE_CRITICAL || b == STATE_CRITICAL) 30 return STATE_CRITICAL; 31 else if (a == STATE_WARNING || b == STATE_WARNING) 32 return STATE_WARNING; 33 else if (a == STATE_OK || b == STATE_OK) 34 return STATE_OK; 35 else if (a == STATE_UNKNOWN || b == STATE_UNKNOWN) 36 return STATE_UNKNOWN; 37 else if (a == STATE_DEPENDENT || b == STATE_DEPENDENT) 38 return STATE_DEPENDENT; 39 else 40 return max (a, b); 41 } 42 @bug Use this sceme instead!! 43 */ 44 45 46 inline void escalteReturnCode(NSCAPI::returnCodes ¤tReturnCode, NSCAPI::returnCodes newReturnCode) { 47 if (newReturnCode == NSCAPI::returnCRIT) 48 currentReturnCode = NSCAPI::returnCRIT; 49 else if ((newReturnCode == NSCAPI::returnWARN) && (currentReturnCode != NSCAPI::returnCRIT) ) 50 currentReturnCode = NSCAPI::returnWARN; 51 else if ((newReturnCode == NSCAPI::returnUNKNOWN) 52 && (currentReturnCode != NSCAPI::returnCRIT) 53 && (currentReturnCode != NSCAPI::returnWARN) ) 54 currentReturnCode = NSCAPI::returnUNKNOWN; 55 } 56 inline void escalteReturnCodeToCRIT(NSCAPI::returnCodes ¤tReturnCode) { 57 currentReturnCode = NSCAPI::returnCRIT; 58 } 59 inline void escalteReturnCodeToWARN(NSCAPI::returnCodes ¤tReturnCode) { 60 if (currentReturnCode != NSCAPI::returnCRIT) 61 currentReturnCode = NSCAPI::returnWARN; 62 } 63 12 64 }; 13 65 … … 83 135 NSCModuleHelper::Message(NSCAPI::log, __FILE__, __LINE__, msg) 84 136 85 #ifdef _DEBUG86 137 #define NSC_DEBUG_MSG_STD(msg) NSC_DEBUG_MSG(((std::string)msg).c_str()) 87 138 #define NSC_DEBUG_MSG(msg) \ 88 139 NSCModuleHelper::Message(NSCAPI::debug, __FILE__, __LINE__, msg) 89 #else90 #define NSC_DEBUG_MSG_STD(msg)91 #define NSC_DEBUG_MSG(msg)92 #endif93 140 94 141 ////////////////////////////////////////////////////////////////////////// -
trunk/include/PDHCounter.h
re0705d4 rf7f536b 9 9 namespace PDH { 10 10 class PDHException { 11 p rivate:11 public: 12 12 std::string str_; 13 13 int errCode_; -
trunk/include/thread.h
r05bfaf2 rf7f536b 158 158 /** 159 159 * Ask the thread to terminate (within 5 seconds) if not return false. 160 * @param delay The time to wait for the thread 160 161 * @return true if the thread has terminated 161 162 */ 162 bool exitThread( ) {163 bool exitThread(const unsigned int delay = 5000L) { 163 164 if (!pObject_) 164 165 throw "Could not terminate thread, has not been started yet..."; 165 166 pObject_->exitThread(); 166 DWORD dwWaitResult = endMutext.wait( 5000L);167 DWORD dwWaitResult = endMutext.wait(delay); 167 168 switch (dwWaitResult) { 168 169 // The thread got mutex ownership.
Note: See TracChangeset
for help on using the changeset viewer.








