Changeset df0ab60 in nscp for modules/CheckWMI/CheckWMI.cpp


Ignore:
Timestamp:
11/21/07 21:53:18 (5 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
  • modules/CheckWMI/CheckWMI.cpp

    receb8c7 rdf0ab60  
    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.