Changeset f7f536b in nscp for trunk/include/NSCHelper.h


Ignore:
Timestamp:
02/25/05 21:47:45 (8 years ago)
Author:
Michael Medin <michael@…>
Children:
cab471b
Parents:
107bd0f
Message:

Multiple fixes in various places.

  • Added threadding blocks "core"
  • Added new Module (CheckDisk)
  • Added new option [log] / debug=1 to enable debug logs.
  • Added more error messages
  • other minor tweaks and fixes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/NSCHelper.h

    r079055f rf7f536b  
    1010  std::list<std::string> makelist(const unsigned int argLen, char **argument); 
    1111  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 &currentReturnCode, 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 &currentReturnCode) { 
     57    currentReturnCode = NSCAPI::returnCRIT; 
     58  } 
     59  inline void escalteReturnCodeToWARN(NSCAPI::returnCodes &currentReturnCode) { 
     60    if (currentReturnCode != NSCAPI::returnCRIT) 
     61      currentReturnCode = NSCAPI::returnWARN; 
     62  } 
     63 
    1264}; 
    1365 
     
    83135  NSCModuleHelper::Message(NSCAPI::log, __FILE__, __LINE__, msg) 
    84136 
    85 #ifdef _DEBUG 
    86137#define NSC_DEBUG_MSG_STD(msg) NSC_DEBUG_MSG(((std::string)msg).c_str()) 
    87138#define NSC_DEBUG_MSG(msg) \ 
    88139  NSCModuleHelper::Message(NSCAPI::debug, __FILE__, __LINE__, msg) 
    89 #else 
    90 #define NSC_DEBUG_MSG_STD(msg) 
    91 #define NSC_DEBUG_MSG(msg) 
    92 #endif 
    93140 
    94141////////////////////////////////////////////////////////////////////////// 
Note: See TracChangeset for help on using the changeset viewer.