Changeset 1d53fe0 in nscp


Ignore:
Timestamp:
02/12/09 20:28:56 (4 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
b1ac2fa
Parents:
04f2743
Message:

2009-02-11 MickeM

  • Fixed so that performance data is always(?) renderd regardless of if we have bounds or not. This was primarily to fix issues where we have might not "unexpectedly" get performance data (might still be some issues here so let me know).

2009-02-06 MickeM

2009-02-05 MickeM

  • Fixed so the error message for "to small eventlog buffer" specifies the required size.
  • Changed so that event log buffer problems are "ignored in the result" (still logged in the error log).

2009-02-03 MickeM

  • Added support for changing the time when using NSCA with the time_delay in NSC.ini time_delay=+4h or time_delay=-1h etc should can now be used when system time not the same as NSCA time.

2009-01-30 MickeM

  • Added support for changing name and description of service from the /install command line NSClient++ /install [gui] [start] [service name] [description] NSClient++ /uninstall [gui] [stop] [service name] NSClient++ /start [gui] [service name] NSClient++ /stop [gui] [service name]

2009-01-28 MickeM

  • Slightly improved error handling around socket creation
  • Fixed some pretty minor issues with the SysTray module (uncreation as well as new boost build).

2009-01-25 MickeM

  • Fixed issue with checkVersion (#242)
  • Fixed spelling error (#244)
  • Fixed crash in CheckFile when a file was locked in exclusive mode (#254) + Improved error handling in all CheckDIsk/CheckFile checks. Should report errors better now.
  • Updated the config file a bit: remving "beta" from a bunch of modules no longer in beta. (#270) + Added more filter operatos to all numeric filters so they accept eq:, ne:, gt:, lt: in addition to =, >, <, <>, !, !=, in: (#269)

2009-01-23 MickeM

+ Added better support for numerical hit matching in the eventlog module. You can now use exact and detailed matching.

You can now use the following syntax:
CheckEventLog ... warn=ne:1 crit=eq:0 ...
To generate a warning if the number of hits are != 1 and a critical if the number of hits are = 0.
Other operators avalible are: =, >, <, <>, !, !=, eq:, ne:, gt:, lt:

Files:
28 added
18 edited

Legend:

Unmodified
Added
Removed
  • AutoBuild.h

    r04f2743 r1d53fe0  
    33// change the FALSE to TRUE for autoincrement of build number 
    44#define INCREMENT_VERSION TRUE 
    5 #define FILEVER        0,3,6,249 
    6 #define PRODUCTVER     0,3,6,249 
    7 #define STRFILEVER     _T("0.3.6.249") 
    8 #define STRPRODUCTVER  _T("0.3.6.249") 
    9 #define STRPRODUCTDATE  _T("2009-01-25") 
     5#define FILEVER        0,3,6,330 
     6#define PRODUCTVER     0,3,6,330 
     7#define STRFILEVER     _T("0.3.6.330") 
     8#define STRPRODUCTVER  _T("0.3.6.330") 
     9#define STRPRODUCTDATE  _T("2009-02-11") 
    1010#endif // AUTOBUILD_H 
  • NSClient++.cpp

    r3692371 r1d53fe0  
    180180  if ( (argc > 1) && ((*argv[1] == '-') || (*argv[1] == '/')) ) { 
    181181    if ( _wcsicmp( _T("install"), argv[1]+1 ) == 0 ) { 
    182       bool bGui = (argc > 2) && (_wcsicmp( _T("gui"), argv[2] )) || (argc > 3) && (_wcsicmp( _T("gui"), argv[3] )); 
    183       bool bStart = (argc > 2) && (_wcsicmp( _T("start"), argv[2] )) || (argc > 3) && (_wcsicmp( _T("start"), argv[3] )); 
     182      bool bGui = false; 
     183      bool bStart = false; 
     184      std::wstring service_name, service_description; 
     185      for (int i=2;i<argc;i++) { 
     186        if (_wcsicmp( _T("gui"), argv[i]) == 0) { 
     187          bGui = true; 
     188        } else if (_wcsicmp( _T("start"), argv[i]) == 0) { 
     189          bStart = true; 
     190        } else { 
     191          if (service_name.empty()) 
     192            service_name = argv[i]; 
     193          else { 
     194            if (!service_description.empty()) 
     195              service_description += _T(" "); 
     196            service_description += argv[i]; 
     197          } 
     198        } 
     199      } 
     200      if (service_name.empty()) 
     201        service_name = SZSERVICENAME; 
     202      if (service_description.empty()) 
     203        service_description = SZSERVICEDISPLAYNAME; 
    184204      g_bConsoleLog = true; 
    185205      try { 
    186         serviceControll::Install(SZSERVICENAME, SZSERVICEDISPLAYNAME, SZDEPENDENCIES); 
     206        serviceControll::Install(service_name.c_str(), service_description.c_str(), SZDEPENDENCIES); 
    187207        if (bStart) 
    188           serviceControll::Start(SZSERVICENAME); 
     208          serviceControll::Start(service_name); 
    189209      } catch (const serviceControll::SCException& e) { 
    190210        if (bGui) 
     
    194214      } 
    195215      try { 
    196         serviceControll::SetDescription(SZSERVICENAME, SZSERVICEDESCRIPTION); 
     216        serviceControll::SetDescription(service_name, service_description); 
    197217      } catch (const serviceControll::SCException& e) { 
    198218        if (bGui) 
     
    203223      return 0; 
    204224    } else if ( _wcsicmp( _T("uninstall"), argv[1]+1 ) == 0 ) { 
    205       bool bGui = (argc > 2) && (_wcsicmp( _T("gui"), argv[2] )); 
     225      bool bGui = false; 
     226      bool bStop = false; 
     227      std::wstring service_name; 
     228      for (int i=2;i<argc;i++) { 
     229        if (_wcsicmp( _T("gui"), argv[i]) == 0) { 
     230          bGui = true; 
     231        } else if (_wcsicmp( _T("stop"), argv[i]) == 0) { 
     232          bStop = true; 
     233        } else { 
     234          service_name = argv[i]; 
     235        } 
     236      } 
     237      if (service_name.empty()) 
     238        service_name = SZSERVICENAME; 
    206239      g_bConsoleLog = true; 
    207240      try { 
    208         serviceControll::Uninstall(SZSERVICENAME); 
     241        if (bStop) 
     242          serviceControll::Stop(service_name); 
     243        serviceControll::Uninstall(service_name); 
    209244      } catch (const serviceControll::SCException& e) { 
    210245        if (bGui) 
     
    234269    } else if ( _wcsicmp( _T("start"), argv[1]+1 ) == 0 ) { 
    235270      g_bConsoleLog = true; 
     271      bool bGui = false; 
     272      std::wstring service_name; 
     273      for (int i=2;i<argc;i++) { 
     274        if (_wcsicmp( _T("gui"), argv[i]) == 0) { 
     275          bGui = true; 
     276        } else { 
     277          service_name = argv[i]; 
     278        } 
     279      } 
     280      if (service_name.empty()) 
     281        service_name = SZSERVICENAME; 
    236282      try { 
    237         serviceControll::Start(SZSERVICENAME); 
     283        serviceControll::Start(service_name.c_str()); 
    238284      } catch (const serviceControll::SCException& e) { 
     285        if (bGui) 
     286          display(_T("Service failed to start"), e.error_); 
    239287        LOG_MESSAGE_STD(_T("Service failed to start: ") + e.error_); 
    240288        return -1; 
     
    242290    } else if ( _wcsicmp( _T("stop"), argv[1]+1 ) == 0 ) { 
    243291      g_bConsoleLog = true; 
     292      bool bGui = false; 
     293      std::wstring service_name; 
     294      for (int i=2;i<argc;i++) { 
     295        if (_wcsicmp( _T("gui"), argv[i]) == 0) { 
     296          bGui = true; 
     297        } else { 
     298          service_name = argv[i]; 
     299        } 
     300      } 
     301      if (service_name.empty()) 
     302        service_name = SZSERVICENAME; 
    244303      try { 
    245         serviceControll::Stop(SZSERVICENAME); 
     304        serviceControll::Stop(service_name.c_str()); 
    246305      } catch (const serviceControll::SCException& e) { 
     306        if (bGui) 
     307          display(_T("Service failed to stop"), e.error_); 
    247308        LOG_MESSAGE_STD(_T("Service failed to stop: ") + e.error_); 
    248309        return -1; 
  • changelog

    r04f2743 r1d53fe0  
    44 * Add API for rehashing the daemon (or implement it the API is there but does nothing) 
    55 * Improved socket performance (would be nice if we could be used as a "hub") 
     6 
     72009-02-11 MickeM  
     8 * Fixed so that performance data is always(?) renderd regardless of if we have bounds or not. 
     9   This was primarily to fix issues where we have might not "unexpectedly" get performance data (might still be some issues here so let me know). 
     10 
     112009-02-06 MickeM  
     12 * Fixed so that arguments ($ARG1$) are parsed properly for alias in CheckExternalScript 
     13 
     142009-02-05 MickeM  
     15 * Fixed so the error message for "to small eventlog buffer" specifies the required size. 
     16 * Changed so that event log buffer problems are "ignored in the result" (still logged in the error log). 
     17 
     182009-02-03 MickeM  
     19 * Added support for changing the time when using NSCA with the time_delay in NSC.ini 
     20   time_delay=+4h or time_delay=-1h etc should can now be used when system time not the same as NSCA time. 
     21 
     222009-01-30 MickeM  
     23 * Added support for changing name and description of service from the /install command line 
     24   NSClient++ /install [gui] [start] [service name] [description] 
     25   NSClient++ /uninstall [gui] [stop] [service name] 
     26   NSClient++ /start [gui] [service name] 
     27   NSClient++ /stop [gui] [service name] 
     28 
     292009-01-28 MickeM  
     30 * Slightly improved error handling around socket creation 
     31 * Fixed some pretty minor issues with the SysTray module (uncreation as well as new boost build). 
    632 
    7332009-01-25 MickeM  
  • include/REGSettings.h

    rfebff5f r1d53fe0  
    148148    DWORD type; 
    149149    DWORD cbData = sizeof(DWORD); 
    150     BYTE *bData = new BYTE[cbData+1]; 
    151     bRet = RegQueryValueEx(hTemp, lpszKey, NULL, &type, bData, &cbData); 
     150    DWORD buffer; 
     151    //BYTE *bData = new BYTE[cbData+1]; 
     152    bRet = RegQueryValueEx(hTemp, lpszKey, NULL, &type, reinterpret_cast<LPBYTE>(&buffer), &cbData ); 
    152153    if (type != REG_DWORD) { 
    153154      bRet = -1; 
     
    155156    RegCloseKey(hTemp); 
    156157    if (bRet == ERROR_SUCCESS) { 
    157       ret = static_cast<DWORD>(*bData); 
    158     } 
    159     delete [] bData; 
     158      ret = buffer; 
     159    } 
     160    //delete [] bData; 
    160161    return ret; 
    161162  } 
  • include/ServiceCmd.cpp

    r3692371 r1d53fe0  
    2121#include <iostream> 
    2222#include <msvc_wrappers.h> 
     23#include <error.hpp> 
    2324 
    2425namespace serviceControll { 
     
    4546    schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 
    4647    if (!schSCManager) 
    47       throw SCException(_T("OpenSCManager failed.")); 
     48      throw SCException(_T("OpenSCManager failed:") + error::lookup::last_error()); 
    4849    schService = CreateService( 
    4950      schSCManager,               // SCManager database 
     
    6768        throw SCException(_T("Service already installed!")); 
    6869      } 
    69       throw SCException(_T("Unable to install service."), err); 
     70      throw SCException(_T("Unable to install service.") + error::lookup::last_error(err)); 
    7071    } 
    7172    std::wcout << _T("Service ") << szName << _T(" installed...") << std::endl;; 
     
    8485    schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); 
    8586    if (!schSCManager) 
    86       throw SCException(_T("OpenSCManager failed.")); 
     87      throw SCException(_T("OpenSCManager failed: ") + error::lookup::last_error()); 
    8788    schService = OpenService(schSCManager, szName, SERVICE_ALL_ACCESS); 
    8889    if (!schService) { 
    8990      DWORD err = GetLastError(); 
    9091      CloseServiceHandle(schSCManager); 
    91       throw SCException(_T("Unable to open service."), err); 
     92      throw SCException(_T("Unable to open service: ") + error::lookup::last_error(err)); 
    9293    } 
    9394    BOOL result = ChangeServiceConfig(schService, dwServiceType, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE , NULL, NULL, NULL,  
     
    118119      DWORD err = GetLastError(); 
    119120      CloseServiceHandle(schSCManager); 
    120       throw SCException(_T("Unable to open service."), err); 
     121      throw SCException(_T("Unable to open service: ") + error::lookup::last_error(err)); 
    121122    } 
    122123 
     
    150151    schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS ); 
    151152    if (!schSCManager)  
    152       throw SCException(_T("OpenSCManager failed.")); 
     153      throw SCException(_T("OpenSCManager failed: ") + error::lookup::last_error()); 
    153154    schService = OpenService(schSCManager, name.c_str(), SERVICE_ALL_ACCESS); 
    154155    if (schService) { 
     
    172173      CloseServiceHandle(schService); 
    173174    } else { 
    174       CloseServiceHandle(schSCManager); 
    175       throw SCException(_T("OpenService failed.")); 
     175      std::wstring err = _T("OpenService failed: ") + error::lookup::last_error(); 
     176      CloseServiceHandle(schSCManager); 
     177      throw SCException(err); 
    176178    } 
    177179    CloseServiceHandle(schSCManager); 
     
    187189    schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS ); 
    188190    if (!schSCManager)  
    189       throw SCException(_T("OpenSCManager failed.")); 
     191      throw SCException(_T("OpenSCManager failed: ") + error::lookup::last_error()); 
    190192    schService = OpenService(schSCManager, name.c_str(), SERVICE_ALL_ACCESS); 
    191193    if (schService) { 
  • include/Socket.h

    r846bbe4 r1d53fe0  
    507507        bindAddres_ = INADDR_ANY; 
    508508      listenQue_ = queLength; 
    509       threadManager_.createThread(this); 
     509      try { 
     510        threadManager_.createThread(this); 
     511      } catch (ThreadException e) { 
     512        throw SocketException(_T("Could not start thread (got exception in thread): ") + e.e_); 
     513      } 
    510514    } 
    511515    virtual void StopListener() { 
     
    518522      } catch (ThreadException e) { 
    519523        tBase::close(); 
    520         throw SocketException(_T("Could not terminate thread (got exception in thread).")); 
     524        throw SocketException(_T("Could not terminate thread (got exception in thread): ") + e.e_); 
    521525      } 
    522526      tBase::close(); 
  • include/checkHelpers.hpp

    r04f2743 r1d53fe0  
    137137      std::wstring tstr; 
    138138      if (crit.check(value, getAlias(), tstr, critical)) { 
    139         std::wcout << _T("crit") << std::endl; 
     139        //std::wcout << _T("crit") << std::endl; 
    140140        NSCHelper::escalteReturnCodeToCRIT(returnCode); 
    141141      } else if (warn.check(value, getAlias(), tstr, warning)) { 
    142         std::wcout << _T("warn") << std::endl; 
     142        //std::wcout << _T("warn") << std::endl; 
    143143        NSCHelper::escalteReturnCodeToWARN(returnCode); 
    144144      }else if (show == showLong) { 
    145         std::wcout << _T("long") << std::endl; 
     145        //std::wcout << _T("long") << std::endl; 
    146146        tstr = getAlias() + _T(": ") + TContents::toStringLong(value); 
    147147      }else if (show == showShort) { 
    148         std::wcout << _T("short") << std::endl; 
     148        //std::wcout << _T("short") << std::endl; 
    149149        tstr = getAlias() + _T(": ") + TContents::toStringShort(value); 
    150150      } 
    151       std::wcout << _T("result: ") << tstr << _T("--") << std::endl; 
    152151      if (perfData) 
    153152        perf += gatherPerfData(value); 
     
    682681        return true; 
    683682      } else { 
     683        NSC_DEBUG_MSG_STD(_T("Missing bounds for check: ") + lable); 
    684684        //std::cout << "No bounds specified..." << std::endl; 
    685685      } 
     
    757757      } else { 
    758758        NSC_DEBUG_MSG_STD(_T("Missing bounds for maxmin-bounds check: ") + alias); 
     759        return min.gatherPerfData(alias, value, 0, 0); 
    759760      } 
    760761      return _T(""); 
  • include/config.h

    rbb8b6d1 r1d53fe0  
    184184#define NSCA_CACHE_HOST _T("cache_hostname") 
    185185#define NSCA_CACHE_HOST_DEFAULT 0 
     186#define NSCA_TIME_DELTA _T("time_delay") 
     187#define NSCA_TIME_DELTA_DEFAULT _T("0") 
    186188 
    187189#define C_SYSTEM_SVC_ALL_0 _T("check_all_services[SERVICE_BOOT_START]") 
  • modules/CheckEventLog/CheckEventLog.cpp

    r04f2743 r1d53fe0  
    622622    //GetOldestEventLogRecord(hLog, &dwThisRecord); 
    623623 
    624     while (ReadEventLog(hLog, EVENTLOG_FORWARDS_READ|EVENTLOG_SEQUENTIAL_READ, 
    625       0, buffer.getBufferUnsafe(), buffer.getBufferSize(), &dwRead, &dwNeeded)) 
    626     { 
     624    while (true) { 
     625      BOOL bStatus = ReadEventLog(hLog, EVENTLOG_FORWARDS_READ|EVENTLOG_SEQUENTIAL_READ, 
     626        0, buffer.getBufferUnsafe(), buffer.getBufferSize(), &dwRead, &dwNeeded); 
     627      if (bStatus == FALSE) { 
     628        DWORD err = GetLastError(); 
     629        if (err == ERROR_INSUFFICIENT_BUFFER) { 
     630          NSC_LOG_ERROR_STD(_T("EvenlogBuffer is too small change the value of ") + EVENTLOG_BUFFER + _T("=") + strEx::itos(dwNeeded+1) + _T(" under [EventLog] in nsc.ini : ") + error::lookup::last_error(err)); 
     631        } else if (err == ERROR_HANDLE_EOF) { 
     632          break; 
     633        } else { 
     634          NSC_LOG_ERROR_STD(_T("Failed to read from eventlog: ") + error::lookup::last_error(err)); 
     635          message = _T("Failed to read from eventlog: ") + error::lookup::last_error(err); 
     636          CloseEventLog(hLog); 
     637          return NSCAPI::returnUNKNOWN; 
     638        } 
     639      } 
    627640      EVENTLOGRECORD *pevlr = buffer.getBufferUnsafe();  
    628641      while (dwRead > 0) {  
     
    719732      }  
    720733    } 
    721     DWORD err = GetLastError(); 
    722     if (err == ERROR_INSUFFICIENT_BUFFER) { 
    723       NSC_LOG_ERROR_STD(_T("EvenlogBuffer is too small (set the value of ") + EVENTLOG_BUFFER + _T("): ") + error::lookup::last_error(err)); 
    724       message = std::wstring(_T("EvenlogBuffer is too small (set the value of ")) + EVENTLOG_BUFFER + _T("): ") + error::lookup::last_error(err); 
    725       return NSCAPI::returnUNKNOWN; 
    726     } else if (err != ERROR_HANDLE_EOF) { 
    727       NSC_LOG_ERROR_STD(_T("Failed to read from eventlog: ") + error::lookup::last_error(err)); 
    728       message = _T("Failed to read from eventlog: ") + error::lookup::last_error(err); 
    729       return NSCAPI::returnUNKNOWN; 
    730     } 
    731734    CloseEventLog(hLog); 
    732735    for (uniq_eventlog_map::const_iterator cit = uniq_records.begin(); cit != uniq_records.end(); ++cit) { 
  • modules/CheckExternalScripts/CheckExternalScripts.cpp

    r394f7a1 r1d53fe0  
    135135  } 
    136136  if (isAlias) { 
    137     return NSCModuleHelper::InjectSplitAndCommand(cd.command, cd.arguments, ' ', message, perf, true); 
     137    return NSCModuleHelper::InjectSplitAndCommand(cd.command, args, ' ', message, perf, true); 
    138138  } else { 
    139139    int result = process::executeProcess(root_, cd.command + _T(" ") + args, message, perf, timeout); 
  • modules/CheckSystem/CheckSystem.cpp

    r04f2743 r1d53fe0  
    7373    NSCModuleHelper::registerCommand(_T("checkMem"), _T("Check free/used memory on the system.")); 
    7474    NSCModuleHelper::registerCommand(_T("checkCounter"), _T("Check a PDH counter.")); 
     75    NSCModuleHelper::registerCommand(_T("listCounterInstances"), _T("List all instances for a counter.")); 
     76     
    7577  } catch (NSCModuleHelper::NSCMHExcpetion &e) { 
    7678    NSC_LOG_ERROR_STD(_T("Failed to register command: ") + e.msg_); 
     
    330332  } else if (command == _T("checkCounter")) { 
    331333    return checkCounter(argLen, char_args, msg, perf); 
     334  } else if (command == _T("listCounterInstances")) { 
     335    return listCounterInstances(argLen, char_args, msg, perf); 
    332336  } 
    333337  return NSCAPI::returnIgnored; 
     
    10651069        msg += strEx::itos(static_cast<float>(value)); 
    10661070      } else { 
     1071        std::wcout << _T("perf data: ") << bPerfData << std::endl; 
    10671072        counter.perfData = bPerfData; 
    10681073        counter.setDefault(tmpObject); 
     
    10881093  return returnCode; 
    10891094} 
     1095 
     1096 
     1097 
     1098/** 
     1099 * List all instances for a given counter. 
     1100 * 
     1101 * @param command Command to execute 
     1102 * @param argLen The length of the argument buffer 
     1103 * @param **char_args The argument buffer 
     1104 * @param &msg String to put message in 
     1105 * @param &perf String to put performance data in  
     1106 * @return The status of the command 
     1107 * 
     1108 * @todo add parsing support for NRPE 
     1109 */ 
     1110NSCAPI::nagiosReturn CheckSystem::listCounterInstances(const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf) 
     1111{ 
     1112  typedef checkHolders::CheckContainer<checkHolders::MaxMinBoundsDouble> CounterContainer; 
     1113 
     1114  std::list<std::wstring> stl_args = arrayBuffer::arrayBuffer2list(argLen, char_args); 
     1115  if (stl_args.empty()) { 
     1116    msg = _T("ERROR: Missing argument exception."); 
     1117    return NSCAPI::returnUNKNOWN; 
     1118  } 
     1119 
     1120  std::wstring counter = arrayBuffer::arrayBuffer2string(char_args, argLen, _T(" ")); 
     1121  try { 
     1122    PDH::Enumerations::pdh_object_details obj = PDH::Enumerations::EnumObjectInstances(counter); 
     1123    for (PDH::Enumerations::pdh_object_details::list::const_iterator it = obj.instances.begin(); it!=obj.instances.end();++it) { 
     1124      if (!msg.empty()) 
     1125        msg += _T(", "); 
     1126      msg += (*it); 
     1127    } 
     1128  } catch (const PDH::PDHException e) { 
     1129    msg = _T("ERROR: Failed to enumerate counter instances: " + e.getError()); 
     1130    return NSCAPI::returnUNKNOWN; 
     1131  } catch (...) { 
     1132    msg = _T("ERROR: Failed to enumerate counter instances: <UNKNOWN EXCEPTION>"); 
     1133    return NSCAPI::returnUNKNOWN; 
     1134  } 
     1135  return NSCAPI::returnOK; 
     1136} 
     1137 
     1138 
    10901139NSC_WRAPPERS_MAIN_DEF(gCheckSystem); 
    10911140NSC_WRAPPERS_IGNORE_MSG_DEF(); 
  • modules/CheckSystem/CheckSystem.h

    r04f2743 r1d53fe0  
    8080  NSCAPI::nagiosReturn checkProcState(const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf); 
    8181  NSCAPI::nagiosReturn checkCounter(const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf); 
     82  NSCAPI::nagiosReturn listCounterInstances(const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf); 
     83 
    8284 
    8385}; 
  • modules/NRPEListener/NRPEListener.cpp

    r04f2743 r1d53fe0  
    8989  if (buffer_length_ != 1024) 
    9090    NSC_DEBUG_MSG_STD(_T("Non-standard buffer length (hope you have recompiled check_nrpe changing #define MAX_PACKETBUFFER_LENGTH = ") + strEx::itos(buffer_length_)); 
     91  NSC_DEBUG_MSG_STD(_T("Loading all commands (from NRPE)")); 
    9192  std::list<std::wstring> commands = NSCModuleHelper::getSettingsSection(NRPE_HANDLER_SECTION_TITLE); 
    9293  std::list<std::wstring>::const_iterator it; 
     
    118119  allowedHosts.setAllowedHosts(strEx::splitEx(getAllowedHosts(), _T(",")), getCacheAllowedHosts()); 
    119120  try { 
     121    NSC_DEBUG_MSG_STD(_T("Starting NRPE socket...")); 
    120122    unsigned short port = NSCModuleHelper::getSettingsInt(NRPE_SECTION_TITLE, NRPE_SETTINGS_PORT, NRPE_SETTINGS_PORT_DEFAULT); 
    121123    std::wstring host = NSCModuleHelper::getSettingsString(NRPE_SECTION_TITLE, NRPE_SETTINGS_BINDADDR, NRPE_SETTINGS_BINDADDR_DEFAULT); 
     
    140142    return false; 
    141143#endif 
     144  } catch (...) { 
     145    NSC_LOG_ERROR_STD(_T("Exception caught: <UNKNOWN EXCEPTION>")); 
     146    return false; 
    142147  } 
    143148  root_ = NSCModuleHelper::getBasePath(); 
  • modules/NSCAAgent/NSCAThread.cpp

    rbc97cd8 r1d53fe0  
    2424 
    2525NSCAThread::NSCAThread() : hStopEvent_(NULL) { 
     26  std::wstring tmpstr = NSCModuleHelper::getSettingsString(NSCA_AGENT_SECTION_TITLE, NSCA_TIME_DELTA, NSCA_TIME_DELTA_DEFAULT); 
     27  if (tmpstr[0] == '-' && tmpstr.size() > 2) 
     28    timeDelta_ = - strEx::stoui_as_time(tmpstr.substr(1)); 
     29  if (tmpstr[0] == '+' && tmpstr.size() > 2) 
     30    timeDelta_ = strEx::stoui_as_time(tmpstr.substr(1)); 
     31  else 
     32    timeDelta_ = strEx::stoui_as_time(tmpstr); 
     33  NSC_DEBUG_MSG_STD(_T("Time difference for NSCA server is: ") + strEx::itos(timeDelta_)); 
    2634  checkIntervall_ = NSCModuleHelper::getSettingsInt(NSCA_AGENT_SECTION_TITLE, NSCA_INTERVAL, NSCA_INTERVAL_DEFAULT); 
    2735  hostname_ = NSCModuleHelper::getSettingsString(NSCA_AGENT_SECTION_TITLE, NSCA_HOSTNAME, NSCA_HOSTNAME_DEFAULT); 
     
    192200      for (std::list<Command::Result>::const_iterator cit = results.begin(); cit != results.end(); ++cit) { 
    193201        try { 
    194           socket.send((*cit).getBuffer(crypt_inst)); 
     202          socket.send((*cit).getBuffer(crypt_inst, timeDelta_)); 
    195203        } catch (NSCAPacket::NSCAException &e) { 
    196204          NSC_LOG_ERROR_STD(_T("Failed to make command: ") + e.getMessage() ); 
  • modules/NSCAAgent/NSCAThread.h

    r5aebda1 r1d53fe0  
    160160    } 
    161161 
    162     simpleSocket::DataBuffer getBuffer(nsca_encrypt &crypt_inst) const { 
     162    simpleSocket::DataBuffer getBuffer(nsca_encrypt &crypt_inst, __time32_t time_delta) const { 
    163163      std::string s = strEx::wstring_to_string(service); 
    164164      std::string r = strEx::wstring_to_string(result); 
     
    169169      NSCAPacket::data_packet *data = reinterpret_cast<NSCAPacket::data_packet*>(buffer); 
    170170      data->packet_version=static_cast<NSCAPacket::int16_t>(htons(NSCA_PACKET_VERSION_3)); 
    171       data->timestamp=static_cast<NSCAPacket::u_int32_t>(htonl(time)); 
     171      data->timestamp=static_cast<NSCAPacket::u_int32_t>(htonl(time+time_delta)); 
    172172      data->return_code = ntohs(code); 
    173173      data->crc32_value=static_cast<NSCAPacket::u_int32_t>(0L); 
     
    230230  std::string password_; 
    231231  int encryption_method_; 
     232  long timeDelta_; 
    232233 
    233234public: 
  • modules/NSClientListener/NSClientListener.cpp

    ra34b229 r1d53fe0  
    3636#define REQ_MEMUSE      7 // Works fine! 
    3737#define REQ_COUNTER     8 // Works fine! 
    38 #define REQ_FILEAGE     9 // ... in the works ... 
    39 //#define REQ_INSTANCES 10  // ! - not implemented Don't know how to use 
     38#define REQ_FILEAGE     9 // Works fine! (i hope) 
     39#define REQ_INSTANCES   10  // Works fine! (i hope) 
    4040 
    4141BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved) 
     
    219219      args.push_back(_T("path=") + cmd.second); 
    220220      break; 
     221    case REQ_INSTANCES: 
     222      cmd.first = _T("listCounterInstances"); 
     223      args.push_back(cmd.second); 
     224      break; 
     225 
     226       
    221227    default: 
    222228      split_to_list(args, cmd.second); 
  • modules/SysTray/SysTray.cpp

    rbc97cd8 r1d53fe0  
    6666} 
    6767bool SysTray::unloadModule() { 
    68   if (systemInfo::isBelowXP(systemInfo::getOSVersion())) { 
    69     hide(); 
     68  if (NSCModuleHelper::getSettingsInt(MAIN_SECTION_TITLE, MAIN_SHARED_SESSION, MAIN_SHARED_SESSION_DEFAULT) == 1) { 
     69    NSC_LOG_ERROR(_T("You have enabled shared session, systray module will not un-load...")); 
     70    return true; 
    7071  } 
     72  hide(); 
    7173  return true; 
    7274} 
  • modules/SysTray/TrayIcon.cpp

    r4bf9740 r1d53fe0  
    122122void IconWidget_::createDialog(void) { 
    123123  hDlgWnd = ::CreateDialog(NSCModuleWrapper::getModule(),MAKEINTRESOURCE(IDD_NSTRAYDLG),NULL,TrayIcon::DialogProc); 
     124  if (hDlgWnd == NULL || !IsWindow(hDlgWnd)) { 
     125    NSC_LOG_ERROR_STD(_T("Failed to create windows: ") + error::lookup::last_error()); 
     126  } 
    124127 
    125128  UINT UDM_TASKBARCREATED = RegisterWindowMessage(_T("TaskbarCreated")); 
     
    136139  { 
    137140    if (Msg.message == WM_MY_CLOSE) { 
     141      TrayIcon::removeIcon(Msg.hwnd); 
    138142      ::DestroyWindow(hDlgWnd); 
    139143//    } else if (Msg.message == WM_QUERYENDSESSION) { 
Note: See TracChangeset for help on using the changeset viewer.