Changeset f7f536b in nscp for trunk/include


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
Location:
trunk/include
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/NSCAPI.h

    re0705d4 rf7f536b  
    22 
    33namespace 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; 
    411 
    512  // Various Return codes 
     
    1623  const int critical = -10;   // Critical error 
    1724  const int warning = 1;      // Warning 
    18   const int debug = 666;      // Debaug message 
     25  const int debug = 666;      // Debug message 
    1926 
    2027  typedef int messageTypes;   // Message type 
  • trunk/include/NSCHelper.cpp

    r079055f rf7f536b  
    5656  return "unknown"; 
    5757} 
     58std::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 
    5869 
    5970 
  • 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////////////////////////////////////////////////////////////////////////// 
  • trunk/include/PDHCounter.h

    re0705d4 rf7f536b  
    99namespace PDH { 
    1010  class PDHException { 
    11   private: 
     11  public: 
    1212    std::string str_; 
    1313    int errCode_; 
  • trunk/include/thread.h

    r05bfaf2 rf7f536b  
    158158  /** 
    159159   * Ask the thread to terminate (within 5 seconds) if not return false. 
     160   * @param delay The time to wait for the thread 
    160161   * @return true if the thread has terminated 
    161162   */ 
    162   bool exitThread() { 
     163  bool exitThread(const unsigned int delay = 5000L) { 
    163164    if (!pObject_) 
    164165      throw "Could not terminate thread, has not been started yet..."; 
    165166    pObject_->exitThread(); 
    166     DWORD dwWaitResult = endMutext.wait(5000L); 
     167    DWORD dwWaitResult = endMutext.wait(delay); 
    167168    switch (dwWaitResult) { 
    168169      // The thread got mutex ownership. 
Note: See TracChangeset for help on using the changeset viewer.