Changeset df0ab60 in nscp for NSClient++.cpp


Ignore:
Timestamp:
11/21/07 21:53:18 (6 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
58a724d
Parents:
5044c09
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"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NSClient++.cpp

    r5044c09 rdf0ab60  
    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) { 
Note: See TracChangeset for help on using the changeset viewer.