Changeset 36c340d in nscp


Ignore:
Timestamp:
02/25/05 21:47:45 (8 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
8223547
Parents:
a1e1922
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
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • NSCPlugin.cpp

    rac676a8 r36c340d  
    88 * @param file The file (DLL) to load as a NSC plug in. 
    99 */ 
    10 NSCPlugin::NSCPlugin(std::string file) 
     10NSCPlugin::NSCPlugin(const std::string file) 
    1111  : file_(file) 
    1212  ,fLoadModule(NULL) 
     
    130130 */ 
    131131void NSCPlugin::handleMessage(int msgType, const char* file, const int line, const char *message) { 
    132   if (!isLoaded()) 
     132  if (!fHandleMessage) 
    133133    throw NSPluginException(file_, "Library is not loaded"); 
    134134  fHandleMessage(msgType, file, line, message); 
  • NSCPlugin.h

    rac676a8 r36c340d  
    107107 
    108108public: 
    109   NSCPlugin(std::string file); 
     109  NSCPlugin(const std::string file); 
    110110  virtual ~NSCPlugin(void); 
    111111 
  • NSClient++.cpp

    r3baaa4d r36c340d  
    144144 * @param plugins A list with plug-ins (DLL files) to load 
    145145 */ 
    146 void NSClientT::loadPlugins(std::list<std::string> plugins) { 
     146void NSClientT::loadPlugins(const std::list<std::string> plugins) { 
     147  MutexLock lock(pluginMutex); 
     148  if (!lock.hasMutex()) { 
     149    LOG_ERROR("FATAL ERROR: Could not get mutex."); 
     150    return; 
     151  } 
    147152  std::list<std::string>::const_iterator it; 
    148153  for (it = plugins.begin(); it != plugins.end(); ++it) { 
     
    154159 */ 
    155160void NSClientT::unloadPlugins() { 
     161  MutexLock lock(pluginMutex); 
     162  if (!lock.hasMutex()) { 
     163    LOG_ERROR("FATAL ERROR: Could not get mutex."); 
     164    return; 
     165  } 
    156166  pluginList::reverse_iterator it; 
    157167  for (it = plugins_.rbegin(); it != plugins_.rend(); ++it) { 
     
    175185 * @param file The DLL file 
    176186 */ 
    177 void NSClientT::loadPlugin(std::string file) { 
     187void NSClientT::loadPlugin(const std::string file) { 
    178188  addPlugin(new NSCPlugin(file)); 
    179189} 
     
    183193 */ 
    184194void NSClientT::addPlugin(plugin_type plugin) { 
     195  MutexLock lock(pluginMutex); 
     196  if (!lock.hasMutex()) { 
     197    LOG_ERROR("FATAL ERROR: Could not get mutex."); 
     198    return; 
     199  } 
    185200  plugin->load(); 
    186201  LOG_DEBUG_STD("Loading: " + plugin->getName()); 
     
    198213 * @return The result, empty string if no result 
    199214 */ 
    200 std::string NSClientT::inject(std::string buffer) { 
     215std::string NSClientT::inject(const std::string buffer) { 
    201216  std::list<std::string> args = charEx::split(buffer.c_str(), '&'); 
    202   if (args.size() < 2) { 
    203     LOG_MESSAGE("Insufficient arguments!"); 
    204   } 
    205217  std::string command = args.front(); args.pop_front(); 
    206218  LOG_MESSAGE_STD("Injecting: " + command); 
     
    230242 */ 
    231243std::string NSClientT::execute(std::string password, std::string cmd, std::list<std::string> args) { 
     244  MutexLock lock(pluginMutex); 
     245  if (!lock.hasMutex()) { 
     246    LOG_ERROR("FATAL ERROR: Could not get mutex."); 
     247    return "FATAL ERROR"; 
     248  } 
    232249  static unsigned int bufferSize = 0; 
    233250  if (bufferSize == 0) 
     
    257274        break; 
    258275      } else if (c == NSCAPI::isfalse) {      // Module ignored the message 
     276        LOG_DEBUG("A module ignored this message"); 
    259277      } else if (c == NSCAPI::invalidBufferLen) { // Buffer is to small 
    260278        LOG_ERROR("Return buffer to small, need to increase it in the ini file."); 
     
    279297 * @param msgType Message type  
    280298 * @param file Filename generally __FILE__ 
    281  * @param line  Line number, generaly __LINE__ 
     299 * @param line  Line number, generally __LINE__ 
    282300 * @param message The message as a human readable string. 
    283301 */ 
    284302void NSClientT::reportMessage(int msgType, const char* file, const int line, std::string message) { 
    285303  MutexLock lock(messageMutex); 
     304  if (!lock.hasMutex()) { 
     305    LOG_ERROR("FATAL ERROR: Could not get mutex."); 
     306    return; 
     307  } 
     308  if (msgType == NSCAPI::debug) { 
     309    typedef enum status {unknown, debug, nodebug }; 
     310    static status d = unknown; 
     311    if (d == unknown) { 
     312      if (Settings::getInstance()->getInt("log", "debug", 0) == 1) 
     313        d = debug; 
     314      else 
     315        d = nodebug; 
     316    } 
     317    if (d == nodebug) 
     318      return; 
     319  } 
    286320  pluginList::const_iterator plit; 
    287321  for (plit = messageHandlers_.begin(); plit != messageHandlers_.end(); ++plit) { 
     
    290324    } catch(const NSPluginException& e) { 
    291325      // Here we are pretty much fucked! (as logging this might cause a loop :) 
    292       throw "This shouldn't have happened..."; 
     326      std::cout << "This is *really really* bad, now the world is about to end..." << std::endl; 
    293327    } 
    294328  } 
    295329} 
    296330std::string NSClientT::getBasePath(void) { 
     331  MutexLock lock(pluginMutex); 
     332  if (!lock.hasMutex()) { 
     333    LOG_ERROR("FATAL ERROR: Could not get mutex."); 
     334    return "FATAL ERROR"; 
     335  } 
    297336  if (!basePath.empty()) 
    298337    return basePath; 
     
    314353  return Settings::getInstance()->getInt(section, key, defaultValue); 
    315354} 
    316  
    317  
    318355int NSAPIGetBasePath(char*buffer, unsigned int bufLen) { 
    319356  return NSCHelper::wrapReturnString(buffer, bufLen, mainClient.getBasePath()); 
  • NSClient++.h

    rac676a8 r36c340d  
    4444  TCPSocketResponderThread socketThread; 
    4545  std::string basePath; 
     46  MutexHandler pluginMutex; 
    4647  MutexHandler messageMutex; 
    4748 
     
    6061  static std::string getPassword(void); 
    6162  std::string getBasePath(void); 
    62   std::string inject(std::string buffer); 
     63  std::string inject(const std::string buffer); 
    6364  std::string execute(std::string password, std::string cmd, std::list<std::string> args); 
    6465  void reportMessage(int msgType, const char* file, const int line, std::string message); 
    6566 
    66   void loadPlugins(std::list<std::string> plugins); 
    67   void loadPlugin(std::string plugin); 
     67  void loadPlugins(const std::list<std::string> plugins); 
     68  void loadPlugin(const std::string plugin); 
    6869  void loadPlugins(void); 
    6970  void unloadPlugins(void); 
     
    106107#define LOG_MESSAGE(msg) \ 
    107108  NSAPIMessage(NSCAPI::log, __FILE__, __LINE__, msg) 
    108 #ifdef _DEBUG 
    109109#define LOG_DEBUG_STD(msg) LOG_DEBUG(((std::string)msg).c_str()) 
    110110#define LOG_DEBUG(msg) \ 
    111111  NSAPIMessage(NSCAPI::debug, __FILE__, __LINE__, msg) 
    112 #else 
    113 #define LOG_DEBUG_STD(msg) 
    114 #define LOG_DEBUG(msg) 
    115 #endif 
    116  
  • NSClient++.sln

    rdb70efa r36c340d  
    22Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NSClient++", "NSClient++.vcproj", "{2286162D-7571-4735-BAC8-4A8D33A4F42D}" 
    33  ProjectSection(ProjectDependencies) = postProject 
    4     {BA246C01-063A-4548-8957-32D5CC76171B} = {BA246C01-063A-4548-8957-32D5CC76171B} 
    54    {BBFF8362-C626-4838-B0A2-F695D638AD24} = {BBFF8362-C626-4838-B0A2-F695D638AD24} 
    65    {2D78C363-02BD-4171-8F91-6B4D669A98BF} = {2D78C363-02BD-4171-8F91-6B4D669A98BF} 
    76    {79F1F571-78A6-4B20-8BD5-0F65CD60012C} = {79F1F571-78A6-4B20-8BD5-0F65CD60012C} 
     7    {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45} = {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45} 
    88    {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F} = {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F} 
    99  EndProjectSection 
     
    3939  GlobalSection(SolutionConfiguration) = preSolution 
    4040    Debug = Debug 
     41    Debug Dynamic Linkage = Debug Dynamic Linkage 
    4142    Release = Release 
     43    Release Dynamic Linkage = Release Dynamic Linkage 
    4244    Release M$ STL = Release M$ STL 
    4345  EndGlobalSection 
     
    4547    {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Debug.ActiveCfg = Debug|Win32 
    4648    {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Debug.Build.0 = Debug|Win32 
     49    {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 
     50    {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 
    4751    {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Release.ActiveCfg = Release|Win32 
    4852    {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Release.Build.0 = Release|Win32 
     53    {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 
     54    {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 
    4955    {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Release M$ STL.ActiveCfg = Release M$ STL|Win32 
    5056    {2286162D-7571-4735-BAC8-4A8D33A4F42D}.Release M$ STL.Build.0 = Release M$ STL|Win32 
    5157    {BBFF8362-C626-4838-B0A2-F695D638AD24}.Debug.ActiveCfg = Debug|Win32 
    5258    {BBFF8362-C626-4838-B0A2-F695D638AD24}.Debug.Build.0 = Debug|Win32 
     59    {BBFF8362-C626-4838-B0A2-F695D638AD24}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 
     60    {BBFF8362-C626-4838-B0A2-F695D638AD24}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 
    5361    {BBFF8362-C626-4838-B0A2-F695D638AD24}.Release.ActiveCfg = Release|Win32 
    5462    {BBFF8362-C626-4838-B0A2-F695D638AD24}.Release.Build.0 = Release|Win32 
     63    {BBFF8362-C626-4838-B0A2-F695D638AD24}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 
     64    {BBFF8362-C626-4838-B0A2-F695D638AD24}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 
    5565    {BBFF8362-C626-4838-B0A2-F695D638AD24}.Release M$ STL.ActiveCfg = Release|Win32 
    5666    {BBFF8362-C626-4838-B0A2-F695D638AD24}.Release M$ STL.Build.0 = Release|Win32 
    5767    {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Debug.ActiveCfg = Debug|Win32 
    5868    {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Debug.Build.0 = Debug|Win32 
     69    {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 
     70    {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 
    5971    {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Release.ActiveCfg = Release|Win32 
    6072    {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Release.Build.0 = Release|Win32 
     73    {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 
     74    {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 
    6175    {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Release M$ STL.ActiveCfg = Release|Win32 
    6276    {79F1F571-78A6-4B20-8BD5-0F65CD60012C}.Release M$ STL.Build.0 = Release|Win32 
    6377    {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Debug.ActiveCfg = Debug|Win32 
    6478    {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Debug.Build.0 = Debug|Win32 
     79    {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 
     80    {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 
    6581    {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Release.ActiveCfg = Release|Win32 
    6682    {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Release.Build.0 = Release|Win32 
     83    {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 
     84    {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 
    6785    {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Release M$ STL.ActiveCfg = Release|Win32 
    6886    {2D78C363-02BD-4171-8F91-6B4D669A98BF}.Release M$ STL.Build.0 = Release|Win32 
    6987    {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Debug.ActiveCfg = Debug|Win32 
    7088    {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Debug.Build.0 = Debug|Win32 
     89    {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 
     90    {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 
    7191    {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Release.ActiveCfg = Release|Win32 
    7292    {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Release.Build.0 = Release|Win32 
     93    {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 
     94    {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 
    7395    {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Release M$ STL.ActiveCfg = Release|Win32 
    7496    {62B685D7-3A2E-4F3E-B2B8-B17F20C0217F}.Release M$ STL.Build.0 = Release|Win32 
    7597    {BA246C01-063A-4548-8957-32D5CC76171B}.Debug.ActiveCfg = Debug|Win32 
    7698    {BA246C01-063A-4548-8957-32D5CC76171B}.Debug.Build.0 = Debug|Win32 
     99    {BA246C01-063A-4548-8957-32D5CC76171B}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 
     100    {BA246C01-063A-4548-8957-32D5CC76171B}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 
    77101    {BA246C01-063A-4548-8957-32D5CC76171B}.Release.ActiveCfg = Release|Win32 
    78102    {BA246C01-063A-4548-8957-32D5CC76171B}.Release.Build.0 = Release|Win32 
     103    {BA246C01-063A-4548-8957-32D5CC76171B}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 
     104    {BA246C01-063A-4548-8957-32D5CC76171B}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 
    79105    {BA246C01-063A-4548-8957-32D5CC76171B}.Release M$ STL.ActiveCfg = Release|Win32 
    80106    {BA246C01-063A-4548-8957-32D5CC76171B}.Release M$ STL.Build.0 = Release|Win32 
    81107    {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Debug.ActiveCfg = Debug|Win32 
    82108    {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Debug.Build.0 = Debug|Win32 
     109    {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Debug Dynamic Linkage.ActiveCfg = Debug Dynamic Linkage|Win32 
     110    {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Debug Dynamic Linkage.Build.0 = Debug Dynamic Linkage|Win32 
    83111    {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Release.ActiveCfg = Release|Win32 
    84112    {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Release.Build.0 = Release|Win32 
     113    {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Release Dynamic Linkage.ActiveCfg = Dynamic Linkage|Win32 
     114    {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Release Dynamic Linkage.Build.0 = Dynamic Linkage|Win32 
    85115    {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Release M$ STL.ActiveCfg = Release|Win32 
    86116    {E6E588AB-EFEF-481C-9AF7-DCDCB95CFF45}.Release M$ STL.Build.0 = Release|Win32 
  • NSClient++.vcproj

    ra0528c4 r36c340d  
    209209        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
    210210    </Configuration> 
     211    <Configuration 
     212      Name="Dynamic Linkage|Win32" 
     213      OutputDirectory="$(ConfigurationName)" 
     214      IntermediateDirectory="$(ConfigurationName)" 
     215      ConfigurationType="1" 
     216      UseOfMFC="0" 
     217      ATLMinimizesCRunTimeLibraryUsage="FALSE" 
     218      CharacterSet="2"> 
     219      <Tool 
     220        Name="VCCLCompilerTool" 
     221        Optimization="2" 
     222        InlineFunctionExpansion="1" 
     223        AdditionalIncludeDirectories="include" 
     224        PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" 
     225        StringPooling="TRUE" 
     226        RuntimeLibrary="2" 
     227        EnableFunctionLevelLinking="TRUE" 
     228        UsePrecompiledHeader="3" 
     229        PrecompiledHeaderThrough="stdafx.h" 
     230        PrecompiledHeaderFile=".\Release/IconService.pch" 
     231        AssemblerListingLocation=".\Release/" 
     232        ObjectFile=".\Release/" 
     233        ProgramDataBaseFileName=".\Release/" 
     234        WarningLevel="3" 
     235        SuppressStartupBanner="TRUE"/> 
     236      <Tool 
     237        Name="VCCustomBuildTool"/> 
     238      <Tool 
     239        Name="VCLinkerTool" 
     240        AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib" 
     241        OutputFile=".\Release/NSClient++.exe" 
     242        LinkIncremental="1" 
     243        SuppressStartupBanner="TRUE" 
     244        IgnoreAllDefaultLibraries="FALSE" 
     245        IgnoreDefaultLibraryNames="" 
     246        ModuleDefinitionFile="" 
     247        ProgramDatabaseFile=".\Release/IconService.pdb" 
     248        SubSystem="1" 
     249        OptimizeForWindows98="1" 
     250        TargetMachine="1"/> 
     251      <Tool 
     252        Name="VCMIDLTool" 
     253        TypeLibraryName=".\Release/IconService.tlb" 
     254        HeaderFileName=""/> 
     255      <Tool 
     256        Name="VCPostBuildEventTool"/> 
     257      <Tool 
     258        Name="VCPreBuildEventTool"/> 
     259      <Tool 
     260        Name="VCPreLinkEventTool"/> 
     261      <Tool 
     262        Name="VCResourceCompilerTool" 
     263        PreprocessorDefinitions="NDEBUG" 
     264        Culture="1036" 
     265        AdditionalIncludeDirectories="./res/"/> 
     266      <Tool 
     267        Name="VCWebServiceProxyGeneratorTool"/> 
     268      <Tool 
     269        Name="VCXMLDataGeneratorTool"/> 
     270      <Tool 
     271        Name="VCWebDeploymentTool"/> 
     272      <Tool 
     273        Name="VCManagedWrapperGeneratorTool"/> 
     274      <Tool 
     275        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     276    </Configuration> 
     277    <Configuration 
     278      Name="Debug Dynamic Linkage|Win32" 
     279      OutputDirectory="$(ConfigurationName)" 
     280      IntermediateDirectory="$(ConfigurationName)" 
     281      ConfigurationType="1" 
     282      UseOfMFC="0" 
     283      ATLMinimizesCRunTimeLibraryUsage="FALSE" 
     284      CharacterSet="2"> 
     285      <Tool 
     286        Name="VCCLCompilerTool" 
     287        Optimization="0" 
     288        AdditionalIncludeDirectories="include" 
     289        PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 
     290        BasicRuntimeChecks="3" 
     291        RuntimeLibrary="3" 
     292        UsePrecompiledHeader="3" 
     293        PrecompiledHeaderThrough="stdafx.h" 
     294        PrecompiledHeaderFile=".\Debug/IconService.pch" 
     295        AssemblerListingLocation=".\Debug/" 
     296        ObjectFile=".\Debug/" 
     297        ProgramDataBaseFileName=".\Debug/" 
     298        WarningLevel="3" 
     299        SuppressStartupBanner="TRUE" 
     300        DebugInformationFormat="4"/> 
     301      <Tool 
     302        Name="VCCustomBuildTool"/> 
     303      <Tool 
     304        Name="VCLinkerTool" 
     305        AdditionalDependencies="kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib" 
     306        OutputFile=".\Debug/NSClient++.exe" 
     307        LinkIncremental="1" 
     308        SuppressStartupBanner="TRUE" 
     309        ModuleDefinitionFile="" 
     310        GenerateDebugInformation="TRUE" 
     311        ProgramDatabaseFile=".\Debug/IconService.pdb" 
     312        SubSystem="1" 
     313        TargetMachine="1"/> 
     314      <Tool 
     315        Name="VCMIDLTool" 
     316        TypeLibraryName=".\Debug/IconService.tlb" 
     317        HeaderFileName=""/> 
     318      <Tool 
     319        Name="VCPostBuildEventTool"/> 
     320      <Tool 
     321        Name="VCPreBuildEventTool"/> 
     322      <Tool 
     323        Name="VCPreLinkEventTool"/> 
     324      <Tool 
     325        Name="VCResourceCompilerTool" 
     326        PreprocessorDefinitions="_DEBUG" 
     327        Culture="1036" 
     328        AdditionalIncludeDirectories="./res/"/> 
     329      <Tool 
     330        Name="VCWebServiceProxyGeneratorTool"/> 
     331      <Tool 
     332        Name="VCXMLDataGeneratorTool"/> 
     333      <Tool 
     334        Name="VCWebDeploymentTool"/> 
     335      <Tool 
     336        Name="VCManagedWrapperGeneratorTool"/> 
     337      <Tool 
     338        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     339    </Configuration> 
    211340  </Configurations> 
    212341  <References> 
     
    256385            Optimization="2" 
    257386            PreprocessorDefinitions="" 
     387            UsePrecompiledHeader="1"/> 
     388        </FileConfiguration> 
     389        <FileConfiguration 
     390          Name="Dynamic Linkage|Win32"> 
     391          <Tool 
     392            Name="VCCLCompilerTool" 
     393            Optimization="2" 
     394            PreprocessorDefinitions="" 
     395            UsePrecompiledHeader="1"/> 
     396        </FileConfiguration> 
     397        <FileConfiguration 
     398          Name="Debug Dynamic Linkage|Win32"> 
     399          <Tool 
     400            Name="VCCLCompilerTool" 
     401            Optimization="0" 
     402            PreprocessorDefinitions="" 
     403            BasicRuntimeChecks="3" 
    258404            UsePrecompiledHeader="1"/> 
    259405        </FileConfiguration> 
     
    328474"/> 
    329475        </FileConfiguration> 
     476        <FileConfiguration 
     477          Name="Dynamic Linkage|Win32"> 
     478          <Tool 
     479            Name="VCCustomBuildTool" 
     480            CommandLine="doxygen.exe $(InputPath) 
     481" 
     482            Outputs=".\Doc"/> 
     483        </FileConfiguration> 
     484        <FileConfiguration 
     485          Name="Debug Dynamic Linkage|Win32" 
     486          ExcludedFromBuild="TRUE"> 
     487          <Tool 
     488            Name="VCCustomBuildTool" 
     489            CommandLine="doxygen.exe $(InputPath) 
     490"/> 
     491        </FileConfiguration> 
    330492      </File> 
    331493      <File 
     
    353515        <FileConfiguration 
    354516          Name="Release M$ STL|Win32"> 
     517          <Tool 
     518            Name="VCCustomBuildTool" 
     519            CommandLine="copy $(InputPath) $(OutDir)\$(InputFileName) 
     520" 
     521            Outputs="$(OutDir)\$(InputFileName)"/> 
     522        </FileConfiguration> 
     523        <FileConfiguration 
     524          Name="Dynamic Linkage|Win32" 
     525          ExcludedFromBuild="TRUE"> 
     526          <Tool 
     527            Name="VCCustomBuildTool" 
     528            CommandLine="copy $(InputPath) $(OutDir)\$(InputFileName) 
     529" 
     530            AdditionalDependencies="" 
     531            Outputs="$(OutDir)\$(InputFileName)"/> 
     532        </FileConfiguration> 
     533        <FileConfiguration 
     534          Name="Debug Dynamic Linkage|Win32" 
     535          ExcludedFromBuild="TRUE"> 
    355536          <Tool 
    356537            Name="VCCustomBuildTool" 
  • Settings.h

    ra0528c4 r36c340d  
    5858   * @return The value or defaultValue if the key is not found 
    5959   */ 
    60   std::string getString(std::string section, std::string key, std::string defaultValue = "") { 
     60  std::string getString(std::string section, std::string key, std::string defaultValue = "") const { 
    6161    char* buffer = new char[1024]; 
    6262    GetPrivateProfileString(section.c_str(), key.c_str(), defaultValue.c_str(), buffer, 1023, file_.c_str()); 
  • include/NSCAPI.h

    ra0528c4 r36c340d  
    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 
  • include/NSCHelper.cpp

    r3baaa4d r36c340d  
    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 
  • include/NSCHelper.h

    r3baaa4d r36c340d  
    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////////////////////////////////////////////////////////////////////////// 
  • include/PDHCounter.h

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

    r55159fd r36c340d  
    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. 
  • modules/CheckDisk/CheckDisk.cpp

    ra1e1922 r36c340d  
    5050    if (!(wfd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) { 
    5151      size += (wfd.nFileSizeHigh * ((long long)MAXDWORD+1)) + (long long)wfd.nFileSizeLow; 
    52       NSC_LOG_ERROR_STD(wfd.cFileName + ": " + strEx::itos((wfd.nFileSizeHigh * ((long long)MAXDWORD+1)) + (long long)wfd.nFileSizeLow) + " --- " + strEx::itos(size)); 
    5352    } 
    5453    return true; 
     
    8382} 
    8483 
    85  
    86 // CheckDirectorySize&<Directory>&<Directory>... 
    87 // request: CheckDirectorySize&<warning>&<max>&<Directory>&<Directory>... 
    88 // Return: <return state>&<return string>... 
    89 // <return state> 0 - No errors 
    90 //          1 - Unknown 
    91 //          2 - Errors 
    92 // <return string>  <directory> <size mb> ... 
    93 // test: CheckDirectorySize&1024M&4096M&c:\WINDOWS\*.* 
    94 //       CheckDirectorySize 
     84std::string CheckDisk::CheckFileSize(const unsigned int argLen, char **char_args) { 
     85  // CheckFileSize 
     86  // request: CheckFileSize&<option>&<option>... 
     87  // <option>     MaxWarn=<size gmkb> 
     88  //          MaxCrit=<size gmkb> 
     89  //          MinWarn=<size gmkb> 
     90  //          MinCrit=<size gmkb> 
     91  //          ShowAll 
     92  //          File=<path> 
     93  //          File:<shortname>=<path> 
     94  // 
     95  // Return: <return state>&<return string>... 
     96  // <return state> 0 - No errors 
     97  //          1 - Unknown 
     98  //          2 - Errors 
     99  // <size gmkb> is a size with a possible modifier letter (such as G for gigabyte, M for Megabyte, K for kilobyte etc) 
     100  // Examples: 
     101  // <return string>  <directory> <size gmkb> ... |<shortname>=<size>:<warn>:<crit> 
     102  // test: CheckFileSize&ShowAll&MaxWarn=1024M&MaxCrit=4096M&File:WIN=c:\WINDOWS\*.* 
     103  //       CheckFileSize 
     104  // 
     105  // check_nscp -H <ip> -p <port> -s <passwd> -c <commandstring> 
     106  // 
     107  // ./check_nscp -H 192.168.0.167 -p 1234 -s pwd -c 'CheckFileSize&ShowAll&MaxWarn=1024M&MaxCrit=4096M&File:WIN=c:\WINDOWS\*.*' 
     108  // WIN: 1G (2110962363B)|WIN:2110962363:1073741824:4294967296 
     109  NSC_DEBUG_MSG("CheckFileSize"); 
     110  std::string perfData; 
     111  std::string ret; 
     112  NSCAPI::returnCodes returnCode = NSCAPI::returnOK; 
     113  std::list<std::string> args = NSCHelper::makelist(argLen, char_args); 
     114  if (args.empty()) 
     115    return "Missing argument(s)."; 
     116  long long maxWarn = 0; 
     117  long long maxCrit = 0; 
     118  long long minWarn = 0; 
     119  long long minCrit = 0; 
     120  bool bShowAll = false; 
     121  std::list<std::pair<std::string,std::string> > paths; 
     122 
     123  std::list<std::string>::const_iterator cit; 
     124  for (cit=args.begin();cit!=args.end();++cit) { 
     125    std::string arg = *cit; 
     126    std::pair<std::string,std::string> p = strEx::split(arg,"="); 
     127    if (p.first == "File") { 
     128      paths.push_back(std::pair<std::string,std::string>("",p.second)); 
     129    } else if (p.first == "MaxWarn") { 
     130      maxWarn = strEx::stoi64_as_BKMG(p.second); 
     131    } else if (p.first == "MinWarn") { 
     132      minWarn = strEx::stoi64_as_BKMG(p.second); 
     133    } else if (p.first == "MaxCrit") { 
     134      maxCrit = strEx::stoi64_as_BKMG(p.second); 
     135    } else if (p.first == "MinCrit") { 
     136      minCrit = strEx::stoi64_as_BKMG(p.second); 
     137    } else if (p.first == "ShowAll") { 
     138      bShowAll = true; 
     139    } else if (p.first.find(":") != std::string::npos) { 
     140      std::pair<std::string,std::string> p2 = strEx::split(p.first,":"); 
     141      if (p2.first == "File") { 
     142        paths.push_back(std::pair<std::string,std::string>(p2.second,p.second)); 
     143      } else { 
     144        return "Unknown command: " + p.first; 
     145      } 
     146    } else { 
     147      return "Unknown command: " + p.first; 
     148    } 
     149  } 
     150  NSC_DEBUG_MSG_STD("Bounds: critical " + strEx::itos(minCrit) + " > siez > " + strEx::itos(maxCrit)); 
     151  NSC_DEBUG_MSG_STD("Bounds: warning " + strEx::itos(minWarn) + " > size > " + strEx::itos(maxWarn)); 
     152  NSC_DEBUG_MSG_STD("Showall: " + ((bShowAll)?"yeap":"noop")); 
     153 
     154  std::list<std::pair<std::string,std::string> >::const_iterator pit; 
     155  for (pit = paths.begin(); pit != paths.end(); ++pit) { 
     156    std::string tstr; 
     157    GetSize sizeFinder; 
     158    std::string sName = (*pit).first; 
     159    if (sName.empty()) 
     160      sName = (*pit).second; 
     161    RecursiveScanDirectory((*pit).second, sizeFinder); 
     162 
     163    if ((maxCrit!=0) && (sizeFinder.getSize() > maxCrit)) { 
     164      tstr = sName + ": " + strEx::itos_as_BKMG(sizeFinder.getSize()); 
     165      returnCode = NSCAPI::returnCRIT; 
     166    } else if (sizeFinder.getSize() < minCrit) { 
     167      tstr = sName + ": " + strEx::itos_as_BKMG(sizeFinder.getSize()); 
     168      NSCHelper::escalteReturnCodeToCRIT(returnCode); 
     169    } else if ((maxWarn!=0)&&(sizeFinder.getSize() > maxWarn)) { 
     170      tstr = sName +  ": " + strEx::itos_as_BKMG(sizeFinder.getSize()); 
     171      NSCHelper::escalteReturnCodeToWARN(returnCode); 
     172    } else if (sizeFinder.getSize() < minWarn) { 
     173      tstr = sName +  ": " + strEx::itos_as_BKMG(sizeFinder.getSize()); 
     174      NSCHelper::escalteReturnCodeToWARN(returnCode); 
     175    } else if (bShowAll) { 
     176      tstr = sName +  ": " + strEx::itos_as_BKMG(sizeFinder.getSize()); 
     177    } 
     178    if (!(*pit).first.empty()) 
     179      perfData += (*pit).first + "=" + strEx::itos(sizeFinder.getSize()) + ";" + strEx::itos(maxWarn) + ";" + strEx::itos(maxCrit) + " "; 
     180    if (!ret.empty() && !tstr.empty()) 
     181      ret += ", "; 
     182    if (!tstr.empty()) 
     183      ret += tstr; 
     184  } 
     185  if (ret.empty()) 
     186    ret = "OK all file sizes are within bounds."; 
     187  if (!perfData.empty()) 
     188    ret += "|" + perfData; 
     189  return NSCHelper::returnNSCP(returnCode, ret); 
     190} 
     191 
     192 
    95193#define BUFFER_SIZE 1024*64 
    96194 
    97195std::string CheckDisk::handleCommand(const std::string command, const unsigned int argLen, char **char_args) { 
    98   std::string ret; 
    99   if (command == "CheckDirectorySize") { 
    100     std::list<std::string> args = NSCHelper::makelist(argLen, char_args); 
    101     if (args.size() < 3) 
    102       return "Missing argument(s)." + strEx::itos((int)args.size()); 
    103     int iWarn = strEx::stoi64_as_BKMG(args.front()); args.pop_front(); 
    104     int iMax = strEx::stoi64_as_BKMG(args.front()); args.pop_front(); 
    105  
    106     std::list<std::string>::const_iterator cit; 
    107     for (cit=args.begin();cit!=args.end();++cit) { 
    108       GetSize size; 
    109       RecursiveScanDirectory(*cit, size); 
    110       if (!ret.empty()) 
    111         ret += ", "; 
    112       ret += (*cit) + ": " + strEx::itos_as_BKMG(size.getSize()); 
    113     } 
    114   } 
    115   return ret; 
     196  if (command == "CheckFileSize") { 
     197    return CheckFileSize(argLen, char_args); 
     198//  } else if (command == "CheckFileDate") { 
     199  }  
     200  return ""; 
    116201} 
    117202 
  • modules/CheckDisk/CheckDisk.def

    ra1e1922 r36c340d  
    1 LIBRARY NSClientCompat 
     1LIBRARY CheckDisk 
    22 
    33EXPORTS 
  • modules/CheckDisk/CheckDisk.h

    ra1e1922 r36c340d  
    1515  bool hasMessageHandler(); 
    1616  std::string handleCommand(const std::string command, const unsigned int argLen, char **args); 
     17 
     18  // Check commands 
     19  std::string CheckFileSize(const unsigned int argLen, char **char_args); 
    1720}; 
  • modules/CheckDisk/CheckDisk.vcproj

    ra1e1922 r36c340d  
    2020        Name="VCCLCompilerTool" 
    2121        Optimization="0" 
    22         PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CHECKDISK_EXPORTS" 
     22        AdditionalIncludeDirectories="../include;../../include" 
     23        PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_STATIC_LIB;_STLP_USE_NEWALLOC" 
    2324        MinimalRebuild="TRUE" 
    2425        BasicRuntimeChecks="3" 
     
    3233      <Tool 
    3334        Name="VCLinkerTool" 
    34         OutputFile="$(OutDir)/CheckDisk.dll" 
     35        OutputFile="../../Debug/modules/$(ProjectName).dll" 
    3536        LinkIncremental="2" 
     37        ModuleDefinitionFile="CheckDisk.def" 
    3638        GenerateDebugInformation="TRUE" 
    3739        ProgramDatabaseFile="$(OutDir)/CheckDisk.pdb" 
     
    8688        OptimizeReferences="2" 
    8789        EnableCOMDATFolding="2" 
     90        ImportLibrary="$(OutDir)/CheckDisk.lib" 
     91        TargetMachine="1"/> 
     92      <Tool 
     93        Name="VCMIDLTool"/> 
     94      <Tool 
     95        Name="VCPostBuildEventTool"/> 
     96      <Tool 
     97        Name="VCPreBuildEventTool"/> 
     98      <Tool 
     99        Name="VCPreLinkEventTool"/> 
     100      <Tool 
     101        Name="VCResourceCompilerTool"/> 
     102      <Tool 
     103        Name="VCWebServiceProxyGeneratorTool"/> 
     104      <Tool 
     105        Name="VCXMLDataGeneratorTool"/> 
     106      <Tool 
     107        Name="VCWebDeploymentTool"/> 
     108      <Tool 
     109        Name="VCManagedWrapperGeneratorTool"/> 
     110      <Tool 
     111        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     112    </Configuration> 
     113    <Configuration 
     114      Name="Dynamic Linkage|Win32" 
     115      OutputDirectory="$(ConfigurationName)" 
     116      IntermediateDirectory="$(ConfigurationName)" 
     117      ConfigurationType="2" 
     118      CharacterSet="2"> 
     119      <Tool 
     120        Name="VCCLCompilerTool" 
     121        AdditionalIncludeDirectories="../include;../../include" 
     122        PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" 
     123        RuntimeLibrary="2" 
     124        UsePrecompiledHeader="3" 
     125        WarningLevel="3" 
     126        Detect64BitPortabilityProblems="TRUE" 
     127        DebugInformationFormat="3"/> 
     128      <Tool 
     129        Name="VCCustomBuildTool"/> 
     130      <Tool 
     131        Name="VCLinkerTool" 
     132        OutputFile="../../Release/modules/$(ProjectName).dll" 
     133        LinkIncremental="1" 
     134        ModuleDefinitionFile="CheckDisk.def" 
     135        GenerateDebugInformation="TRUE" 
     136        SubSystem="2" 
     137        OptimizeReferences="2" 
     138        EnableCOMDATFolding="2" 
     139        ImportLibrary="$(OutDir)/CheckDisk.lib" 
     140        TargetMachine="1"/> 
     141      <Tool 
     142        Name="VCMIDLTool"/> 
     143      <Tool 
     144        Name="VCPostBuildEventTool"/> 
     145      <Tool 
     146        Name="VCPreBuildEventTool"/> 
     147      <Tool 
     148        Name="VCPreLinkEventTool"/> 
     149      <Tool 
     150        Name="VCResourceCompilerTool"/> 
     151      <Tool 
     152        Name="VCWebServiceProxyGeneratorTool"/> 
     153      <Tool 
     154        Name="VCXMLDataGeneratorTool"/> 
     155      <Tool 
     156        Name="VCWebDeploymentTool"/> 
     157      <Tool 
     158        Name="VCManagedWrapperGeneratorTool"/> 
     159      <Tool 
     160        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     161    </Configuration> 
     162    <Configuration 
     163      Name="Debug Dynamic Linkage|Win32" 
     164      OutputDirectory="$(ConfigurationName)" 
     165      IntermediateDirectory="$(ConfigurationName)" 
     166      ConfigurationType="2" 
     167      CharacterSet="2"> 
     168      <Tool 
     169        Name="VCCLCompilerTool" 
     170        Optimization="0" 
     171        AdditionalIncludeDirectories="../include;../../include" 
     172        PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 
     173        MinimalRebuild="TRUE" 
     174        BasicRuntimeChecks="3" 
     175        RuntimeLibrary="3" 
     176        UsePrecompiledHeader="3" 
     177        WarningLevel="3" 
     178        Detect64BitPortabilityProblems="TRUE" 
     179        DebugInformationFormat="4"/> 
     180      <Tool 
     181        Name="VCCustomBuildTool"/> 
     182      <Tool 
     183        Name="VCLinkerTool" 
     184        OutputFile="../../Debug/modules/$(ProjectName).dll" 
     185        LinkIncremental="2" 
     186        ModuleDefinitionFile="CheckDisk.def" 
     187        GenerateDebugInformation="TRUE" 
     188        ProgramDatabaseFile="$(OutDir)/CheckDisk.pdb" 
     189        SubSystem="2" 
    88190        ImportLibrary="$(OutDir)/CheckDisk.lib" 
    89191        TargetMachine="1"/> 
     
    133235        <FileConfiguration 
    134236          Name="Release|Win32"> 
     237          <Tool 
     238            Name="VCCLCompilerTool" 
     239            UsePrecompiledHeader="1"/> 
     240        </FileConfiguration> 
     241        <FileConfiguration 
     242          Name="Dynamic Linkage|Win32"> 
     243          <Tool 
     244            Name="VCCLCompilerTool" 
     245            UsePrecompiledHeader="1"/> 
     246        </FileConfiguration> 
     247        <FileConfiguration 
     248          Name="Debug Dynamic Linkage|Win32"> 
    135249          <Tool 
    136250            Name="VCCLCompilerTool" 
  • modules/CheckEventLog/CheckEventLog.cpp

    ra0528c4 r36c340d  
    2929 
    3030std::string CheckEventLog::getModuleName() { 
    31   return "NSClient compatibility Module."; 
     31  return "Event log Checker."; 
    3232} 
    3333NSCModuleWrapper::module_version CheckEventLog::getModuleVersion() { 
     
    104104      DWORD eventType_; 
    105105      std::string eventSource_; 
     106      boost::regex eventSourceRegExp_; 
    106107      bool notSetValue_; 
    107108      DWORD writtenBeforeDelta_ ; 
     
    109110      DWORD generatedBeforeDelta_; 
    110111      DWORD generatedAfterDelta_; 
     112      boost::regex regexp_; 
    111113 
    112114      searchQueryItem(bool notSetValue)  
     
    115117        generatedBeforeDelta_(0), generatedAfterDelta_(0)  
    116118      {} 
     119      searchQueryItem& operator=(const searchQueryItem &other) { 
     120        eventType_ = other.eventType_; 
     121        eventSource_ = other.eventSource_; 
     122        notSetValue_ = other.notSetValue_; 
     123        writtenBeforeDelta_ = other.writtenBeforeDelta_; 
     124        writtenAfterDelta_ = other.writtenAfterDelta_; 
     125        generatedBeforeDelta_ = other.generatedBeforeDelta_; 
     126        generatedAfterDelta_ = other.generatedAfterDelta_; 
     127        try { 
     128          regexp_ = other.regexp_; 
     129        } catch (const boost::bad_expression e) { 
     130          throw (std::string)"Invalid syntax in regular expression:" + other.toString(); 
     131        } 
     132        try { 
     133          eventSourceRegExp_ = other.eventSourceRegExp_; 
     134        } catch (const boost::bad_expression e) { 
     135          throw (std::string)"Invalid syntax in event source regular expression:" + other.toString(); 
     136        } 
     137        return *this; 
     138      } 
    117139 
    118140      inline bool matchDateWritten(DWORD now, DWORD written) const { 
     
    150172      } 
    151173      inline bool matchSource(std::string eventSource) const { 
    152         if (eventSource_.empty()) 
     174        if ((eventSource_.empty())&&eventSourceRegExp_.empty()) 
    153175          return notSetValue_; 
    154         return eventSource_ == eventSource; 
     176        else if (eventSource_.empty()) 
     177          return boost::regex_match(eventSource, eventSourceRegExp_); 
     178        else if (eventSourceRegExp_.empty()) 
     179          return eventSource_ == eventSource; 
     180        return boost::regex_match(eventSource, eventSourceRegExp_) && (eventSource_ == eventSource); 
     181      } 
     182      inline bool matchRegexp(std::string msg) const { 
     183        if (regexp_.empty()) 
     184          return notSetValue_; 
     185        return boost::regex_match(msg, regexp_); 
    155186      } 
    156187      std::string toString() const { 
    157188        std::stringstream ss; 
     189        ss << "    Regexp: " << regexp_ << std::endl; 
    158190        ss << "    Event type: " << eventType_ << std::endl; 
    159191        ss << "    Event source: " << eventSource_ << std::endl; 
     192        ss << "    Event source Regexp: " << eventSourceRegExp_ << std::endl; 
    160193        ss << "    Written delta: " << writtenAfterDelta_ << " > " << writtenBeforeDelta_ << std::endl; 
    161194        ss << "    Generated delta: " << generatedAfterDelta_ << " > " << generatedBeforeDelta_ << std::endl; 
     
    167200    searchQueryBundle() : require(true), exclude(false) {} 
    168201    std::string toString() { 
    169       return "  Required:\n" + require.toString()  + "\n  Exlude:\n" + exclude.toString(); 
     202      return "  Required:\n" + require.toString()  + "\n  Exclude:\n" + exclude.toString(); 
    170203    } 
    171204  }; 
     
    189222  else if (p.first == "eventSource") 
    190223    item.eventSource_ = p.second; 
     224  else if (p.first == "eventSourceRegexp") { 
     225    try { 
     226      std::string s = p.second; 
     227      NSC_DEBUG_MSG_STD("Attempting to make regexp from: " + s); 
     228      item.eventSourceRegExp_ = s; 
     229      NSC_DEBUG_MSG_STD("success..."); 
     230    } catch (const boost::bad_expression e) { 
     231      item.eventSourceRegExp_ = ""; 
     232      throw (std::string)"Invalid syntax in regular expression:" + p.second; 
     233    } 
     234  } 
     235  else if (p.first == "generatedBeforeDelta") 
     236    item.generatedBeforeDelta_ = strEx::stoi(p.second); 
     237  else if (p.first == "generatedAfterDelta") 
     238    item.generatedAfterDelta_ = strEx::stoi(p.second); 
     239  else if (p.first == "writtenBeforeDelta") 
     240    item.writtenBeforeDelta_ = strEx::stoi(p.second); 
     241  else if (p.first == "writtenAfterDelta") 
     242    item.writtenAfterDelta_ = strEx::stoi(p.second); 
     243  else if (p.first == "regexp") { 
     244    try { 
     245      item.regexp_ = p.second; 
     246    } catch (const boost::bad_expression e) { 
     247      item.regexp_ = ""; 
     248      throw (std::string)"Invalid syntax in regular expression:" + p.second; 
     249    } 
     250  } else 
     251    throw (std::string)"Invalid argument: " + p.first; 
    191252} 
    192253void addToQueryBundle(searchQuery::searchQueryBundle &bundle, std::string arg) { 
     
    196257  else if (p.first == "exclude") 
    197258    addToQueryItem(bundle.exclude, p.second); 
     259  else 
     260    throw (std::string)"Invalid require/exclude: " + p.first; 
    198261} 
    199262void addToQuery(searchQuery &q, std::string arg) { 
     
    212275    else if (p.first == "descriptions") 
    213276      q.descriptions = true; 
    214   } 
    215 } 
    216  
    217 searchQuery buildQury(std::list<std::string> args) { 
    218   searchQuery ret; 
     277    else 
     278      throw (std::string)"Invalid argument: " + arg; 
     279  } 
     280} 
     281 
     282void buildQury(searchQuery &query, std::list<std::string> args) { 
    219283  for (std::list<std::string>::const_iterator it = args.begin(); it!=args.end(); it++) { 
    220     addToQuery(ret, *it); 
    221   } 
    222   return ret; 
    223 } 
    224 // huffa&CheckEventLog&Application&1&<type>&<query>&huffa... 
     284    NSC_DEBUG_MSG_STD("Adding: " + *it); 
     285    addToQuery(query, *it); 
     286  } 
     287} 
     288// CheckEventLog 
    225289// request: CheckEventLog&<logfile>&<Query strings> 
    226290// Return: <return state>&<log entry 1> - <log entry 2>... 
     
    228292//          1 - Unknown 
    229293//          2 - Errors 
     294// Examples: 
     295// CheckEventLog&Application&1&<type>&<query>&huffa... 
     296// CheckEventLog&Application&warn.require.eventType=warning&critical.require.eventType=error&truncate=1024&descriptions&all.exclude.eventSourceRegexp=^(Win|Msi|NSClient\+\+|Userenv|ASP\.NET|LoadPerf|Outlook|Application E|NSClient).* 
    230297#define BUFFER_SIZE 1024*64 
    231298 
     
    233300  if (command != "CheckEventLog") 
    234301    return ""; 
     302  NSCAPI::returnCodes rCode = NSCAPI::returnOK; 
    235303  std::list<std::string> args = NSCHelper::makelist(argLen, char_args); 
    236304  if (args.size() < 2) 
     
    238306  std::string ret; 
    239307  bool critical = false; 
     308  searchQuery query; 
    240309  std::string logFile = args.front(); args.pop_front(); 
    241   searchQuery query = buildQury(args); 
     310  try { 
     311    buildQury(query, args); 
     312  } catch (std::string s) { 
     313    return NSCHelper::returnNSCP(NSCAPI::returnUNKNOWN, s); 
     314  } 
    242315  NSC_DEBUG_MSG_STD("Base query: " + query.toString()); 
    243316 
    244317  HANDLE hLog = OpenEventLog(NULL, logFile.c_str()); 
    245318  if (hLog == NULL)  
    246     return "Could not open the Application event log."; 
     319    return NSCHelper::returnNSCP(NSCAPI::returnUNKNOWN, "Could not open the Application event log."); 
    247320 
    248321  DWORD dwThisRecord, dwRead, dwNeeded; 
     
    271344        query.critical.require.matchSource(record.eventSource()) && 
    272345        query.critical.require.matchDateGenerated(currentTime, record.timeGenerated()) && 
    273         query.critical.require.matchDateWritten(currentTime, record.timeWritten()) 
     346        query.critical.require.matchDateWritten(currentTime, record.timeWritten()) && 
     347        query.critical.require.matchRegexp(record.enumStrings()) 
    274348        ) { 
    275349          match = true; 
     
    278352      if ( query.critical.exclude.matchType(record.eventType()) || 
    279353        query.critical.exclude.matchSource(record.eventSource()) || 
    280         query.critical.require.matchDateGenerated(currentTime, record.timeGenerated()) || 
    281         query.critical.require.matchDateWritten(currentTime, record.timeWritten()) 
     354        query.critical.exclude.matchDateGenerated(currentTime, record.timeGenerated()) || 
     355        query.critical.exclude.matchDateWritten(currentTime, record.timeWritten()) || 
     356        query.critical.exclude.matchRegexp(record.enumStrings()) 
    282357        ) { 
    283358          match = false; 
     
    287362      if ( query.warn.require.matchType(record.eventType()) && 
    288363        query.warn.require.matchSource(record.eventSource()) && 
    289         query.critical.require.matchDateGenerated(currentTime, record.timeGenerated()) && 
    290         query.critical.require.matchDateWritten(currentTime, record.timeWritten()) 
     364        query.warn.require.matchDateGenerated(currentTime, record.timeGenerated()) && 
     365        query.warn.require.matchDateWritten(currentTime, record.timeWritten()) && 
     366        query.warn.require.matchRegexp(record.enumStrings()) 
    291367        ) 
    292368        match = true; 
    293369      if ( query.warn.exclude.matchType(record.eventType()) || 
    294370        query.warn.exclude.matchSource(record.eventSource()) || 
    295         query.critical.require.matchDateGenerated(currentTime, record.timeGenerated()) || 
    296         query.critical.require.matchDateWritten(currentTime, record.timeWritten()) 
     371        query.warn.exclude.matchDateGenerated(currentTime, record.timeGenerated()) || 
     372        query.warn.exclude.matchDateWritten(currentTime, record.timeWritten()) || 
     373        query.warn.exclude.matchRegexp(record.enumStrings()) 
    297374        ) 
    298375        match = false; 
     
    324401    ret = "WARNING: " + ret; 
    325402  else  
    326     ret = "OK: No errors/warnings in eventlog."; 
     403    ret = "OK: No errors/warnings in event log."; 
    327404  if (query.truncate != 0) 
    328405    ret = ret.substr(0, query.truncate); 
    329   return ret; 
     406  return NSCHelper::returnNSCP(rCode, ret); 
    330407} 
    331408 
  • modules/CheckEventLog/CheckEventLog.def

    ra0528c4 r36c340d  
    1 LIBRARY ConsoleLogger 
     1LIBRARY CheckEventLog 
    22 
    33EXPORTS 
  • modules/CheckEventLog/CheckEventLog.vcproj

    ra0528c4 r36c340d  
    2121        Optimization="0" 
    2222        AdditionalIncludeDirectories="../include;../../include" 
    23         PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_STATIC_LIB;_STLP_USE_NEWALLOC" 
     23        PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_STATIC_LIB;_STLP_USE_NEWALLOC,_STLP_DEBUG" 
    2424        MinimalRebuild="TRUE" 
    2525        BasicRuntimeChecks="3" 
     
    9696      <Tool 
    9797        Name="VCPreBuildEventTool"/> 
     98      <Tool 
     99        Name="VCPreLinkEventTool"/> 
     100      <Tool 
     101        Name="VCResourceCompilerTool"/> 
     102      <Tool 
     103        Name="VCWebServiceProxyGeneratorTool"/> 
     104      <Tool 
     105        Name="VCXMLDataGeneratorTool"/> 
     106      <Tool 
     107        Name="VCWebDeploymentTool"/> 
     108      <Tool 
     109        Name="VCManagedWrapperGeneratorTool"/> 
     110      <Tool 
     111        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     112    </Configuration> 
     113    <Configuration 
     114      Name="Dynamic Linkage|Win32" 
     115      OutputDirectory="$(ConfigurationName)" 
     116      IntermediateDirectory="$(ConfigurationName)" 
     117      ConfigurationType="2" 
     118      CharacterSet="2"> 
     119      <Tool 
     120        Name="VCCLCompilerTool" 
     121        AdditionalIncludeDirectories="../include;../../include" 
     122        PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_STLP_USE_STATIC_LIB;SYSTRAY_EXPORTS" 
     123        RuntimeLibrary="0" 
     124        UsePrecompiledHeader="3" 
     125        WarningLevel="3" 
     126        Detect64BitPortabilityProblems="TRUE" 
     127        DebugInformationFormat="3"/> 
     128      <Tool 
     129        Name="VCCustomBuildTool"/> 
     130      <Tool 
     131        Name="VCLinkerTool" 
     132        OutputFile="../../Release/modules/$(ProjectName).dll" 
     133        LinkIncremental="1" 
     134        ModuleDefinitionFile="CheckEventLog.def" 
     135        GenerateDebugInformation="TRUE" 
     136        SubSystem="2" 
     137        OptimizeReferences="2" 
     138        EnableCOMDATFolding="2" 
     139        ImportLibrary="$(OutDir)/CheckEventLog.lib" 
     140        TargetMachine="1"/> 
     141      <Tool 
     142        Name="VCMIDLTool"/> 
     143      <Tool 
     144        Name="VCPostBuildEventTool"/> 
     145      <Tool 
     146        Name="VCPreBuildEventTool" 
     147        ExcludedFromBuild="TRUE"/> 
     148      <Tool 
     149        Name="VCPreLinkEventTool"/> 
     150      <Tool 
     151        Name="VCResourceCompilerTool"/> 
     152      <Tool 
     153        Name="VCWebServiceProxyGeneratorTool"/> 
     154      <Tool 
     155        Name="VCXMLDataGeneratorTool"/> 
     156      <Tool 
     157        Name="VCWebDeploymentTool"/> 
     158      <Tool 
     159        Name="VCManagedWrapperGeneratorTool"/> 
     160      <Tool 
     161        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     162    </Configuration> 
     163    <Configuration 
     164      Name="Debug Dynamic Linkage|Win32" 
     165      OutputDirectory="$(ConfigurationName)" 
     166      IntermediateDirectory="$(ConfigurationName)" 
     167      ConfigurationType="2" 
     168      CharacterSet="2"> 
     169      <Tool 
     170        Name="VCCLCompilerTool" 
     171        Optimization="0" 
     172        AdditionalIncludeDirectories="../include;../../include" 
     173        PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 
     174        MinimalRebuild="TRUE" 
     175        BasicRuntimeChecks="3" 
     176        RuntimeLibrary="3" 
     177        UsePrecompiledHeader="3" 
     178        WarningLevel="3" 
     179        Detect64BitPortabilityProblems="TRUE" 
     180        DebugInformationFormat="4"/> 
     181      <Tool 
     182        Name="VCCustomBuildTool"/> 
     183      <Tool 
     184        Name="VCLinkerTool" 
     185        OutputFile="../../Debug/modules/$(ProjectName).dll" 
     186        LinkIncremental="2" 
     187        ModuleDefinitionFile="CheckEventLog.def" 
     188        GenerateDebugInformation="TRUE" 
     189        ProgramDatabaseFile="$(OutDir)/CheckEventLog.pdb" 
     190        SubSystem="2" 
     191        ImportLibrary="$(OutDir)/CheckEventLog.lib" 
     192        TargetMachine="1"/> 
     193      <Tool 
     194        Name="VCMIDLTool"/> 
     195      <Tool 
     196        Name="VCPostBuildEventTool"/> 
     197      <Tool 
     198        Name="VCPreBuildEventTool" 
     199        ExcludedFromBuild="TRUE"/> 
    98200      <Tool 
    99201        Name="VCPreLinkEventTool"/> 
     
    135237        <FileConfiguration 
    136238          Name="Release|Win32"> 
     239          <Tool 
     240            Name="VCCLCompilerTool" 
     241            UsePrecompiledHeader="1"/> 
     242        </FileConfiguration> 
     243        <FileConfiguration 
     244          Name="Dynamic Linkage|Win32"> 
     245          <Tool 
     246            Name="VCCLCompilerTool" 
     247            UsePrecompiledHeader="1"/> 
     248        </FileConfiguration> 
     249        <FileConfiguration 
     250          Name="Debug Dynamic Linkage|Win32"> 
    137251          <Tool 
    138252            Name="VCCLCompilerTool" 
  • modules/CheckEventLog/stdafx.h

    ra1e1922 r36c340d  
    1010// Windows Header Files: 
    1111#include <windows.h> 
    12  
     12#include <boost/regex.hpp>  
    1313#include <string> 
    14  
    1514 
    1615#include <NSCAPI.h> 
  • modules/ConsoleLogger/ConsoleLogger.vcproj

    ra0528c4 r36c340d  
    111111        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
    112112    </Configuration> 
     113    <Configuration 
     114      Name="Dynamic Linkage|Win32" 
     115      OutputDirectory="$(ConfigurationName)" 
     116      IntermediateDirectory="$(ConfigurationName)" 
     117      ConfigurationType="2" 
     118      CharacterSet="2"> 
     119      <Tool 
     120        Name="VCCLCompilerTool" 
     121        AdditionalIncludeDirectories="../include;../../include" 
     122        PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" 
     123        RuntimeLibrary="2" 
     124        UsePrecompiledHeader="3" 
     125        WarningLevel="3" 
     126        Detect64BitPortabilityProblems="TRUE" 
     127        DebugInformationFormat="3"/> 
     128      <Tool 
     129        Name="VCCustomBuildTool"/> 
     130      <Tool 
     131        Name="VCLinkerTool" 
     132        OutputFile="../../Release/modules/$(ProjectName).dll" 
     133        LinkIncremental="1" 
     134        ModuleDefinitionFile="ConsoleLogger.def" 
     135        GenerateDebugInformation="TRUE" 
     136        SubSystem="2" 
     137        OptimizeReferences="2" 
     138        EnableCOMDATFolding="2" 
     139        ImportLibrary="$(OutDir)/ConsoleLogger.lib" 
     140        TargetMachine="1"/> 
     141      <Tool 
     142        Name="VCMIDLTool"/> 
     143      <Tool 
     144        Name="VCPostBuildEventTool"/> 
     145      <Tool 
     146        Name="VCPreBuildEventTool"/> 
     147      <Tool 
     148        Name="VCPreLinkEventTool"/> 
     149      <Tool 
     150        Name="VCResourceCompilerTool"/> 
     151      <Tool 
     152        Name="VCWebServiceProxyGeneratorTool"/> 
     153      <Tool 
     154        Name="VCXMLDataGeneratorTool"/> 
     155      <Tool 
     156        Name="VCWebDeploymentTool"/> 
     157      <Tool 
     158        Name="VCManagedWrapperGeneratorTool"/> 
     159      <Tool 
     160        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     161    </Configuration> 
     162    <Configuration 
     163      Name="Debug Dynamic Linkage|Win32" 
     164      OutputDirectory="$(ConfigurationName)" 
     165      IntermediateDirectory="$(ConfigurationName)" 
     166      ConfigurationType="2" 
     167      CharacterSet="2"> 
     168      <Tool 
     169        Name="VCCLCompilerTool" 
     170        Optimization="0" 
     171        AdditionalIncludeDirectories="../include;../../include" 
     172        PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 
     173        MinimalRebuild="TRUE" 
     174        BasicRuntimeChecks="3" 
     175        RuntimeLibrary="3" 
     176        UsePrecompiledHeader="3" 
     177        WarningLevel="3" 
     178        Detect64BitPortabilityProblems="TRUE" 
     179        DebugInformationFormat="4"/> 
     180      <Tool 
     181        Name="VCCustomBuildTool"/> 
     182      <Tool 
     183        Name="VCLinkerTool" 
     184        OutputFile="../../Debug/modules/$(ProjectName).dll" 
     185        LinkIncremental="2" 
     186        ModuleDefinitionFile="ConsoleLogger.def" 
     187        GenerateDebugInformation="TRUE" 
     188        ProgramDatabaseFile="$(OutDir)/ConsoleLogger.pdb" 
     189        SubSystem="2" 
     190        ImportLibrary="$(OutDir)/ConsoleLogger.lib" 
     191        TargetMachine="1"/> 
     192      <Tool 
     193        Name="VCMIDLTool"/> 
     194      <Tool 
     195        Name="VCPostBuildEventTool"/> 
     196      <Tool 
     197        Name="VCPreBuildEventTool"/> 
     198      <Tool 
     199        Name="VCPreLinkEventTool"/> 
     200      <Tool 
     201        Name="VCResourceCompilerTool"/> 
     202      <Tool 
     203        Name="VCWebServiceProxyGeneratorTool"/> 
     204      <Tool 
     205        Name="VCXMLDataGeneratorTool"/> 
     206      <Tool 
     207        Name="VCWebDeploymentTool"/> 
     208      <Tool 
     209        Name="VCManagedWrapperGeneratorTool"/> 
     210      <Tool 
     211        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     212    </Configuration> 
    113213  </Configurations> 
    114214  <References> 
     
    135235        <FileConfiguration 
    136236          Name="Release|Win32"> 
     237          <Tool 
     238            Name="VCCLCompilerTool" 
     239            UsePrecompiledHeader="1"/> 
     240        </FileConfiguration> 
     241        <FileConfiguration 
     242          Name="Dynamic Linkage|Win32"> 
     243          <Tool 
     244            Name="VCCLCompilerTool" 
     245            UsePrecompiledHeader="1"/> 
     246        </FileConfiguration> 
     247        <FileConfiguration 
     248          Name="Debug Dynamic Linkage|Win32"> 
    137249          <Tool 
    138250            Name="VCCLCompilerTool" 
  • modules/FileLogger/FileLogger.vcproj

    ra0528c4 r36c340d  
    111111        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
    112112    </Configuration> 
     113    <Configuration 
     114      Name="Dynamic Linkage|Win32" 
     115      OutputDirectory="$(ConfigurationName)" 
     116      IntermediateDirectory="$(ConfigurationName)" 
     117      ConfigurationType="2" 
     118      CharacterSet="2"> 
     119      <Tool 
     120        Name="VCCLCompilerTool" 
     121        AdditionalIncludeDirectories="../include;../../include" 
     122        PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" 
     123        RuntimeLibrary="2" 
     124        UsePrecompiledHeader="3" 
     125        WarningLevel="3" 
     126        Detect64BitPortabilityProblems="TRUE" 
     127        DebugInformationFormat="3"/> 
     128      <Tool 
     129        Name="VCCustomBuildTool"/> 
     130      <Tool 
     131        Name="VCLinkerTool" 
     132        OutputFile="../../Release/modules/$(ProjectName).dll" 
     133        LinkIncremental="1" 
     134        ModuleDefinitionFile="FileLogger.def" 
     135        GenerateDebugInformation="TRUE" 
     136        SubSystem="2" 
     137        OptimizeReferences="2" 
     138        EnableCOMDATFolding="2" 
     139        ImportLibrary="$(OutDir)/FileLogger.lib" 
     140        TargetMachine="1"/> 
     141      <Tool 
     142        Name="VCMIDLTool"/> 
     143      <Tool 
     144        Name="VCPostBuildEventTool"/> 
     145      <Tool 
     146        Name="VCPreBuildEventTool"/> 
     147      <Tool 
     148        Name="VCPreLinkEventTool"/> 
     149      <Tool 
     150        Name="VCResourceCompilerTool"/> 
     151      <Tool 
     152        Name="VCWebServiceProxyGeneratorTool"/> 
     153      <Tool 
     154        Name="VCXMLDataGeneratorTool"/> 
     155      <Tool 
     156        Name="VCWebDeploymentTool"/> 
     157      <Tool 
     158        Name="VCManagedWrapperGeneratorTool"/> 
     159      <Tool 
     160        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     161    </Configuration> 
     162    <Configuration 
     163      Name="Debug Dynamic Linkage|Win32" 
     164      OutputDirectory="$(ConfigurationName)" 
     165      IntermediateDirectory="$(ConfigurationName)" 
     166      ConfigurationType="2" 
     167      CharacterSet="2"> 
     168      <Tool 
     169        Name="VCCLCompilerTool" 
     170        Optimization="0" 
     171        AdditionalIncludeDirectories="../include;../../include" 
     172        PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 
     173        MinimalRebuild="TRUE" 
     174        BasicRuntimeChecks="3" 
     175        RuntimeLibrary="3" 
     176        UsePrecompiledHeader="3" 
     177        WarningLevel="3" 
     178        Detect64BitPortabilityProblems="TRUE" 
     179        DebugInformationFormat="4"/> 
     180      <Tool 
     181        Name="VCCustomBuildTool"/> 
     182      <Tool 
     183        Name="VCLinkerTool" 
     184        OutputFile="../../Debug/modules/$(ProjectName).dll" 
     185        LinkIncremental="2" 
     186        ModuleDefinitionFile="FileLogger.def" 
     187        GenerateDebugInformation="TRUE" 
     188        ProgramDatabaseFile="$(OutDir)/FileLogger.pdb" 
     189        SubSystem="2" 
     190        ImportLibrary="$(OutDir)/FileLogger.lib" 
     191        TargetMachine="1"/> 
     192      <Tool 
     193        Name="VCMIDLTool"/> 
     194      <Tool 
     195        Name="VCPostBuildEventTool"/> 
     196      <Tool 
     197        Name="VCPreBuildEventTool"/> 
     198      <Tool 
     199        Name="VCPreLinkEventTool"/> 
     200      <Tool 
     201        Name="VCResourceCompilerTool"/> 
     202      <Tool 
     203        Name="VCWebServiceProxyGeneratorTool"/> 
     204      <Tool 
     205        Name="VCXMLDataGeneratorTool"/> 
     206      <Tool 
     207        Name="VCWebDeploymentTool"/> 
     208      <Tool 
     209        Name="VCManagedWrapperGeneratorTool"/> 
     210      <Tool 
     211        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     212    </Configuration> 
    113213  </Configurations> 
    114214  <References> 
     
    135235        <FileConfiguration 
    136236          Name="Release|Win32"> 
     237          <Tool 
     238            Name="VCCLCompilerTool" 
     239            UsePrecompiledHeader="1"/> 
     240        </FileConfiguration> 
     241        <FileConfiguration 
     242          Name="Dynamic Linkage|Win32"> 
     243          <Tool 
     244            Name="VCCLCompilerTool" 
     245            UsePrecompiledHeader="1"/> 
     246        </FileConfiguration> 
     247        <FileConfiguration 
     248          Name="Debug Dynamic Linkage|Win32"> 
    137249          <Tool 
    138250            Name="VCCLCompilerTool" 
  • modules/NSClientCompat/NSClientCompat.cpp

    r3baaa4d r36c340d  
    4747 */ 
    4848bool NSClientCompat::unloadModule() { 
    49   if (!pdhThread.exitThread()) 
     49  if (!pdhThread.exitThread(20000)) 
    5050    NSC_LOG_ERROR("Could not exit the thread, memory leak and potential corruption may be the result..."); 
    5151  return true; 
  • modules/NSClientCompat/NSClientCompat.vcproj

    ra1e1922 r36c340d  
    113113        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
    114114    </Configuration> 
     115    <Configuration 
     116      Name="Dynamic Linkage|Win32" 
     117      OutputDirectory="$(ConfigurationName)" 
     118      IntermediateDirectory="$(ConfigurationName)" 
     119      ConfigurationType="2" 
     120      CharacterSet="2"> 
     121      <Tool 
     122        Name="VCCLCompilerTool" 
     123        AdditionalIncludeDirectories="../include;../../include" 
     124        PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" 
     125        RuntimeLibrary="2" 
     126        UsePrecompiledHeader="3" 
     127        WarningLevel="3" 
     128        Detect64BitPortabilityProblems="TRUE" 
     129        DebugInformationFormat="3"/> 
     130      <Tool 
     131        Name="VCCustomBuildTool"/> 
     132      <Tool 
     133        Name="VCLinkerTool" 
     134        AdditionalDependencies="Pdh.lib" 
     135        OutputFile="../../Release/modules/$(ProjectName).dll" 
     136        LinkIncremental="1" 
     137        ModuleDefinitionFile="NSClientCompat.def" 
     138        GenerateDebugInformation="TRUE" 
     139        SubSystem="2" 
     140        OptimizeReferences="2" 
     141        EnableCOMDATFolding="2" 
     142        ImportLibrary="$(OutDir)/NSClientCompat.lib" 
     143        TargetMachine="1"/> 
     144      <Tool 
     145        Name="VCMIDLTool"/> 
     146      <Tool 
     147        Name="VCPostBuildEventTool"/> 
     148      <Tool 
     149        Name="VCPreBuildEventTool"/> 
     150      <Tool 
     151        Name="VCPreLinkEventTool"/> 
     152      <Tool 
     153        Name="VCResourceCompilerTool"/> 
     154      <Tool 
     155        Name="VCWebServiceProxyGeneratorTool"/> 
     156      <Tool 
     157        Name="VCXMLDataGeneratorTool"/> 
     158      <Tool 
     159        Name="VCWebDeploymentTool"/> 
     160      <Tool 
     161        Name="VCManagedWrapperGeneratorTool"/> 
     162      <Tool 
     163        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     164    </Configuration> 
     165    <Configuration 
     166      Name="Debug Dynamic Linkage|Win32" 
     167      OutputDirectory="$(ConfigurationName)" 
     168      IntermediateDirectory="$(ConfigurationName)" 
     169      ConfigurationType="2" 
     170      CharacterSet="2"> 
     171      <Tool 
     172        Name="VCCLCompilerTool" 
     173        Optimization="0" 
     174        AdditionalIncludeDirectories="../include;../../include" 
     175        PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 
     176        MinimalRebuild="TRUE" 
     177        BasicRuntimeChecks="3" 
     178        RuntimeLibrary="3" 
     179        UsePrecompiledHeader="3" 
     180        WarningLevel="3" 
     181        Detect64BitPortabilityProblems="TRUE" 
     182        DebugInformationFormat="4"/> 
     183      <Tool 
     184        Name="VCCustomBuildTool"/> 
     185      <Tool 
     186        Name="VCLinkerTool" 
     187        AdditionalDependencies="Pdh.lib" 
     188        OutputFile="../../Debug/modules/$(ProjectName).dll" 
     189        LinkIncremental="2" 
     190        ModuleDefinitionFile="NSClientCompat.def" 
     191        GenerateDebugInformation="TRUE" 
     192        ProgramDatabaseFile="$(OutDir)/NSClientCompat.pdb" 
     193        SubSystem="2" 
     194        ImportLibrary="$(OutDir)/NSClientCompat.lib" 
     195        TargetMachine="1"/> 
     196      <Tool 
     197        Name="VCMIDLTool"/> 
     198      <Tool 
     199        Name="VCPostBuildEventTool"/> 
     200      <Tool 
     201        Name="VCPreBuildEventTool"/> 
     202      <Tool 
     203        Name="VCPreLinkEventTool"/> 
     204      <Tool 
     205        Name="VCResourceCompilerTool"/> 
     206      <Tool 
     207        Name="VCWebServiceProxyGeneratorTool"/> 
     208      <Tool 
     209        Name="VCXMLDataGeneratorTool"/> 
     210      <Tool 
     211        Name="VCWebDeploymentTool"/> 
     212      <Tool 
     213        Name="VCManagedWrapperGeneratorTool"/> 
     214      <Tool 
     215        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     216    </Configuration> 
    115217  </Configurations> 
    116218  <References> 
     
    153255            UsePrecompiledHeader="1"/> 
    154256        </FileConfiguration> 
     257        <FileConfiguration 
     258          Name="Dynamic Linkage|Win32"> 
     259          <Tool 
     260            Name="VCCLCompilerTool" 
     261            UsePrecompiledHeader="1"/> 
     262        </FileConfiguration> 
     263        <FileConfiguration 
     264          Name="Debug Dynamic Linkage|Win32"> 
     265          <Tool 
     266            Name="VCCLCompilerTool" 
     267            UsePrecompiledHeader="1"/> 
     268        </FileConfiguration> 
    155269      </File> 
    156270    </Filter> 
  • modules/NSClientCompat/PDHCollector.cpp

    ra1e1922 r36c340d  
    8585  pdh.addCounter("\\\\.\\Processor(_total)\\% Processor Time", &cpu); 
    8686 
    87   pdh.open(); 
     87  try { 
     88    pdh.open(); 
     89  } catch (const PDH::PDHException &e) { 
     90    NSC_LOG_ERROR_STD("Failed to open performance counters: " + e.str_); 
     91    return 0; 
     92  } 
    8893 
    8994  startRunning(); 
     
    9398      if (!mutex.hasMutex())  
    9499        NSC_LOG_ERROR("Failed to get Mutex!"); 
    95       else 
    96         pdh.collect(); 
     100      else { 
     101        try { 
     102          pdh.collect(); 
     103        } catch (const PDH::PDHException &e) { 
     104          NSC_LOG_ERROR_STD("Failed to query performance counters: " + e.str_); 
     105        } 
     106      } 
    97107    } 
    98108    Sleep(CHECK_INTERVAL*1000); 
    99109  } 
    100110 
    101   pdh.close(); 
     111  try { 
     112    pdh.close(); 
     113  } catch (const PDH::PDHException &e) { 
     114    NSC_LOG_ERROR_STD("Failed to close performance counters: " + e.str_); 
     115  } 
    102116  NSC_DEBUG_MSG("PDHCollector - shutdown!"); 
    103117  return 0; 
     
    153167/** 
    154168 * 
    155  * Memory commited bytes (your guess is as good as mine to what this is :) 
     169 * Memory committed bytes (your guess is as good as mine to what this is :) 
    156170 * @return Some form of memory check 
    157171 */ 
  • modules/SysTray/SysTray.vcproj

    ra0528c4 r36c340d  
    108108        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
    109109    </Configuration> 
     110    <Configuration 
     111      Name="Dynamic Linkage|Win32" 
     112      OutputDirectory="$(ConfigurationName)" 
     113      IntermediateDirectory="$(ConfigurationName)" 
     114      ConfigurationType="2" 
     115      CharacterSet="2"> 
     116      <Tool 
     117        Name="VCCLCompilerTool" 
     118        AdditionalIncludeDirectories="../include;../../include" 
     119        PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" 
     120        RuntimeLibrary="2" 
     121        UsePrecompiledHeader="3" 
     122        WarningLevel="3" 
     123        Detect64BitPortabilityProblems="TRUE" 
     124        DebugInformationFormat="3"/> 
     125      <Tool 
     126        Name="VCCustomBuildTool"/> 
     127      <Tool 
     128        Name="VCLinkerTool" 
     129        OutputFile="../../Release/modules/$(ProjectName).dll" 
     130        LinkIncremental="1" 
     131        ModuleDefinitionFile="SysTray.def" 
     132        GenerateDebugInformation="TRUE" 
     133        SubSystem="2" 
     134        OptimizeReferences="2" 
     135        EnableCOMDATFolding="2" 
     136        ImportLibrary="$(OutDir)/SysTray.lib" 
     137        TargetMachine="1"/> 
     138      <Tool 
     139        Name="VCMIDLTool"/> 
     140      <Tool 
     141        Name="VCPostBuildEventTool"/> 
     142      <Tool 
     143        Name="VCPreBuildEventTool"/> 
     144      <Tool 
     145        Name="VCPreLinkEventTool"/> 
     146      <Tool 
     147        Name="VCResourceCompilerTool"/> 
     148      <Tool 
     149        Name="VCWebServiceProxyGeneratorTool"/> 
     150      <Tool 
     151        Name="VCXMLDataGeneratorTool"/> 
     152      <Tool 
     153        Name="VCWebDeploymentTool"/> 
     154      <Tool 
     155        Name="VCManagedWrapperGeneratorTool"/> 
     156      <Tool 
     157        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     158    </Configuration> 
     159    <Configuration 
     160      Name="Debug Dynamic Linkage|Win32" 
     161      OutputDirectory="$(ConfigurationName)" 
     162      IntermediateDirectory="$(ConfigurationName)" 
     163      ConfigurationType="2" 
     164      CharacterSet="2"> 
     165      <Tool 
     166        Name="VCCLCompilerTool" 
     167        Optimization="0" 
     168        AdditionalIncludeDirectories="../include;../../include" 
     169        PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_STLP_USE_NEWALLOC;_STLP_DEBUG=1" 
     170        MinimalRebuild="TRUE" 
     171        BasicRuntimeChecks="3" 
     172        RuntimeLibrary="3" 
     173        UsePrecompiledHeader="3" 
     174        WarningLevel="3" 
     175        Detect64BitPortabilityProblems="TRUE" 
     176        DebugInformationFormat="4"/> 
     177      <Tool 
     178        Name="VCCustomBuildTool"/> 
     179      <Tool 
     180        Name="VCLinkerTool" 
     181        OutputFile="../../Debug/modules/$(ProjectName).dll" 
     182        ModuleDefinitionFile="SysTray.def" 
     183        GenerateDebugInformation="TRUE" 
     184        ImportLibrary="$(OutDir)/SysTray.lib" 
     185        TargetMachine="1"/> 
     186      <Tool 
     187        Name="VCMIDLTool"/> 
     188      <Tool 
     189        Name="VCPostBuildEventTool"/> 
     190      <Tool 
     191        Name="VCPreBuildEventTool"/> 
     192      <Tool 
     193        Name="VCPreLinkEventTool"/> 
     194      <Tool 
     195        Name="VCResourceCompilerTool"/> 
     196      <Tool 
     197        Name="VCWebServiceProxyGeneratorTool"/> 
     198      <Tool 
     199        Name="VCXMLDataGeneratorTool"/> 
     200      <Tool 
     201        Name="VCWebDeploymentTool"/> 
     202      <Tool 
     203        Name="VCManagedWrapperGeneratorTool"/> 
     204      <Tool 
     205        Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 
     206    </Configuration> 
    110207  </Configurations> 
    111208  <References> 
     
    133230            UsePrecompiledHeader="1"/> 
    134231        </FileConfiguration> 
     232        <FileConfiguration 
     233          Name="Dynamic Linkage|Win32"> 
     234          <Tool 
     235            Name="VCCLCompilerTool" 
     236            UsePrecompiledHeader="1"/> 
     237        </FileConfiguration> 
     238        <FileConfiguration 
     239          Name="Debug Dynamic Linkage|Win32"> 
     240          <Tool 
     241            Name="VCCLCompilerTool" 
     242            UsePrecompiledHeader="1"/> 
     243        </FileConfiguration> 
    135244      </File> 
    136245      <File 
  • readme.txt

    r3baaa4d r36c340d  
    1 ** ROUGH DRAFT ** 
    2 ** Spelling missate etc... :) ** 
    3  
    4  
    51NSClient++ is a windows service that allows performance metrics to be gathered by Nagios  
    62(and possibly other monitoring tools). It is an attempt to create a NSClient compatible  
     
    84 
    95 
     6This is an initial NSClient++ test release. 
     7 
     8This version has many of the features from NSClient. 
     9The following commands (from check_nt) are supported. 
     10 * CLIENTVERSION 
     11 * CPULOAD 
     12 * UPTIME 
     13 * USEDDISKSPACE 
     14 * MEMUSE 
     15 * SERVICESTATE 
     16 * PROCSTATE 
     17 
    1018Installation: 
    11 NSClient++ -install 
    12 Will install the NT service 
     19To install simply copy all files to directory on the server and run  
     20the following command: "NSClient++ /install" to uninstall run:  
     21"NSClient++ /uninstall". 
    1322 
    14 NSClient++ -uninstall 
    15 Will uninstall the service 
     23The NSClient++ has the following command syntax: 
     24NSClient++ -<command> 
     25  <command> 
     26    install - Install the service 
     27    start - Start the service 
     28    stop  - Stop the service 
     29    about - Show some info (version et.al.) 
     30    version - Show some info 
     31    test  - Run interactively (hint: enable ConsoleLogger for  
     32      this to make sense). Useful for debugging purposes. 
    1633 
    17 NSClient++ -start 
    18 Will start the service 
     34The directory structure: 
     35  <install root> 
     36    - NSClient++.exe  - The executable (and service) 
     37    - NSC.ini   - The INI file (settings) 
     38    <modules> 
     39      - Various NSClient++ modules available to this instance. 
    1940 
    20 NSClient++ -stop 
    21 Will stop the service 
     41The default modules: 
     42CheckEventLog.dll 
     43  An eventlog checker (has yet to get a Unix client) 
     44ConsoleLogger.dll 
     45  Log messages to console. (Usefull when run with -test) 
     46FileLogger.dll 
     47  Log messages to file (Usefull when run as service) 
     48NSClientCompat.dll 
     49  NSCLient compatibility module. Provides NSClient commands. 
     50SysTray.dll 
     51  Shows a sytray when the service (exe) is started and allows you to  
     52  view the logfile and inject commands. 
    2253 
    23 NSClient++ -test 
    24 Will start in interactive mode: 
    25 enter exit<return> to exit. ANything else will be interpreted as a command ie: foo&bar<enter> will be interpreted as a command name foo with argument bar. 
    26 It also listens to the port in this mode so it can be used to run the client standalone. 
    27 Notice output is *NOT* piped t othe stdard output unless you enable the console logger module. 
     54Settings: 
     55The following things can be changed ion the NSC.ini file. 
     56 
     57[generic] 
     58password=secret-password 
     59# The password to use. 
     60 
     61port=1234 
     62# The port to bind to 
     63 
     64[main] 
     65bufferSize=4096 
     66# Maximum buffer size for commands to return 
     67 
     68[log] 
     69file=nsclient.log 
     70# The file to log to. 
     71 
     72[nsclient compat] 
     73version=modern 
     74# The version string to return to the client. 
     75# Modern returns the nsclient++ version string in a new syntax: 
     76# <application> <version> <date> 
     77# Notice this is not automated as of yet (as in date/version is not updated). 
     78 
     79[systray] 
     80defaultCommand= 
     81# The default command to show in the inject command dialog. 
    2882 
    2983 
    30  
    31  
    32  
    33 The API is quite simple: 
     84Using the API: 
    3485The following functions are available for a module to "export": (think DLL) 
    3586 
Note: See TracChangeset for help on using the changeset viewer.