Changeset c1d545e in nscp


Ignore:
Timestamp:
02/09/08 11:36:31 (5 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
1a35b3f
Parents:
047516e
Message:

2008-02-09 MickeM

+ New module CheckExternalScripts to handle 1, external script (similar to the old NRPE but in its own module)

  • Can Check batch/vbs/programs/*
  • Works with NSCA module (if you don't want to have NRPE at the same time)
  • Simpler syntax (discarded old and added new section for alias)
  • Started to add "sample alias" to ease initial setup and give some nice ideas (please provide me with feedback on them)
Files:
7 added
13 edited

Legend:

Unmodified
Added
Removed
  • AutoBuild.h

    rde8ef76 rc1d545e  
    33// change the FALSE to TRUE for autoincrement of build number 
    44#define INCREMENT_VERSION TRUE 
    5 #define FILEVER        0,3,0,39 
    6 #define PRODUCTVER     0,3,0,39 
    7 #define STRFILEVER     _T("0.3.0.39") 
    8 #define STRPRODUCTVER  _T("0.3.0.39") 
    9 #define STRPRODUCTDATE  _T("2008-02-03") 
     5#define FILEVER        0,3,0,48 
     6#define PRODUCTVER     0,3,0,48 
     7#define STRFILEVER     _T("0.3.0.48") 
     8#define STRPRODUCTVER  _T("0.3.0.48") 
     9#define STRPRODUCTDATE  _T("2008-02-08") 
    1010#endif // AUTOBUILD_H 
  • NSC.dist

    r8b206ee rc1d545e  
    103103;check_all_services[SERVICE_DEMAND_START]=ignored 
    104104;check_all_services[SERVICE_DISABLED]=stopped 
     105 
     106[External Script] 
     107;# COMMAND TIMEOUT 
     108;  This specifies the maximum number of seconds that the NRPE daemon will allow plug-ins to finish executing before killing them off. 
     109;command_timeout=60 
     110; 
     111;# COMMAND ARGUMENT PROCESSING 
     112;  This option determines whether or not the NRPE daemon will allow clients to specify arguments to commands that are executed. 
     113;allow_arguments=0 
     114; 
     115;# COMMAND ALLOW NASTY META CHARS 
     116;  This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments. 
     117;allow_nasty_meta_chars=0 
     118; 
     119;# COMMAND ALLOW NASTY META CHARS 
     120;  This option determines whether or not the NRPE daemon will allow clients to specify nasty (as in |`&><'"\[]{}) characters in arguments. 
     121;script_dir=c:\my\script\dir 
     122 
     123[External Scripts] 
     124;check_es_long=scripts\long.bat 
     125;check_es_ok=scripts\ok.bat 
     126;check_es_nok=scripts\nok.bat 
     127;check_vbs_sample=cscript.exe //T:30 //NoLogo scripts\check_vb.vbs 
     128 
     129[External Alias] 
     130alias_cpu=checkCPU warn=80 crit=90 time=5m time=1m time=30s 
     131alias_disk=CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED 
     132alias_service=checkServiceState CheckAll 
     133alias_mem=checkMem MaxWarn=80% MaxCrit=90% ShowAll type=physical 
    105134 
    106135 
  • NSCPlugin.cpp

    r047516e rc1d545e  
    147147    return fGetVersion(major, minor, revision)?true:false; 
    148148  } catch (...) { 
    149     throw NSPluginException(file_, _T("Unhandled exception in getVersion in: ": ) + file_); 
     149    throw NSPluginException(file_, _T("Unhandled exception in getVersion.")); 
    150150  } 
    151151} 
     
    163163    return false; 
    164164  } catch (...) { 
    165     throw NSPluginException(file_, _T("Unhandled exception in hasCommandHandler in: ": ) + file_); 
     165    throw NSPluginException(file_, _T("Unhandled exception in hasCommandHandler.")); 
    166166  } 
    167167} 
     
    179179    return false; 
    180180  } catch (...) { 
    181     throw NSPluginException(file_, _T("Unhandled exception in hasMessageHandler in: ": ) + file_); 
     181    throw NSPluginException(file_, _T("Unhandled exception in hasMessageHandler.")); 
    182182  } 
    183183} 
     
    203203    return fHandleCommand(command, argLen, arguments, returnMessageBuffer, returnMessageBufferLen, returnPerfBuffer, returnPerfBufferLen); 
    204204  } catch (...) { 
    205     throw NSPluginException(file_, _T("Unhandled exception in handleCommand in: ": ) + file_); 
     205    throw NSPluginException(file_, _T("Unhandled exception in handleCommand.")); 
    206206  } 
    207207} 
     
    221221    fHandleMessage(msgType, file, line, message); 
    222222  } catch (...) { 
    223     throw NSPluginException(file_, _T("Unhandled exception in handleMessage in: ": ) + file_); 
     223    throw NSPluginException(file_, _T("Unhandled exception in handleMessage.")); 
    224224  } 
    225225} 
     
    236236    fUnLoadModule(); 
    237237  } catch (...) { 
    238     throw NSPluginException(file_, _T("Unhandled exception in handleMessage in: ": ) + file_); 
     238    throw NSPluginException(file_, _T("Unhandled exception in handleMessage.")); 
    239239  } 
    240240  FreeLibrary(hModule_); 
     
    248248    return fGetName(buf, buflen)?true:false; 
    249249  } catch (...) { 
    250     throw NSPluginException(file_, _T("Unhandled exception in getName in: ": ) + file_); 
     250    throw NSPluginException(file_, _T("Unhandled exception in getName.")); 
    251251  } 
    252252} 
     
    257257    return fGetDescription(buf, buflen)?true:false; 
    258258  } catch (...) { 
    259     throw NSPluginException(file_, _T("Unhandled exception in getDescription in: ": ) + file_); 
     259    throw NSPluginException(file_, _T("Unhandled exception in getDescription.")); 
    260260  } 
    261261} 
     
    279279    fModuleHelperInit(NSAPILoader); 
    280280  } catch (...) { 
    281     throw NSPluginException(file_, _T("Unhandled exception in getDescription in: ": ) + file_); 
     281    throw NSPluginException(file_, _T("Unhandled exception in getDescription.")); 
    282282  } 
    283283   
     
    335335    return fGetConfigurationMeta(buflen, buf)?true:false; 
    336336  } catch (...) { 
    337     throw NSPluginException(file_, _T("Unhandled exception in getConfigurationMeta in: ": ) + file_); 
     337    throw NSPluginException(file_, _T("Unhandled exception in getConfigurationMeta.")); 
    338338  } 
    339339} 
     
    345345    return fCommandLineExec(command, argLen, arguments); 
    346346  } catch (...) { 
    347     throw NSPluginException(file_, _T("Unhandled exception in commandLineExec in: ": ) + file_); 
    348   } 
    349 } 
     347    throw NSPluginException(file_, _T("Unhandled exception in commandLineExec.")); 
     348  } 
     349} 
  • NSClient++-2005.sln

    r3f69109 rc1d545e  
    4545EndProject 
    4646Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LUA", "..\..\LUA\LUA\LUA.vcproj", "{B6D08289-B8AE-4391-9D07-93B22618BE58}" 
     47EndProject 
     48Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CheckExternalScripts", "modules\CheckExternalScripts\CheckExternalScripts-2005.vcproj", "{0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}" 
    4749EndProject 
    4850Global 
     
    638640    {B6D08289-B8AE-4391-9D07-93B22618BE58}.Release|Win32.Build.0 = Release|Win32 
    639641    {B6D08289-B8AE-4391-9D07-93B22618BE58}.Release|x64.ActiveCfg = Release|Win32 
     642    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug|Any CPU.ActiveCfg = Debug|x64 
     643    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug|Itanium.ActiveCfg = Debug|x64 
     644    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 
     645    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug|Mixed Platforms.Build.0 = Debug|x64 
     646    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug|Win32.ActiveCfg = Debug|Win32 
     647    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug|Win32.Build.0 = Debug|Win32 
     648    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug|x64.ActiveCfg = Debug|x64 
     649    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug|x64.Build.0 = Debug|x64 
     650    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug-MemCheck|Any CPU.ActiveCfg = Debug-MemCheck|x64 
     651    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug-MemCheck|Itanium.ActiveCfg = Debug-MemCheck|x64 
     652    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug-MemCheck|Mixed Platforms.ActiveCfg = Debug-MemCheck|x64 
     653    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug-MemCheck|Mixed Platforms.Build.0 = Debug-MemCheck|x64 
     654    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug-MemCheck|Win32.ActiveCfg = Debug-MemCheck|Win32 
     655    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug-MemCheck|Win32.Build.0 = Debug-MemCheck|Win32 
     656    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug-MemCheck|x64.ActiveCfg = Debug-MemCheck|x64 
     657    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Debug-MemCheck|x64.Build.0 = Debug-MemCheck|x64 
     658    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Distribution|Any CPU.ActiveCfg = Distribution|x64 
     659    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Distribution|Itanium.ActiveCfg = Distribution|x64 
     660    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Distribution|Mixed Platforms.ActiveCfg = Distribution|x64 
     661    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Distribution|Mixed Platforms.Build.0 = Distribution|x64 
     662    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Distribution|Win32.ActiveCfg = Distribution|Win32 
     663    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Distribution|Win32.Build.0 = Distribution|Win32 
     664    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Distribution|x64.ActiveCfg = Distribution|x64 
     665    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Distribution|x64.Build.0 = Distribution|x64 
     666    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Nightly|Any CPU.ActiveCfg = Nightly|x64 
     667    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Nightly|Itanium.ActiveCfg = Nightly|x64 
     668    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Nightly|Mixed Platforms.ActiveCfg = Nightly|x64 
     669    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Nightly|Mixed Platforms.Build.0 = Nightly|x64 
     670    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Nightly|Win32.ActiveCfg = Nightly|Win32 
     671    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Nightly|Win32.Build.0 = Nightly|Win32 
     672    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Nightly|x64.ActiveCfg = Nightly|x64 
     673    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Nightly|x64.Build.0 = Nightly|x64 
     674    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Release|Any CPU.ActiveCfg = Release|x64 
     675    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Release|Itanium.ActiveCfg = Release|x64 
     676    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Release|Mixed Platforms.ActiveCfg = Release|x64 
     677    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Release|Mixed Platforms.Build.0 = Release|x64 
     678    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Release|Win32.ActiveCfg = Release|Win32 
     679    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Release|Win32.Build.0 = Release|Win32 
     680    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Release|x64.ActiveCfg = Release|x64 
     681    {0BEEC749-0E3E-4FB2-82DA-AC8D4730A129}.Release|x64.Build.0 = Release|x64 
    640682  EndGlobalSection 
    641683  GlobalSection(SolutionProperties) = preSolution 
  • NSClient++.cpp

    rb5ef837 rc1d545e  
    242242  try { 
    243243    mainClient.unloadPlugins(); 
    244   } catch(NSPluginException *e) { 
    245     std::wcout << _T("Exception raised: ") << e->error_ << _T(" in module: ") << e->file_ << std::endl;; 
     244  } catch(NSPluginException &e) { 
     245    std::wcout << _T("Exception raised: ") << e.error_ << _T(" in module: ") << e.file_ << std::endl;; 
    246246  } 
    247247  try { 
  • changelog

    r047516e rc1d545e  
    66 * Add API for rehashing the daemon (or implement it the API is there but does nothing) 
    77 
     82008-02-09 MickeM 
     9 + New module CheckExternalScripts to handle 1, external script (similar to the old NRPE but in its own module) 
     10   - Can Check batch/vbs/programs/* 
     11   - Works with NSCA module (if you don't want to have NRPE at the same time) 
     12   - Simpler syntax (discarded old and added new section for alias) 
     13   - Started to add "sample alias" to ease initial setup and give some nice ideas (please provide me with feedback on them) 
     14 
    8152008-02-08 MickeM 
    916 + Added some more default catch handlers (on the "core" side of plugin-calls). 
     
    2027 
    21282008-02-03 MickeM 
    22  + Added encryption subsystem to NSCA module (still no mcrypt support, but atleast you have "xor" and passwords) 
     29 + Added encryption subsystem to NSCA module (still no mcrypt support, but at least you have "xor" and passwords) 
    2330 + Added API for scripts to register commands 
    2431 + Added command descriptions (for some modules) 
    2532 * Fixed issue in NRPE that displayed a console window when running commands 
    2633 * New improved "inject" dialog from the system tray 
    27    Lists avalible commands, and shows command descriptions and a lot of other improvments. 
    28  + Added an internal log windows that displays log in realtime. 
     34   Lists available commands, and shows command descriptions and a lot of other improvements. 
     35 + Added an internal log windows that displays log in real-time. 
    2936 + Fixed some issues with the dialog procs (should work smoother now, especially Termination) 
    3037 
    31382008-02-02 MickeM 
    3239 * Might have fixed the "missing eventlog messages" problem. 
    33  + Added %count% parameter to syntax which (when used with unique) will display the numbe of hits for each message displayed. 
     40 + Added %count% parameter to syntax which (when used with unique) will display the number of hits for each message displayed. 
    3441 
    35422008-01-27 MickeM 
    3643 * Fixed a memory-leak in format_time 
    3744 * Fixed so time/date is displayed in "local time" (not UTC) for the eventlog check 
    38  + Added %message% to evenlog check. Will display the "proper formated eventlog message" as in the eventlog viewer. 
     45 + Added %message% to eventlog check. Will display the "proper formated eventlog message" as in the eventlog viewer. 
    3946   For this to work you need to have the descriptions flag set 
    4047   In short: /nrpe -H 192.168.0.147 -c checkEventLog -a truncate=1024 "syntax=%generated%: %message%" descriptions=true file=System MaxWarn=1 MaxCrit=1 filter+eventType==error filter+generated=\<12h filter=new filter=all filter=in 
     
    5057 
    51582007-12-10 MickeM 
    52  + Added intial draft for LUA module 
     59 + Added initial draft for LUA module 
    5360 
    54612007-12-09 MickeM 
     
    5663 + Improved the socket thread with: 
    5764    * a default-catch 
    58     * If the socket failes to start we still wait for it to shut down (no error message) 
     65    * If the socket fails to start we still wait for it to shut down (no error message) 
    5966 + Added first version of the NSCA agent (NSCAgent.dll) 
    6067   (no encryption support as of yet, but will come) 
     
    7380 * Fixed some UNICODE issues with process-listings 
    7481 + Added an error message if the "detected" process enumeration method is not available. 
    75  + Fixed some more unicode issues Password encrypt/decrypt: #107 
    76  * Fixed unicode issues with "external programs" #109 
     82 + Fixed some more Unicode issues Password encrypt/decrypt: #107 
     83 * Fixed Unicode issues with "external programs" #109 
    7784 * Fixed so default string for check_nt:s FILEAGE command is "delta" is 5 minutes ago (and not absolute ie. 1970...), Issue #39 
    7885 + added support for  <date strings> to check_nt:s FILEAGE command, Issue #39 
  • include/Mutex.h

    r978bd31 rc1d545e  
    2323#include "Singleton.h" 
    2424#include "strEx.h" 
    25 #include <assert.h> 
    2625#include <windows.h> 
    2726#include <iostream> 
     
    6261    if ( GetLastError() == ERROR_ALREADY_EXISTS ) 
    6362      hMutex = OpenMutex(MUTEX_ALL_ACCESS, FALSE, NULL); 
    64     assert(hMutex != NULL); 
     63    std::wcout << _T("Error in mutex creation: ") << GetLastError() << std::endl; 
    6564  } 
    6665  /** 
     
    123122   */ 
    124123  MutexLock(HANDLE hMutex, DWORD timeout = 5000L) : bHasMutex(false), hMutex_(hMutex) { 
    125     if (hMutex_ == NULL) 
    126       std::wcout << "Whops..." << std::endl; 
    127     assert(hMutex_ != NULL); 
     124    if (hMutex_ == NULL) { 
     125      std::wcout << _T("Error in mutex lock: ") << std::endl; 
     126      bHasMutex = false; 
     127      return; 
     128    } 
    128129    dwWaitResult = WaitForSingleObject(hMutex_, timeout); 
    129130    switch (dwWaitResult) { 
  • include/NSCHelper.cpp

    r6b690bf rc1d545e  
    268268 * @return The result of the command 
    269269 */ 
    270 NSCAPI::nagiosReturn NSCModuleHelper::InjectSplitAndCommand(const std::wstring command, const std::wstring buffer, TCHAR splitChar, std::wstring & message, std::wstring & perf) 
     270NSCAPI::nagiosReturn NSCModuleHelper::InjectSplitAndCommand(const std::wstring command, const std::wstring buffer, TCHAR splitChar, std::wstring & message, std::wstring & perf, bool escape) 
    271271{ 
    272272  if (!fNSAPIInject) 
     
    277277    aBuffer= arrayBuffer::createEmptyArrayBuffer(argLen); 
    278278  else 
    279     aBuffer= arrayBuffer::split2arrayBuffer(buffer, splitChar, argLen); 
     279    aBuffer= arrayBuffer::split2arrayBuffer(buffer, splitChar, argLen, escape); 
    280280  NSCAPI::nagiosReturn ret = InjectCommand(command.c_str(), argLen, aBuffer, message, perf); 
    281281  arrayBuffer::destroyArrayBuffer(aBuffer, argLen); 
  • include/NSCHelper.h

    r047516e rc1d545e  
    134134  NSCAPI::nagiosReturn InjectCommand(const TCHAR* command, const unsigned int argLen, TCHAR **argument, std::wstring & message, std::wstring & perf); 
    135135  NSCAPI::nagiosReturn InjectSplitAndCommand(const TCHAR* command, TCHAR* buffer, TCHAR splitChar, std::wstring & message, std::wstring & perf); 
    136   NSCAPI::nagiosReturn InjectSplitAndCommand(const std::wstring command, const std::wstring buffer, TCHAR splitChar, std::wstring & message, std::wstring & perf); 
     136  NSCAPI::nagiosReturn InjectSplitAndCommand(const std::wstring command, const std::wstring buffer, TCHAR splitChar, std::wstring & message, std::wstring & perf, bool escape = false); 
    137137  void StopService(void); 
    138138  std::wstring getBasePath(); 
  • include/config.h

    r035c51f rc1d545e  
    105105#define NRPE_SETTINGS_SCRIPTDIR_DEFAULT _T("") 
    106106 
     107// External Script Settings headlines 
     108#define EXTSCRIPT_SECTION_TITLE _T("External Script") 
     109#define EXTSCRIPT_SCRIPT_SECTION_TITLE _T("External Scripts") 
     110#define EXTSCRIPT_ALIAS_SECTION_TITLE _T("External Alias") 
     111#define EXTSCRIPT_SETTINGS_TIMEOUT _T("command_timeout") 
     112#define EXTSCRIPT_SETTINGS_TIMEOUT_DEFAULT 60 
     113#define EXTSCRIPT_SETTINGS_ALLOW_ARGUMENTS _T("allow_arguments") 
     114#define EXTSCRIPT_SETTINGS_ALLOW_ARGUMENTS_DEFAULT 0 
     115#define EXTSCRIPT_SETTINGS_ALLOW_NASTY_META _T("allow_nasty_meta_chars") 
     116#define EXTSCRIPT_SETTINGS_ALLOW_NASTY_META_DEFAULT 0 
     117#define EXTSCRIPT_SETTINGS_SCRIPTDIR _T("script_dir") 
     118#define EXTSCRIPT_SETTINGS_SCRIPTDIR_DEFAULT _T("") 
     119 
    107120// Check System Settings 
    108121#define C_SYSTEM_SECTION_TITLE _T("Check System") 
  • include/thread.h

    r047516e rc1d545e  
    6868  bool bThreadHasBeenClosed; 
    6969 
    70  
     70#define THREAD_MAGIC_ID 123456 
    7171 
    7272  typedef struct thread_param { 
     
    7474    LPVOID lpParam;   // The optional argument to the thread 
    7575    Thread *pCore; 
     76    unsigned int magic_id; 
    7677  } thread_param; 
    7778 
     
    8384  Thread(std::wstring threadid) : threadid_(threadid), hThread_(NULL), pObject_(NULL), uThreadID(-1), bThreadHasTerminated(false), bThreadHasBeenClosed(false) { 
    8485    hMutex_ = CreateMutex(NULL, FALSE, NULL); 
    85     assert(hMutex_ != NULL); 
     86    if (hMutex_ == NULL) { 
     87      std::wcerr << _T("Failed to create thread mutec for thread: ") << threadid << _T(": ") << GetLastError() << std::endl; 
     88    } 
    8689  } 
    8790  /** 
     
    125128  static unsigned __stdcall threadProc(void* lpParameter) { 
    126129    thread_param* param = static_cast<thread_param*>(lpParameter); 
     130    if (param->magic_id != THREAD_MAGIC_ID) { 
     131      std::wcerr << _T("Thread magic ID check failed :(") << std::endl; 
     132      _endthreadex( 0 ); 
     133      return 0; 
     134    } 
    127135    T* instance = param->instance; 
    128136    LPVOID lpParam = param->lpParam; 
    129137    Thread *pCore = param->pCore; 
    130138    delete param; 
    131  
    132     unsigned returnCode = instance->threadProc(lpParam); 
     139    unsigned returnCode = 0; 
     140    try { 
     141      returnCode = instance->threadProc(lpParam); 
     142    } catch (...) { 
     143      std::wcerr << _T("Unhandled exception in thread a :(") << std::endl; 
     144    } 
    133145    pCore->terminate(); 
    134146    _endthreadex( 0 ); 
    135147    return returnCode; 
    136  
    137 //    _endthread(); 
    138148  } 
    139149 
     
    149159   */ 
    150160  void createThread(LPVOID lpParam = NULL) { 
     161    if (hMutex_ == NULL) 
     162      throw ThreadException(_T("No mutex in createThread (") + threadid_ + _T(") not started...")); 
    151163    thread_param* param = NULL; 
    152164    { 
     
    158170        throw ThreadException(_T("Thread already started, thread (") + threadid_ + _T(") not started...")); 
    159171      } 
    160 //      assert(hStopEvent_ == NULL); 
    161172      param = new thread_param; 
     173      if (param == NULL) 
     174        throw ThreadException(_T("Failed to allocate memory for new thread: ") + threadid_); 
    162175      param->instance = pObject_ = new T; 
    163 //      param->hStopEvent = hStopEvent_ = CreateEvent(NULL, TRUE, FALSE, NULL); 
     176      if (param->instance == NULL) 
     177        throw ThreadException(_T("Failed to allocate memory for new thread: ") + threadid_); 
    164178      param->lpParam = lpParam; 
    165179      param->pCore = this; 
    166     } 
    167     //hThread_ = reinterpret_cast<HANDLE>(::_beginthreadex(threadProc, 0, reinterpret_cast<VOID*>(param))); 
    168     //hThread = (HANDLE)_beginthreadex( NULL, 0, &SecondThreadFunc, NULL, 0, &threadID ); 
     180      param->magic_id = THREAD_MAGIC_ID; 
     181    } 
    169182    uintptr_t thread_handle = ::_beginthreadex(NULL, 0, threadProc, reinterpret_cast<VOID*>(param), 0, &uThreadID); 
    170183    if (thread_handle == 0 || thread_handle == 1 || thread_handle == -1) { 
     
    179192   */ 
    180193  bool exitThread(const unsigned int delay = 20000L) { 
     194    if (hMutex_ == NULL) 
     195      throw ThreadException(_T("No mutex in createThread (") + threadid_ + _T(") not started...")); 
    181196    DWORD dwWaitResult = -1; 
    182197    { 
     
    198213    } 
    199214    std::wcerr << _T("Failed to terminate thread: ") << threadid_ << _T("...") << std::endl; 
    200     //assert(false); 
    201215    return false; 
    202216  } 
  • modules/CheckSystem/PDHCollector.cpp

    r47b843a rc1d545e  
    4747  bool bUseIndex = false; 
    4848 
    49   // Investigate enviornment and find out what to use 
     49  // Investigate environment and find out what to use 
    5050  try { 
    5151    OSVERSIONINFO osVer = systemInfo::getOSVersion(); 
Note: See TracChangeset for help on using the changeset viewer.