Changeset 7b51081 in nscp for trunk/modules/CheckSystem


Ignore:
Timestamp:
02/23/07 19:25:23 (6 years ago)
Author:
Michael Medin <michael@…>
Children:
3c35ad4
Parents:
858709e
Message:

Getting ready for the 0.2.7 release, a few minor fixes here and there...

Location:
trunk/modules/CheckSystem
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/CheckSystem/CheckSystem.cpp

    r858709e r7b51081  
    1010#include <checkHelpers.hpp> 
    1111#include <map> 
     12#include <set> 
    1213#include <sysinfo.h> 
    1314 
     
    309310  NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 
    310311  bool bNSClient = false; 
     312  bool bPerfData = true; 
    311313  CPULoadConatiner tmpObject; 
    312314 
     
    317319    MAP_OPTIONS_STR("warn", tmpObject.warn.max) 
    318320    MAP_OPTIONS_STR("crit", tmpObject.crit.max) 
     321    MAP_OPTIONS_BOOL_FALSE(IGNORE_PERFDATA, bPerfData) 
    319322    MAP_OPTIONS_STR_AND("time", tmpObject.data, list.push_back(tmpObject)) 
    320323    MAP_OPTIONS_STR_AND("Time", tmpObject.data, list.push_back(tmpObject)) 
     
    349352    } else { 
    350353      load.setDefault(tmpObject); 
     354      if (!bPerfData) 
     355        load.perfData = false; 
    351356      load.runCheck(value, returnCode, msg, perf); 
    352357    } 
     
    371376  NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 
    372377  bool bNSClient = false; 
     378  bool bPerfData = true; 
    373379  UpTimeConatiner bounds; 
    374380 
     
    379385    MAP_OPTIONS_STR("warn", bounds.warn.min) 
    380386    MAP_OPTIONS_STR("crit", bounds.crit.min) 
     387    MAP_OPTIONS_BOOL_FALSE(IGNORE_PERFDATA, bPerfData) 
    381388    MAP_OPTIONS_STR("Alias", bounds.data) 
    382389    MAP_OPTIONS_SHOWALL(bounds) 
     
    396403  } else { 
    397404    value *= 1000; 
     405    if (!bPerfData) 
     406      bounds.perfData = false; 
    398407    bounds.runCheck(value, returnCode, msg, perf); 
    399408  } 
     
    441450  } 
    442451  std::list<StateConatiner> list; 
     452  std::set<std::string> excludeList; 
    443453  NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 
    444454  bool bNSClient = false; 
    445455  StateConatiner tmpObject; 
    446  
    447   tmpObject.data = "uptime"; 
    448   tmpObject.warn.state = "started"; 
    449  
     456  bool bPerfData = true; 
     457  bool bAutoStart = false; 
     458 
     459  tmpObject.data = "service"; 
     460  tmpObject.crit.state = "started"; 
     461  //{{ 
    450462  MAP_OPTIONS_BEGIN(stl_args) 
    451463    MAP_OPTIONS_SHOWALL(tmpObject) 
    452464    MAP_OPTIONS_STR("Alias", tmpObject.data) 
     465    MAP_OPTIONS_BOOL_FALSE(IGNORE_PERFDATA, bPerfData) 
    453466    MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 
     467    MAP_OPTIONS_BOOL_TRUE("CheckAll", bAutoStart) 
     468    MAP_OPTIONS_INSERT("exclude", excludeList) 
    454469    MAP_OPTIONS_SECONDARY_BEGIN(":", p2) 
    455       else if (p2.first == "Time") { 
    456         tmpObject.data = p__.second; 
    457         tmpObject.alias = p2.second; 
    458         list.push_back(tmpObject); 
    459       } 
    460470      MAP_OPTIONS_MISSING_EX(p2, msg, "Unknown argument: ") 
    461471    MAP_OPTIONS_SECONDARY_END() 
     
    469479    } 
    470480  MAP_OPTIONS_END() 
    471  
     481  //}} 
     482  if (bAutoStart) { 
     483    // get a list of all service with startup type Automatic  
     484    std::list<TNtServiceInfo> service_list_automatic; 
     485    TNtServiceInfo::EnumServices(SERVICE_WIN32,SERVICE_INACTIVE|SERVICE_ACTIVE,&service_list_automatic);  
     486    for (std::list<TNtServiceInfo>::const_iterator service =service_list_automatic.begin();service!=service_list_automatic.end();++service) {  
     487      if (excludeList.find((*service).m_strServiceName) == excludeList.end()) { 
     488        if((*service).m_dwStartType == 2 ) { 
     489          tmpObject.data = (*service).m_strServiceName; 
     490          tmpObject.crit.state = "started";  
     491          list.push_back(tmpObject);  
     492          //stl_forward.push_back((*service).m_strServiceName);  
     493        } 
     494        else if((*service).m_dwStartType == 4 ) { 
     495          tmpObject.data = (*service).m_strServiceName; 
     496          tmpObject.crit.state = "stopped";  
     497          list.push_back(tmpObject);  
     498        } 
     499      } 
     500    }  
     501  } 
    472502  for (std::list<StateConatiner>::iterator it = list.begin(); it != list.end(); ++it) { 
    473503    TNtServiceInfo info; 
     
    509539      else 
    510540        value = checkHolders::state_none; 
     541      if (!bPerfData) 
     542        (*it).perfData = false; 
    511543      (*it).runCheck(value, returnCode, msg, perf); 
    512544    } 
     
    542574  NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 
    543575  bool bShowAll = false; 
     576  bool bPerfData = true; 
    544577  bool bNSClient = false; 
    545578  MemoryConatiner bounds; 
     
    551584    MAP_OPTIONS_STR("Alias", bounds.data) 
    552585    MAP_OPTIONS_SHOWALL(bounds) 
     586    MAP_OPTIONS_BOOL_FALSE(IGNORE_PERFDATA, bPerfData) 
    553587    MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 
    554588    MAP_OPTIONS_MODE("type", "paged", type, tPaged) 
     
    603637    return NSCAPI::returnOK; 
    604638  } else { 
     639    if (!bPerfData) 
     640      bounds.perfData = false; 
    605641    bounds.runCheck(value, returnCode, msg, perf); 
    606642  } 
     
    668704  bool bNSClient = false; 
    669705  StateConatiner tmpObject; 
     706  bool bPerfData = true; 
    670707 
    671708  tmpObject.data = "uptime"; 
     
    676713    MAP_OPTIONS_STR("Alias", tmpObject.alias) 
    677714    MAP_OPTIONS_SHOWALL(tmpObject) 
     715    MAP_OPTIONS_BOOL_FALSE(IGNORE_PERFDATA, bPerfData) 
    678716    MAP_OPTIONS_BOOL_TRUE(NSCLIENT, bNSClient) 
    679717    MAP_OPTIONS_SECONDARY_BEGIN(":", p2) 
     
    713751      if (bFound && (*it).showAll()) { 
    714752        if (!msg.empty()) msg += " - "; 
    715         msg += (*it).data + ": Started"; 
     753        msg += (*it).data + ": Running"; 
    716754      } else if (bFound) { 
    717755      } else { 
    718756        if (!msg.empty()) msg += " - "; 
    719         msg += (*it).data + ": Stopped"; 
     757        msg += (*it).data + ": not running"; 
    720758        NSCHelper::escalteReturnCodeToCRIT(returnCode); 
    721759      } 
     
    729767        value.state = checkHolders::state_stopped; 
    730768      } 
     769      if (!bPerfData) 
     770        (*it).perfData = false; 
    731771      (*it).runCheck(value, returnCode, msg, perf); 
    732772    } 
     
    765805  NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 
    766806  bool bNSClient = false; 
     807  bool bPerfData = true; 
    767808  /* average maax */ 
    768809  bool bCheckAverages = true;  
     
    776817    MAP_OPTIONS_STR("MaxCrit", tmpObject.crit.max) 
    777818    MAP_OPTIONS_STR("MinCrit", tmpObject.crit.min) 
     819    MAP_OPTIONS_BOOL_FALSE(IGNORE_PERFDATA, bPerfData) 
    778820    MAP_OPTIONS_STR("Alias", tmpObject.data) 
    779821    MAP_OPTIONS_SHOWALL(tmpObject) 
     
    815857        msg += strEx::itos(value); 
    816858      } else { 
     859        if (!bPerfData) 
     860          counter.perfData = false; 
    817861        counter.setDefault(tmpObject); 
    818862        counter.runCheck(value, returnCode, msg, perf); 
  • trunk/modules/CheckSystem/PDHCollector.cpp

    r858709e r7b51081  
    4545* @author mickem 
    4646* 
    47 * @date 03-13-2004 
     47* @date 03-13-2004                
    4848* 
    4949* @bug If we have "custom named" counters ? 
Note: See TracChangeset for help on using the changeset viewer.