Changeset 5735dda in nscp for modules/CheckSystem
- Timestamp:
- 06/13/10 22:02:07 (3 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- f0607c4
- Parents:
- 5cd6bcf (diff), f1d6990 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- modules/CheckSystem
- Files:
-
- 3 deleted
- 5 edited
-
CheckSystem.cpp (modified) (7 diffs)
-
CheckSystem.h (modified) (1 diff)
-
CheckSystem-2005.vcproj (deleted)
-
CheckSystem-2008.vcproj (deleted)
-
CheckSystem.def (modified) (1 diff)
-
Jamfile (deleted)
-
PDHCollector.cpp (modified) (7 diffs)
-
stdafx.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
modules/CheckSystem/CheckSystem.cpp
rb4110d8 r5735dda 30 30 #include <set> 31 31 #include <sysinfo.h> 32 #include <filter_framework.hpp> 33 #include <simple_registry.hpp> 34 32 35 #ifdef USE_BOOST 33 36 #include <boost/regex.hpp> … … 77 80 NSCModuleHelper::registerCommand(_T("checkCounter"), _T("Check a PDH counter.")); 78 81 NSCModuleHelper::registerCommand(_T("listCounterInstances"), _T("List all instances for a counter.")); 82 NSCModuleHelper::registerCommand(_T("checkSingleRegEntry"), _T("Check registry key")); 83 84 79 85 } catch (NSCModuleHelper::NSCMHExcpetion &e) { 80 86 NSC_LOG_ERROR_STD(_T("Failed to register command: ") + e.msg_); … … 208 214 } 209 215 } else { 216 if ((*it).counters.size() == 0) { 217 std::wcout << _T("empty counter: ") << (*it).name << std::endl; 218 } 210 219 for (PDH::Enumerations::Counters::const_iterator it2 = (*it).counters.begin();it2!=(*it).counters.end();++it2) { 211 220 std::wstring counter = _T("\\") + (*it).name + _T("\\") + (*it2).name; … … 232 241 } 233 242 std::wcout << _T(" open "); 234 std::wcout << std::endl; ;243 std::wcout << std::endl; 235 244 } 236 245 } … … 264 273 return 0; 265 274 } 266 DWORD dw = PDH::PDH Query::lookupIndex(name);275 DWORD dw = PDH::PDHResolver::lookupIndex(name); 267 276 NSC_LOG_MESSAGE_STD(_T("--+--[ Lookup Result ]----------------------------------------")); 268 277 NSC_LOG_MESSAGE_STD(_T(" | Index for '") + name + _T("' is ") + strEx::itos(dw)); … … 341 350 } else if (command == _T("listCounterInstances")) { 342 351 return listCounterInstances(argLen, char_args, msg, perf); 352 } else if (command == _T("checkSingleRegEntry")) { 353 return checkSingleRegEntry(argLen, char_args, msg, perf); 343 354 } 344 355 return NSCAPI::returnIgnored; … … 1164 1175 } 1165 1176 1177 ////////////////////////////////////////////////////////////////////////// 1178 ////////////////////////////////////////////////////////////////////////// 1179 1180 struct regkey_info { 1181 1182 std::wstring error; 1183 1184 static regkey_info get(__int64 now, std::wstring path) { 1185 return regkey_info(now, path); 1186 } 1187 1188 regkey_info() 1189 : ullLastWriteTime(0) 1190 , iType(0) 1191 , ullNow(0) 1192 , uiExists(0) 1193 , ullChildCount(0) 1194 {} 1195 regkey_info(__int64 now, std::wstring path) 1196 : path(path) 1197 , ullLastWriteTime(0) 1198 , iType(0) 1199 , ullNow(now) 1200 , uiExists(0) 1201 , ullChildCount(0) 1202 { 1203 std::wstring key; 1204 try { 1205 std::wcout << _T("opening: ") << path << std::endl; 1206 std::wstring::size_type pos = path.find_first_of(L'\\'); 1207 if (pos != std::wstring::npos) { 1208 key = path.substr(0, pos); 1209 path = path.substr(pos+1); 1210 std::wcout << key << _T(":") << path << std::endl; 1211 simple_registry::registry_key rkey(simple_registry::parseHKEY(key), path); 1212 info = rkey.get_info(); 1213 uiExists = 1; 1214 } else { 1215 error = _T("Failed to parse key"); 1216 } 1217 } catch (simple_registry::registry_exception &e) { 1218 try { 1219 std::wstring::size_type pos = path.find_last_of(L'\\'); 1220 if (pos != std::wstring::npos) { 1221 std::wstring item = path.substr(pos+1); 1222 path = path.substr(0, pos); 1223 std::wcout << key << _T(":") << path << _T(".") << item << std::endl; 1224 simple_registry::registry_key rkey(simple_registry::parseHKEY(key), path); 1225 info = rkey.get_info(item); 1226 uiExists = 1; 1227 } else { 1228 error = _T("Failed to parse key"); 1229 } 1230 } catch (simple_registry::registry_exception &e) { 1231 //error = e.what(); 1232 } 1233 } catch (...) { 1234 error = _T("Unknown exception"); 1235 } 1236 1237 //HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application\MaxSize 1238 1239 // TODO get key info here! 1240 //ullLastWriteTime = ((info.ftLastWriteTime.dwHighDateTime * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)info.ftLastWriteTime.dwLowDateTime); 1241 }; 1242 1243 unsigned long long ullSize; 1244 __int64 ullLastWriteTime; 1245 __int64 ullNow; 1246 std::wstring filename; 1247 std::wstring path; 1248 unsigned long ullChildCount; 1249 unsigned long uiExists; 1250 unsigned int iType; 1251 simple_registry::registry_key::reg_info info; 1252 1253 static const __int64 MSECS_TO_100NS = 10000; 1254 1255 __int64 get_written() { 1256 return (ullNow-ullLastWriteTime)/MSECS_TO_100NS; 1257 } 1258 std::wstring render(std::wstring syntax) { 1259 strEx::replace(syntax, _T("%path%"), path); 1260 strEx::replace(syntax, _T("%key%"), filename); 1261 strEx::replace(syntax, _T("%write%"), strEx::format_filetime(ullLastWriteTime, DATE_FORMAT)); 1262 strEx::replace(syntax, _T("%write-raw%"), strEx::itos(ullLastWriteTime)); 1263 strEx::replace(syntax, _T("%now-raw%"), strEx::itos(ullNow)); 1264 strEx::replace(syntax, _T("%type%"), strEx::itos_as_BKMG(iType)); 1265 strEx::replace(syntax, _T("%child-count%"), strEx::itos(ullChildCount)); 1266 strEx::replace(syntax, _T("%exists%"), strEx::itos(uiExists)); 1267 strEx::replace(syntax, _T("%int%"), strEx::itos(info.iValue)); 1268 strEx::replace(syntax, _T("%int-value%"), strEx::itos(info.iValue)); 1269 strEx::replace(syntax, _T("%string%"), info.sValue); 1270 strEx::replace(syntax, _T("%string-value%"), info.sValue); 1271 return syntax; 1272 } 1273 }; 1274 1275 1276 struct regkey_filter { 1277 filters::filter_all_times written; 1278 filters::filter_all_num_ul type; 1279 filters::filter_all_num_ul exists; 1280 filters::filter_all_num_ul child_count; 1281 filters::filter_all_num_ll value_int; 1282 filters::filter_all_strings value_string; 1283 1284 inline bool hasFilter() { 1285 return type.hasFilter() || exists.hasFilter() || written.hasFilter() || child_count.hasFilter() || value_int.hasFilter() || value_string.hasFilter(); 1286 } 1287 bool matchFilter(regkey_info &value) const { 1288 if ((written.hasFilter())&&(written.matchFilter(value.get_written()))) 1289 return true; 1290 else if (type.hasFilter()&&type.matchFilter(value.iType)) 1291 return true; 1292 else if (exists.hasFilter()&&exists.matchFilter(value.uiExists)) 1293 return true; 1294 else if ((child_count.hasFilter())&&(child_count.matchFilter(value.ullChildCount))) 1295 return true; 1296 else if ((value_int.hasFilter())&&(value_int.matchFilter(value.info.iValue))) 1297 return true; 1298 else if ((value_string.hasFilter())&&(value_string.matchFilter(value.info.sValue))) 1299 return true; 1300 return false; 1301 } 1302 1303 std::wstring getValue() const { 1304 if (written.hasFilter()) 1305 return _T("written: ") + written.getValue(); 1306 if (type.hasFilter()) 1307 return _T("type: ") + type.getValue(); 1308 if (exists.hasFilter()) 1309 return _T("exists: ") + exists.getValue(); 1310 if (child_count.hasFilter()) 1311 return _T("child_count: ") + child_count.getValue(); 1312 if (value_int.hasFilter()) 1313 return _T("value(i): ") + value_int.getValue(); 1314 if (value_string.hasFilter()) 1315 return _T("value(s): ") + value_string.getValue(); 1316 return _T("UNknown..."); 1317 } 1318 1319 }; 1320 1321 1322 struct regkey_container : public regkey_info { 1323 1324 static regkey_container get(std::wstring path, unsigned long long now) { 1325 return regkey_container(now, path); 1326 } 1327 1328 1329 regkey_container(__int64 now, std::wstring path) : regkey_info(now, path) {} 1330 1331 bool has_errors() { 1332 return !error.empty(); 1333 } 1334 std::wstring get_error() { 1335 return error; 1336 } 1337 1338 }; 1339 1340 1341 class regkey_type_handler { 1342 public: 1343 static int parse(std::wstring s) { 1344 return 1; 1345 } 1346 static std::wstring print(int value) { 1347 return _T("unknown"); 1348 } 1349 static std::wstring print_unformated(int value) { 1350 return strEx::itos(value); 1351 } 1352 static std::wstring key_prefix() { 1353 return _T(""); 1354 } 1355 static std::wstring key_postfix() { 1356 return _T(""); 1357 } 1358 static std::wstring get_perf_unit(int value) { 1359 return _T(""); 1360 } 1361 static std::wstring print_perf(int value, std::wstring unit) { 1362 return strEx::itos(value); 1363 } 1364 }; 1365 class regkey_exists_handler { 1366 public: 1367 static int parse(std::wstring s) { 1368 if (s == _T("true")) 1369 return 1; 1370 return 0; 1371 } 1372 static std::wstring print(int value) { 1373 return value==1?_T("true"):_T("false"); 1374 } 1375 static std::wstring print_unformated(int value) { 1376 return strEx::itos(value); 1377 } 1378 static std::wstring key_prefix() { 1379 return _T(""); 1380 } 1381 static std::wstring key_postfix() { 1382 return _T(""); 1383 } 1384 static std::wstring get_perf_unit(int value) { 1385 return _T(""); 1386 } 1387 static std::wstring print_perf(int value, std::wstring unit) { 1388 return strEx::itos(value); 1389 } 1390 }; 1391 1392 typedef checkHolders::CheckContainer<checkHolders::ExactBounds<checkHolders::NumericBounds<int, regkey_type_handler> > > RegTypeContainer; 1393 typedef checkHolders::CheckContainer<checkHolders::ExactBounds<checkHolders::NumericBounds<int, regkey_exists_handler> > > RegExistsContainer; 1394 1395 typedef checkHolders::CheckContainer<checkHolders::ExactBoundsULong> ExactULongContainer; 1396 typedef checkHolders::CheckContainer<checkHolders::ExactBoundsLongLong> ExactLongLongContainer; 1397 typedef checkHolders::CheckContainer<checkHolders::ExactBoundsTime> DateTimeContainer; 1398 typedef checkHolders::CheckContainer<checkHolders::FilterBounds<filters::filter_all_strings> > StringContainer; 1399 1400 struct check_regkey_child_count : public checkHolders::check_proxy_container<regkey_container, ExactULongContainer> { 1401 check_regkey_child_count() { set_alias(_T("child-count")); } 1402 unsigned long get_value(regkey_container &value) { 1403 return value.ullChildCount; 1404 } 1405 }; 1406 struct check_regkey_int_value : public checkHolders::check_proxy_container<regkey_container, ExactLongLongContainer> { 1407 check_regkey_int_value() { set_alias(_T("value")); } 1408 long long get_value(regkey_container &value) { 1409 return value.info.iValue; 1410 } 1411 }; 1412 struct check_regkey_string_value : public checkHolders::check_proxy_container<regkey_container, StringContainer> { 1413 check_regkey_string_value() { set_alias(_T("value")); } 1414 std::wstring get_value(regkey_container &value) { 1415 return value.info.sValue; 1416 } 1417 }; 1418 struct check_regkey_written : public checkHolders::check_proxy_container<regkey_container, DateTimeContainer> { 1419 check_regkey_written() { set_alias(_T("written")); } 1420 unsigned long long get_value(regkey_container &value) { 1421 return value.ullLastWriteTime; 1422 } 1423 }; 1424 struct check_regkey_type : public checkHolders::check_proxy_container<regkey_container, RegTypeContainer> { 1425 check_regkey_type() { set_alias(_T("type")); } 1426 int get_value(regkey_container &value) { 1427 return value.iType; 1428 } 1429 }; 1430 struct check_regkey_exists : public checkHolders::check_proxy_container<regkey_container, RegExistsContainer> { 1431 check_regkey_exists() { set_alias(_T("exists")); } 1432 int get_value(regkey_container &value) { 1433 return value.uiExists; 1434 } 1435 }; 1436 1437 1438 typedef checkHolders::check_multi_container<regkey_container> check_file_multi; 1439 struct check_regkey_factories { 1440 static checkHolders::check_proxy_interface<regkey_container>* type() { 1441 return new check_regkey_type(); 1442 } 1443 static checkHolders::check_proxy_interface<regkey_container>* exists() { 1444 return new check_regkey_exists(); 1445 } 1446 static checkHolders::check_proxy_interface<regkey_container>* child_count() { 1447 return new check_regkey_child_count(); 1448 } 1449 static checkHolders::check_proxy_interface<regkey_container>* written() { 1450 return new check_regkey_written(); 1451 } 1452 static checkHolders::check_proxy_interface<regkey_container>* value_string() { 1453 return new check_regkey_string_value(); 1454 } 1455 static checkHolders::check_proxy_interface<regkey_container>* value_int() { 1456 return new check_regkey_int_value(); 1457 } 1458 }; 1459 1460 #define MAP_FACTORY_PB(value, obj) \ 1461 else if ((p__.first == _T("check")) && (p__.second == ##value)) { checker.add_check(check_regkey_factories::obj()); } 1462 1463 1464 NSCAPI::nagiosReturn CheckSystem::checkSingleRegEntry(const unsigned int argLen, TCHAR **char_args, std::wstring &message, std::wstring &perf) { 1465 NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 1466 std::list<std::wstring> stl_args = arrayBuffer::arrayBuffer2list(argLen, char_args); 1467 check_file_multi checker; 1468 typedef std::pair<int,regkey_filter> filteritem_type; 1469 typedef std::list<filteritem_type > filterlist_type; 1470 if (stl_args.empty()) { 1471 message = _T("Missing argument(s)."); 1472 return NSCAPI::returnUNKNOWN; 1473 } 1474 std::list<std::wstring> files; 1475 unsigned int truncate = 0; 1476 std::wstring syntax = _T("%filename%"); 1477 std::wstring alias; 1478 bool bPerfData = true; 1479 1480 try { 1481 MAP_OPTIONS_BEGIN(stl_args) 1482 MAP_OPTIONS_STR2INT(_T("truncate"), truncate) 1483 MAP_OPTIONS_BOOL_FALSE(IGNORE_PERFDATA, bPerfData) 1484 MAP_OPTIONS_STR(_T("syntax"), syntax) 1485 MAP_OPTIONS_STR(_T("alias"), alias) 1486 MAP_OPTIONS_PUSH(_T("path"), files) 1487 MAP_OPTIONS_SHOWALL(checker) 1488 MAP_OPTIONS_EXACT_NUMERIC_ALL_MULTI(checker, _T("")) 1489 MAP_FACTORY_PB(_T("type"), type) 1490 MAP_FACTORY_PB(_T("child-count"), child_count) 1491 MAP_FACTORY_PB(_T("written"), written) 1492 MAP_FACTORY_PB(_T("int"), value_int) 1493 MAP_FACTORY_PB(_T("string"), value_string) 1494 MAP_OPTIONS_MISSING(message, _T("Unknown argument: ")) 1495 MAP_OPTIONS_END() 1496 } catch (filters::parse_exception e) { 1497 message = e.getMessage(); 1498 return NSCAPI::returnUNKNOWN; 1499 } catch (filters::filter_exception e) { 1500 message = e.getMessage(); 1501 return NSCAPI::returnUNKNOWN; 1502 } 1503 FILETIME now; 1504 GetSystemTimeAsFileTime(&now); 1505 unsigned __int64 nowi64 = ((now.dwHighDateTime * ((unsigned long long)MAXDWORD+1)) + (unsigned long long)now.dwLowDateTime); 1506 for (std::list<std::wstring>::const_iterator pit = files.begin(); pit != files.end(); ++pit) { 1507 regkey_container info = regkey_container::get(*pit, nowi64); 1508 if (info.has_errors()) { 1509 message = info.error; 1510 return NSCAPI::returnUNKNOWN; 1511 } 1512 checker.alias = info.render(syntax); 1513 checker.runCheck(info, returnCode, message, perf); 1514 } 1515 if ((truncate > 0) && (message.length() > (truncate-4))) { 1516 message = message.substr(0, truncate-4) + _T("..."); 1517 perf = _T(""); 1518 } 1519 if (message.empty()) 1520 message = _T("CheckSingleRegkey ok"); 1521 return returnCode; 1522 } 1166 1523 1167 1524 NSC_WRAPPERS_MAIN_DEF(gCheckSystem); -
modules/CheckSystem/CheckSystem.h
rb4110d8 r5735dda 82 82 NSCAPI::nagiosReturn checkCounter(const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf); 83 83 NSCAPI::nagiosReturn listCounterInstances(const unsigned int argLen, TCHAR **char_args, std::wstring &msg, std::wstring &perf); 84 NSCAPI::nagiosReturn checkSingleRegEntry(const unsigned int argLen, TCHAR **char_args, std::wstring &message, std::wstring &perf); 84 85 85 86 -
modules/CheckSystem/CheckSystem.def
rf42280d rcad08fb 11 11 NSHandleCommand 12 12 NSUnloadModule 13 NSGetConfigurationMeta14 13 NSGetModuleDescription 15 14 NSCommandLineExec -
modules/CheckSystem/PDHCollector.cpp
r42ff14d rb4110d8 20 20 #include "stdafx.h" 21 21 #include "PDHCollector.h" 22 #include <Settings.h>23 22 #include <sysinfo.h> 24 23 25 24 26 25 PDHCollector::PDHCollector() : hStopEvent_(NULL) { 27 dontCollect_ = NSCModuleHelper::getSettingsInt(C_SYSTEM_SECTION_TITLE, C_SYSTEM_IGNORE_COLLECTION, C_SYSTEM_IGNORE_COLLECTION_DEFAULT)==1; 28 checkIntervall_ = NSCModuleHelper::getSettingsInt(C_SYSTEM_SECTION_TITLE, C_SYSTEM_CHECK_RESOLUTION, C_SYSTEM_CHECK_RESOLUTION_DEFAULT); 29 std::wstring s = NSCModuleHelper::getSettingsString(C_SYSTEM_SECTION_TITLE, C_SYSTEM_CPU_BUFFER_TIME, C_SYSTEM_CPU_BUFFER_TIME_DEFAULT); 26 // TODO: Re add this? 27 //dontCollect_ = SETTINGS_GET_INT(check_system::) NSCModuleHelper::getSettingsInt(C_SYSTEM_SECTION_TITLE, C_SYSTEM_IGNORE_COLLECTION, C_SYSTEM_IGNORE_COLLECTION_DEFAULT)==1; 28 checkIntervall_ = SETTINGS_GET_INT(check_system::INTERVALL); 29 std::wstring s = SETTINGS_GET_STRING(check_system::BUFFER_SIZE); 30 30 unsigned int i = strEx::stoui_as_time(s, checkIntervall_*100); 31 31 cpu.resize(i/(checkIntervall_*100)+10); … … 46 46 47 47 bool PDHCollector::loadCounter(PDH::PDHQuery &pdh) { 48 if (NSCModuleHelper::getSettingsInt(C_SYSTEM_SECTION_TITLE, C_SYSTEM_AUTODETECT_PDH, C_SYSTEM_AUTODETECT_PDH_DEFAULT) != 1) { 49 NSC_DEBUG_MSG_STD(_T("Autodetect disabled from nsc.ini via: ") + C_SYSTEM_AUTODETECT_PDH); 48 std::wstring method = SETTINGS_GET_STRING(check_system::CPU_METHOD); 49 50 if (method == setting_keys::check_system::CPU_METHOD_PDH_MANUAL) { 51 NSC_DEBUG_MSG_STD(_T("Autodetect disabled from nsc.ini via: ") + SETTINGS_MAKE_NAME(check_system::CPU_METHOD)); 50 52 return false; 51 53 } 52 54 std::wstring prefix; 53 std::wstring section = NSCModuleHelper::getSettingsString(C_SYSTEM_SECTION_TITLE, C_SYSTEM_FORCE_LANGUAGE, C_SYSTEM_FORCE_LANGUAGE_DEFAULT); 54 int noIndex = NSCModuleHelper::getSettingsInt(C_SYSTEM_SECTION_TITLE, C_SYSTEM_NO_INDEX, C_SYSTEM_NO_INDEX_DEFAULT); 55 std::wstring section = SETTINGS_GET_STRING(check_system::FORCE_LANGUAGE); 55 56 bool bUseIndex = false; 56 57 … … 60 61 if (!systemInfo::isNTBased(osVer)) { 61 62 NSC_LOG_ERROR_STD(_T("Detected Windows 3.x or Windows 9x, PDH will be disabled.")); 62 NSC_LOG_ERROR_STD(_T("To manual set performance counters you need to first set ") C_SYSTEM_AUTODETECT_PDH _T("=0 in the config file, and then you also need to configure the various counter."));63 NSC_LOG_ERROR_STD(_T("To manual set performance counters you need to first setup ") + SETTINGS_MAKE_NAME(check_system::CPU_METHOD) + _T(", and then you also need to configure the various counter.")); 63 64 return false; 64 65 } … … 77 78 } else { 78 79 NSC_LOG_ERROR_STD(_T("Unknown OS detected, PDH will be disabled.")); 79 NSC_LOG_ERROR_STD(_T("To manual set performance counters you need to first set ") C_SYSTEM_AUTODETECT_PDH _T("=0in the config file, and then you also need to configure the various counter."));80 NSC_LOG_ERROR_STD(_T("To manual set performance counters you need to first set ") + SETTINGS_MAKE_NAME(check_system::CPU_METHOD) + _T(" in the config file, and then you also need to configure the various counter.")); 80 81 return false; 81 82 } … … 87 88 section = _T("0x") + section.substr(section.length()-4); 88 89 } 89 if (bUseIndex&& noIndex==1) {90 NSC_DEBUG_MSG_STD(_T("We wanted to use index but were forced not to use them due to: ") + C_SYSTEM_NO_INDEX);90 if (bUseIndex&&(method==setting_keys::check_system::CPU_METHOD_PDH_NO_INDEX)) { 91 NSC_DEBUG_MSG_STD(_T("We wanted to use index but were forced not to use them due to: ") + SETTINGS_MAKE_NAME(check_system::CPU_METHOD)); 91 92 bUseIndex = false; 92 93 } 93 94 } catch (const systemInfo::SystemInfoException &e) { 94 NSC_LOG_ERROR_STD(_T("To manual set performance counters you need to first set ") C_SYSTEM_AUTODETECT_PDH _T("=0in the config file, and then you also need to configure the various counter."));95 NSC_LOG_ERROR_STD(_T("To manual set performance counters you need to first set ") + SETTINGS_MAKE_NAME(check_system::CPU_METHOD) + _T(" in the config file, and then you also need to configure the various counter.")); 95 96 NSC_LOG_ERROR_STD(_T("The Error: ") + e.getError()); 96 97 return false; 97 98 } catch (...) { 98 NSC_LOG_ERROR_STD(_T("To manual set performance counters you need to first set ") C_SYSTEM_AUTODETECT_PDH _T("=0in the config file, and then you also need to configure the various counter."));99 NSC_LOG_ERROR_STD(_T("To manual set performance counters you need to first set ") + SETTINGS_MAKE_NAME(check_system::CPU_METHOD) + _T(" in the config file, and then you also need to configure the various counter.")); 99 100 NSC_LOG_ERROR_STD(_T("The Error: UNKNOWN_EXCEPTION")); 100 101 return false; … … 127 128 memCl = settings.getString(section, prefix + _T("_") + C_SYSTEM_MEM_PAGE_LIMIT, C_SYSTEM_MEM_PAGE_LIMIT_DEFAULT); 128 129 memCb = settings.getString(section, prefix + _T("_") + C_SYSTEM_MEM_PAGE, C_SYSTEM_MEM_PAGE_DEFAULT); 130 */ 129 131 } 130 132 NSC_DEBUG_MSG_STD(_T("Found countername: CPU: ") + proc); … … 176 178 NSC_DEBUG_MSG_STD(_T("We aparently failed to load counters trying to use default (English) counters or those configured in nsc.ini")); 177 179 SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT)); 178 pdh.addCounter( NSCModuleHelper::getSettingsString(C_SYSTEM_SECTION_TITLE, C_SYSTEM_MEM_PAGE_LIMIT, C_SYSTEM_MEM_PAGE_LIMIT_DEFAULT), &memCmtLim);179 pdh.addCounter( NSCModuleHelper::getSettingsString(C_SYSTEM_SECTION_TITLE, C_SYSTEM_MEM_PAGE, C_SYSTEM_MEM_PAGE_DEFAULT), &memCmt);180 pdh.addCounter( NSCModuleHelper::getSettingsString(C_SYSTEM_SECTION_TITLE, C_SYSTEM_UPTIME, C_SYSTEM_UPTIME_DEFAULT), &upTime);181 pdh.addCounter( NSCModuleHelper::getSettingsString(C_SYSTEM_SECTION_TITLE, C_SYSTEM_CPU, C_SYSTEM_MEM_CPU_DEFAULT), &cpu);180 pdh.addCounter(SETTINGS_GET_STRING(check_system::PDH_MEM_CMT_LIM), &memCmtLim); 181 pdh.addCounter(SETTINGS_GET_STRING(check_system::PDH_MEM_CMT_BYT), &memCmt); 182 pdh.addCounter(SETTINGS_GET_STRING(check_system::PDH_SYSUP), &upTime); 183 pdh.addCounter(SETTINGS_GET_STRING(check_system::PDH_CPU), &cpu); 182 184 try { 183 185 pdh.open(); -
modules/CheckSystem/stdafx.h
rb0ae738 r7f9c823 35 35 #include <list> 36 36 #include <NSCAPI.h> 37 #include <nsc_module_wrapper.hpp> 37 38 #include <NSCHelper.h> 38 39 #include <config.h>
Note: See TracChangeset
for help on using the changeset viewer.








