Changeset 580392ac in nscp


Ignore:
Timestamp:
11/18/06 14:14:22 (7 years ago)
Author:
Michael Medin <michael@…>
Children:
858709e
Parents:
edbbfbb
Message:

+ Added support for empty NRPE checking (i.e.. chec_nrpe without a -c argument)

  • Added error message when detected language is missing from counters.defs + Added Swedish locale to counters.defs (yes, I switched to Swedish XP on my computer :)
  • Fixed : (and possibly other problems) in counters when checking from check_nt (via NSCLient protocol) + Added CheckAllExcept? to CheckDrive? to check all except the specified drives.
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/changelog

    r8fcc179 r580392ac  
    1111 * Add option to recheck DNS in real time 
    1212 
     132006-11-18 MickeM 
     14 + Added support for empty NRPE checking (i.e.. chec_nrpe without a -c argument) 
     15 * Added error message when detected language is missing from counters.defs 
     16 + Added Swedish locale to counters.defs (yes, I switched to Swedish XP on my computer :) 
     17 * Fixed : (and possibly other problems) in counters when checking from check_nt (via NSCLient protocol) 
     18 + Added CheckAllExcept to CheckDrive to check all except the specified drives. 
     19 
    13202006-10-05 MickeM 
    1421 * Yayyy!!! (first fix in a looong while :) 
     
    2027   NOTICE this is "slow" since all hosts in the list are "looked up" each time you get a NRPE/NSClient  
    2128   request it will be "slow" but I think it is not that much of a problem really. 
    22    NOTICE I dont have the posibility to test this so feel free to report if it works and if it doesn't. 
     29   NOTICE I don't have the possibility to test this so feel free to report if it works and if it doesn't. 
    2330   Set cache_allowed_hosts=0 to disable host cache 
    2431 
     
    100107   CheckWMI MaxWarn=10 MaxCrit=15 "Query:load=Select LoadPercentage from win32_Processor" 
    101108   The Max* are as every other check and sets limits.  
    102    The Query works similarly to other check commands ie. Query:<name>=<WMI query> 
     109   The Query works similarly to other check commands i.e.. Query:<name>=<WMI query> 
    103110   So any other WMI query should work (notice this is experimental and not stable and has virtually  
    104111   no error handling so it is likely to crash nsclient if you ask anything "non working".) 
     
    252259 
    2532602005-03-19 MickeM 
    254  * Refactored out NSCLient Listener as a separate module 
     261 * Re factored out NSCLient Listener as a separate module 
    255262 + Added initial NRPE listener module (not yet implemented only a shell) 
    256263 * Changed Module API (Inject function has new syntax) 
  • trunk/counters.defs

    redbbfbb r580392ac  
    6767NT4_MemoryCommitByte = "\Memória\Bytes confirmados" 
    6868 
     69 
     70[0x041d] 
     71Description = "Swedish SE" 
     72 
     73W2K_SystemTotalProcessorTime = "\Processor(_Total)\% processortid" 
     74W2K_SystemSystemUpTime = "\System\Tid sedan systemstart" 
     75W2K_MemoryCommitLimit = "\Minne\Dedikationsgräns" 
     76W2K_MemoryCommitByte = "\Minne\Dedicerade byte" 
  • trunk/include/Socket.h

    rde0bdb0 r580392ac  
    247247 
    248248  public: 
    249     Listener() : pHandler_(NULL), bindPort_(0), bindAddres_(INADDR_ANY), listenQue_(0) {}; 
     249    Listener() : pHandler_(NULL), bindPort_(0), bindAddres_(INADDR_ANY), listenQue_(0), threadManager_("listenThreadManager") {}; 
    250250    virtual ~Listener() { 
    251251      if (responderList_.size() > 0) { 
  • trunk/include/config.h

    r8fcc179 r580392ac  
    55 
    66// Version 
    7 #define SZVERSION "0.2.5h 2006-03-01" 
     7#define SZVERSION "0.2.6 2006-11-18" 
    88 
    99// internal name of the service 
     
    3232#define NSCLIENT "nsclient" 
    3333#define CHECK_ALL "CheckAll" 
     34#define CHECK_ALL_OTHERS "CheckAllOthers" 
    3435 
    3536// NSClient Setting headlines 
  • trunk/include/thread.h

    r237da21 r580392ac  
    88  std::string e_; 
    99  ThreadException(std::string e) : e_(e) { 
    10     std::cout << e << std::endl; 
     10    std::cerr << e << std::endl; 
    1111  } 
    1212}; 
     
    3838class Thread { 
    3939private: 
     40  std::string threadid_; 
    4041  HANDLE hThread_;    // Thread handle 
    4142  T* pObject_;      // Wrapped object 
     
    6061   * Sets up default values 
    6162   */ 
    62   Thread() : hThread_(NULL), pObject_(NULL), uThreadID(-1), bThreadHasTerminated(false), bThreadHasBeenClosed(false) { 
     63  Thread(std::string threadid) : threadid_(threadid), hThread_(NULL), pObject_(NULL), uThreadID(-1), bThreadHasTerminated(false), bThreadHasBeenClosed(false) { 
    6364    hMutex_ = CreateMutex(NULL, FALSE, NULL); 
    6465    assert(hMutex_ != NULL); 
     
    7475        ; 
    7576      else if (bThreadHasBeenClosed||bThreadHasTerminated) 
    76         std::cout << "Thread has not terminated correctly..." << std::endl; 
     77        std::cout << "Thread has not terminated correctly: " << threadid_ << "..." << std::endl; 
    7778      /* 
    7879      MutexLock mutex(hMutex_, 5000L); 
     
    132133      MutexLock mutex(hMutex_, 5000L); 
    133134      if (!mutex.hasMutex()) { 
    134         throw ThreadException("Could not retrieve mutex, thread not started..."); 
     135        throw ThreadException("Could not retrieve mutex, thread (" + threadid_ + ") not started..."); 
    135136      } 
    136137      if (pObject_) { 
    137         throw ThreadException("Thread already started, thread not started..."); 
     138        throw ThreadException("Thread already started, thread (" + threadid_ + ") not started..."); 
    138139      } 
    139140//      assert(hStopEvent_ == NULL); 
     
    158159      MutexLock mutex(hMutex_, delay); 
    159160      if (!mutex.hasMutex()) { 
    160         throw ThreadException("Could not retrieve mutex, thread not stopped..."); 
     161        throw ThreadException("Could not retrieve mutex, thread (" + threadid_ + ") not stopped..."); 
    161162      } 
    162163      if (!pObject_) 
     
    172173      return true; 
    173174    } 
    174     std::cout << "Failed to terminate thread..." << std::endl; 
     175    std::cerr << "Failed to terminate thread: " << threadid_ << "..." << std::endl; 
    175176    assert(false); 
    176177    return false; 
     
    179180    MutexLock mutex(hMutex_, 5000L); 
    180181    if (!mutex.hasMutex()) { 
    181       throw ThreadException("Could not retrieve mutex, thread not stopped..."); 
     182      throw ThreadException("Could not retrieve mutex, thread (" + threadid_ + ") not stopped..."); 
    182183    } 
    183184    return pObject_ != NULL; 
     
    186187    MutexLock mutex(hMutex_, 5000L); 
    187188    if (!mutex.hasMutex()) { 
    188       throw ThreadException("Could not retrieve mutex, thread not stopped..."); 
     189      throw ThreadException("Could not retrieve mutex, thread (" + threadid_ + ") not stopped..."); 
    189190    } 
    190191    return pObject_; 
     
    193194    MutexLock mutex(hMutex_, 5000L); 
    194195    if (!mutex.hasMutex()) { 
    195       throw ThreadException("Could not retrieve mutex, thread not stopped..."); 
     196      throw ThreadException("Could not retrieve mutex, thread (" + threadid_ + ") not stopped..."); 
    196197    } 
    197198    return pObject_; 
  • trunk/modules/CheckDisk/CheckDisk.cpp

    r99bb030 r580392ac  
    100100  bool bFilterCDROM = false; 
    101101  bool bCheckAll = false; 
     102  bool bCheckAllOthers = false; 
    102103  bool bNSClient = false; 
    103104  std::list<DriveConatiner> drives; 
     
    113114    MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 
    114115    MAP_OPTIONS_BOOL_TRUE(CHECK_ALL, bCheckAll) 
     116    MAP_OPTIONS_BOOL_TRUE(CHECK_ALL_OTHERS, bCheckAllOthers) 
    115117    MAP_OPTIONS_SECONDARY_BEGIN(":", p2) 
    116118      else if (p2.first == "Drive") { 
     
    143145      dwDrives >>= 1; 
    144146    } 
     147  } 
     148  if (bCheckAllOthers) { 
     149    std::list<DriveConatiner> checkdrives; 
     150    DWORD dwDrives = GetLogicalDrives(); 
     151    int idx = 0; 
     152    while (dwDrives != 0) { 
     153      if (dwDrives & 0x1) { 
     154        std::string drv; 
     155        drv += static_cast<char>('A' + idx); drv += ":\\"; 
     156        UINT drvType = GetDriveType(drv.c_str()); 
     157        if ( ((!bFilter)&&(drvType == DRIVE_FIXED))  || 
     158          ((bFilter)&&(bFilterFixed)&&(drvType==DRIVE_FIXED)) || 
     159          ((bFilter)&&(bFilterCDROM)&&(drvType==DRIVE_CDROM)) || 
     160          ((bFilter)&&(bFilterRemote)&&(drvType==DRIVE_REMOTE)) || 
     161          ((bFilter)&&(bFilterRemovable)&&(drvType==DRIVE_REMOVABLE)) )   
     162        { 
     163          bool bFound = false; 
     164          for (std::list<DriveConatiner>::const_iterator pit = drives.begin();pit!=drives.end();++pit) { 
     165            DriveConatiner drive = (*pit); 
     166            if (drive.data == drv) 
     167              bFound = true; 
     168          } 
     169          if (!bFound) 
     170            checkdrives.push_back(DriveConatiner(drv, tmpObject.warn, tmpObject.crit)); 
     171        } 
     172      } 
     173      idx++; 
     174      dwDrives >>= 1; 
     175    } 
     176    drives = checkdrives; 
    145177  } 
    146178 
  • trunk/modules/CheckSystem/CheckSystem.cpp

    r8fcc179 r580392ac  
    3131 * @return  
    3232 */ 
    33 CheckSystem::CheckSystem() : processMethod_(0) {} 
     33CheckSystem::CheckSystem() : processMethod_(0), pdhThread("pdhThread") {} 
    3434/** 
    3535 * Default d-tor 
     
    796796      if (!PDH::Enumerations::validate(counter.data, tstr)) { 
    797797        msg = tstr; 
     798        msg += " (" + counter.getAlias() + "|" + counter.data + ")"; 
    798799        return NSCAPI::returnUNKNOWN; 
    799800      } 
     
    817818      } 
    818819    } catch (const PDH::PDHException e) { 
    819       NSC_LOG_ERROR_STD("ERROR: " + e.getError() + " (" + counter.getAlias() + ")"); 
    820       msg = static_cast<std::string>("ERROR: ") + e.getError(); 
     820      NSC_LOG_ERROR_STD("ERROR: " + e.getError() + " (" + counter.getAlias() + "|" + counter.data + ")"); 
     821      msg = static_cast<std::string>("ERROR: ") + e.getError()+ " (" + counter.getAlias() + "|" + counter.data + ")"; 
    821822      return NSCAPI::returnUNKNOWN; 
    822823    } 
  • trunk/modules/CheckSystem/PDHCollector.cpp

    r8fcc179 r580392ac  
    6767    settings.setFile(NSCModuleHelper::getBasePath() + "\\counters.defs", true); 
    6868 
     69    NSC_LOG_ERROR_STD("Getting counter info..."); 
    6970 
    7071    try { 
     
    9394      section = "0000" + strEx::ihextos(langId); 
    9495      section = "0x" + section.substr(section.length()-4); 
     96      if (settings.getString(section, "Description", "_NOT_FOUND") == "_NOT_FOUND") { 
     97        NSC_LOG_ERROR_STD("Detected language: " + section + " but it could not be found in: counters.defs"); 
     98        NSC_LOG_ERROR_STD("You need to manually configure performance counters!"); 
     99        return 0; 
     100      } 
    95101      NSC_DEBUG_MSG_STD("Detected language: " + settings.getString(section, "Description", "Not found") + " (" + section + ")"); 
    96102    } catch (systemInfo::SystemInfoException e) { 
     
    111117  } 
    112118 
     119  NSC_LOG_ERROR_STD("Attempting to open counter..."); 
    113120  try { 
    114121    pdh.open(); 
     122    NSC_LOG_ERROR_STD("Counters opend..."); 
    115123  } catch (const PDH::PDHException &e) { 
    116124    NSC_LOG_ERROR_STD("Failed to open performance counters: " + e.getError()); 
  • trunk/modules/NRPEListener/NRPEListener.cpp

    rde0bdb0 r580392ac  
    325325  } 
    326326  strEx::token cmd = strEx::getToken(p.getPayload(), '!'); 
     327  if (cmd.first == "_NRPE_CHECK") { 
     328    return NRPEPacket(NRPEPacket::responsePacket, NRPEPacket::version2, NSCAPI::returnOK, "I ("SZVERSION") seem to be doing fine..."); 
     329  } 
    327330  std::string msg, perf; 
    328331 
  • trunk/modules/NSClientListener/NSClientListener.cpp

    rde0bdb0 r580392ac  
    160160    case REQ_COUNTER: 
    161161      cmd.first = "checkCounter"; 
    162       cmd.second += "&nsclient"; 
     162      cmd.second = "Counter=" + cmd.second + "&nsclient"; 
    163163      break; 
    164164    case REQ_FILEAGE: 
  • trunk/modules/SysTray/SysTray.cpp

    r99bb030 r580392ac  
    1616} 
    1717 
    18 SysTray::SysTray() {} 
     18SysTray::SysTray() : icon("SysTray") {} 
    1919SysTray::~SysTray() {} 
    2020bool SysTray::loadModule() { 
Note: See TracChangeset for help on using the changeset viewer.