Changeset 8d928dd in nscp


Ignore:
Timestamp:
11/21/07 21:53:18 (6 years ago)
Author:
Michael Medin <michael@…>
Children:
81cf57a
Parents:
31509a7
Message:

2007-11-21 MickeM

  • Fixed process counter so checkProcState now return the *correct* number (previously it was correct-1)
  • Fixed som missing exceptions that were not caught + Added "AliasCol?" option to CheckWMIValue to allow a column to be used as "alias" for a result set:

CheckWMIValue -a "Query=select Caption, ThreadCount? from Win32_Process" MaxWarn=50 MaxCrit=100 Check:threads=ThreadCount AliasCol?=Caption

will give you: "System threads: 98 > warning, svchost.exe threads: 87 > warning"

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/AutoBuild.h

    r31509a7 r8d928dd  
    33// change the FALSE to TRUE for autoincrement of build number 
    44#define INCREMENT_VERSION TRUE 
    5 #define FILEVER        0,2,7,84 
    6 #define PRODUCTVER     0,2,7,182 
    7 #define STRFILEVER     "0.2.7.84" 
    8 #define STRPRODUCTVER  "0.2.7.182" 
    9 #define STRPRODUCTDATE  "2007-11-18" 
     5#define FILEVER        0,2,7,88 
     6#define PRODUCTVER     0,2,7,186 
     7#define STRFILEVER     "0.2.7.88" 
     8#define STRPRODUCTVER  "0.2.7.186" 
     9#define STRPRODUCTDATE  "2007-11-20" 
    1010#endif // AUTOBUILD_H 
  • trunk/NSClient++-2005.vcproj

    r31509a7 r8d928dd  
    634634      <Tool 
    635635        Name="VCCustomBuildTool" 
    636         CommandLine="echo Seting up scripts&#x0D;&#x0A;cmd /c &quot;mkdir $(InputDir)\Dist\scripts\&quot;&#x0D;&#x0A;cmd /c &quot;xcopy /Q /Y $(InputDir)\scripts\*.bat $(InputDir)\Dist\scripts\&quot;&#x0D;&#x0A;echo Removing old archive&#x0D;&#x0A;cmd /c &quot;del &quot;$(InputDir)\Dist\modules\*.pdb&quot;&quot;&#x0D;&#x0A;cmd /c &quot;del &quot;$(InputDir)\Dist\*.zip&quot;&quot;&#x0D;&#x0A;echo Making archive&#x0D;&#x0A;7z.exe a -r -tzip -bd $(TargetDir)\$(InputName)-$(PlatformName).zip $(TargetDir)\*&#x0D;&#x0A;echo Renaming archive&#x0D;&#x0A;postbuild.pl &quot;$(TargetDir)\$(InputName)-$(PlatformName).zip&quot;&#x0D;&#x0A;echo Sending to server&#x0D;&#x0A;pscp.exe $(TargetDir)\*.zip mickem@ssl.nakednuns.org:/var/www/files/nightly/&#x0D;&#x0A;" 
     636        CommandLine="echo Seting up scripts&#x0D;&#x0A;cmd /c &quot;mkdir &quot;$(InputDir)\Dist\scripts\&quot;&quot;&#x0D;&#x0A;cmd /c &quot;xcopy /Q /Y &quot;$(InputDir)\scripts\*.*&quot; &quot;$(InputDir)\Dist\scripts\&quot;&quot;&#x0D;&#x0A;echo Removing old archive&#x0D;&#x0A;cmd /c &quot;del &quot;$(InputDir)\Dist\modules\*.pdb&quot;&quot;&#x0D;&#x0A;cmd /c &quot;del &quot;$(InputDir)\Dist\*.zip&quot;&quot;&#x0D;&#x0A;echo Making archive&#x0D;&#x0A;7z.exe a -r -tzip -bd &quot;$(TargetDir)\$(ProjectName)-$(PlatformName).zip&quot; &quot;$(TargetDir)\*&quot;&#x0D;&#x0A;echo Renaming archive&#x0D;&#x0A;postbuild.pl &quot;$(TargetDir)\$(ProjectName)-$(PlatformName).zip&quot;&#x0D;&#x0A;echo Sending to server&#x0D;&#x0A;pscp.exe &quot;$(TargetDir)\*.zip&quot; mickem@ssl.nakednuns.org:/var/www/files/nightly/&#x0D;&#x0A;" 
    637637        Outputs="$(InputDir)\Dist\$(ProjectName).zip" 
    638638      /> 
  • trunk/NSClient++.cpp

    r31509a7 r8d928dd  
    106106    } else if ( _stricmp( "noboot", argv[1]+1 ) == 0 ) { 
    107107      g_bConsoleLog = true; 
     108      mainClient.enableDebug(true); 
    108109      int nRetCode = -1; 
    109110      if (argc>=4) 
     
    181182  try { 
    182183    Settings::getInstance()->setFile(getBasePath(), "NSC.ini"); 
     184    if (debug_) { 
     185      Settings::getInstance()->setInt("log", "debug", 1); 
     186    } 
    183187  } catch (SettingsException e) { 
    184188    LOG_ERROR_STD("Could not find settings: " + e.getMessage()); 
     
    187191    LOG_ERROR_STD("Unknown exception reading settings..."); 
    188192    return false; 
    189   } 
    190   if (debug_) { 
    191     Settings::getInstance()->setInt("log", "debug", 1); 
    192193  } 
    193194 
     
    201202    return false; 
    202203  } 
    203  
    204   SettingsT::sectionList list = Settings::getInstance()->getSection("modules"); 
    205   for (SettingsT::sectionList::iterator it = list.begin(); it != list.end(); it++) { 
    206     try { 
    207       loadPlugin(getBasePath() + "modules\\" + (*it)); 
    208     } catch(const NSPluginException& e) { 
    209       LOG_ERROR_STD("Exception raised: " + e.error_ + " in module: " + e.file_); 
    210       return false; 
    211     } catch (...) { 
    212       LOG_ERROR_STD("Unknown exception loading plugin: " + (*it)); 
    213       return false; 
    214     } 
     204  try { 
     205    SettingsT::sectionList list = Settings::getInstance()->getSection("modules"); 
     206    for (SettingsT::sectionList::iterator it = list.begin(); it != list.end(); it++) { 
     207      try { 
     208        loadPlugin(getBasePath() + "modules\\" + (*it)); 
     209      } catch(const NSPluginException& e) { 
     210        LOG_ERROR_STD("Exception raised: " + e.error_ + " in module: " + e.file_); 
     211        return false; 
     212      } catch (...) { 
     213        LOG_ERROR_STD("Unknown exception loading plugin: " + (*it)); 
     214        return false; 
     215      } 
     216    } 
     217  } catch (SettingsException e) { 
     218    NSC_LOG_ERROR_STD("Failed to set settings file" + e.getMessage()); 
    215219  } 
    216220  try { 
     
    472476  static status d = unknown; 
    473477  if (d == unknown) { 
    474     if (Settings::getInstance()->getInt("log", "debug", 0) == 1) 
     478    try { 
     479      if (Settings::getInstance()->getInt("log", "debug", 0) == 1) 
     480        d = debug; 
     481      else 
     482        d = nodebug; 
     483    } catch (SettingsException e) { 
    475484      d = debug; 
    476     else 
    477       d = nodebug; 
     485    } 
    478486  } 
    479487  return (d == debug); 
     
    554562  basePath = path.substr(0, pos) + "\\"; 
    555563  delete [] buffer; 
    556   Settings::getInstance()->setFile(basePath, "NSC.ini"); 
     564  try { 
     565    Settings::getInstance()->setFile(basePath, "NSC.ini"); 
     566  } catch (SettingsException e) { 
     567    NSC_LOG_ERROR_STD("Failed to set settings file" + e.getMessage()); 
     568  } 
    557569  return basePath; 
    558570} 
     
    563575} 
    564576int NSAPIGetSettingsInt(const char* section, const char* key, int defaultValue) { 
    565   return Settings::getInstance()->getInt(section, key, defaultValue); 
     577  try { 
     578    return Settings::getInstance()->getInt(section, key, defaultValue); 
     579  } catch (SettingsException e) { 
     580    NSC_LOG_ERROR_STD("Failed to set settings file" + e.getMessage()); 
     581  } 
    566582} 
    567583NSCAPI::errorReturn NSAPIGetBasePath(char*buffer, unsigned int bufLen) { 
  • trunk/changelog

    r31509a7 r8d928dd  
    55 * Add module for relaying events 
    66 * Add API for rehashing the daemon (or implement it the API is there but does nothing) 
     7 
     82007-11-21 MickeM 
     9 * Fixed process counter so checkProcState  now return the *correct* number (previously it was correct-1) 
     10 * Fixed som missing exceptions that were not caught 
     11 + Added "AliasCol" option to CheckWMIValue to allow a column to be used as "alias" for a result set: 
     12     CheckWMIValue -a "Query=select Caption, ThreadCount from Win32_Process" MaxWarn=50 MaxCrit=100 Check:threads=ThreadCount AliasCol=Caption 
     13    will give you: "System threads: 98 > warning, svchost.exe threads: 87 > warning" 
     14 
     152007-11-20 MickeM 
     16 + Added new option to CheckSystem to override detected language (force_language=0x0014) 
    717 
    8182007-11-19 MickeM 
  • trunk/include/config.h

    rbab5a54 r8d928dd  
    108108#define C_SYSTEM_AUTODETECT_PDH "auto_detect_pdh" 
    109109#define C_SYSTEM_AUTODETECT_PDH_DEFAULT 1 
     110#define C_SYSTEM_FORCE_LANGUAGE "force_language" 
     111#define C_SYSTEM_FORCE_LANGUAGE_DEFAULT "" 
    110112 
    111113#define C_SYSTEM_MEM_PAGE_LIMIT "MemoryCommitLimit" 
  • trunk/modules/CheckSystem/CheckSystem.cpp

    rbab5a54 r8d928dd  
    725725  for (BOOL OK = enumeration.GetProcessFirst(&entry); OK; OK = enumeration.GetProcessNext(&entry) ) { 
    726726    NSPROCLST::iterator it = ret.find(entry.sFilename); 
    727     if (it == ret.end()) 
     727    if (it == ret.end()) { 
    728728      ret[entry.sFilename].entry = entry; 
    729     else 
     729      ret[entry.sFilename].count = 1; 
     730    } else 
    730731      (*it).second.count++; 
    731732  } 
  • trunk/modules/CheckSystem/PDHCollector.cpp

    rc1e3930 r8d928dd  
    6464    SettingsT settings; 
    6565    std::string prefix; 
    66     std::string section; 
    6766    settings.setFile(NSCModuleHelper::getBasePath(),  "counters.defs", true); 
    68  
    69     NSC_LOG_ERROR_STD("Getting counter info..."); 
     67    std::string section = NSCModuleHelper::getSettingsString(C_SYSTEM_SECTION_TITLE, C_SYSTEM_FORCE_LANGUAGE, C_SYSTEM_FORCE_LANGUAGE_DEFAULT); 
    7068 
    7169    try { 
     
    9290      } 
    9391 
    94       section = "0000" + strEx::ihextos(langId); 
    95       section = "0x" + section.substr(section.length()-4); 
     92      if (!section.empty()) { 
     93        NSC_DEBUG_MSG_STD("Overriding language with: " + section); 
     94      } else { 
     95        section = "0000" + strEx::ihextos(langId); 
     96        section = "0x" + section.substr(section.length()-4); 
     97      } 
    9698      if (settings.getString(section, "Description", "_NOT_FOUND") == "_NOT_FOUND") { 
    9799        NSC_LOG_ERROR_STD("Detected language: " + section + " but it could not be found in: counters.defs"); 
     
    101103      NSC_DEBUG_MSG_STD("Detected language: " + settings.getString(section, "Description", "Not found") + " (" + section + ")"); 
    102104    } catch (const systemInfo::SystemInfoException &e) { 
    103       //NSC_LOG_ERROR_STD("System detection failed, PDH will be disabled: " + e.getError()); 
    104105      NSC_LOG_ERROR_STD("To manual set performance counters you need to first set " C_SYSTEM_AUTODETECT_PDH "=0 in the config file, and then you also need to configure the various counter."); 
    105106      return -1; 
  • trunk/modules/CheckWMI/CheckWMI.cpp

    r22dec86 r8d928dd  
    155155  unsigned int truncate = 0; 
    156156  std::string query; 
     157  std::string aliasCol; 
    157158 
    158159  // Query=Select ... MaxWarn=5 MaxCrit=12 Check=Col1 --(later)-- Match==test Check=Col2 
     
    163164      MAP_OPTIONS_NUMERIC_ALL(tmpObject, "") 
    164165      MAP_OPTIONS_STR("Alias", tmpObject.data) 
     166      MAP_OPTIONS_STR("AliasCol", aliasCol) 
    165167      MAP_OPTIONS_STR("Query", query) 
    166168      MAP_OPTIONS_BOOL_FALSE(IGNORE_PERFDATA, bPerfData) 
     
    199201        } 
    200202      } 
    201     } else { 
    202       for (WMIQuery::result_type::const_iterator citRow = rows.begin(); citRow != rows.end(); ++citRow) { 
    203         bool found = false; 
    204         for (WMIQuery::wmi_row::list_type::const_iterator citCol = (*citRow).results.begin(); citCol != (*citRow).results.end(); ++citCol) { 
    205           if ((*citCol).first == itm.data) { 
    206             found = true; 
    207             long long value = (*citCol).second.numeric; 
    208             itm.runCheck(value, returnCode, message, perf); 
    209           } 
    210         } 
    211         if (!found) { 
    212           NSC_LOG_ERROR_STD("Column: " + itm.data + " was not found!"); 
     203    } 
     204  } 
     205  for (WMIQuery::result_type::const_iterator citRow = rows.begin(); citRow != rows.end(); ++citRow) { 
     206    bool found = false; 
     207    std::string alias; 
     208    if (!aliasCol.empty()) { 
     209      alias = (*citRow).get(aliasCol).string; 
     210    } 
     211    for (WMIQuery::wmi_row::list_type::const_iterator citCol = (*citRow).results.begin(); citCol != (*citRow).results.end(); ++citCol) { 
     212      for (std::list<WMIConatiner>::const_iterator it = list.begin(); it != list.end(); ++it) { 
     213        WMIConatiner itm = (*it); 
     214        if (itm.data == "*") { 
     215          found = true; 
     216        } else if ((*citCol).first == itm.data) { 
     217          std::string oldAlias = itm.alias; 
     218          if (!alias.empty()) 
     219            itm.alias = alias + " " + itm.getAlias(); 
     220          found = true; 
     221          long long value = (*citCol).second.numeric; 
     222          itm.runCheck(value, returnCode, message, perf); 
     223          itm.alias = oldAlias; 
    213224        } 
    214225      } 
     226    } 
     227    if (!found) { 
     228      NSC_LOG_ERROR_STD("A column was not found!"); 
    215229    } 
    216230  } 
Note: See TracChangeset for help on using the changeset viewer.