Changeset d656933 in nscp for modules/CheckSystem
- Timestamp:
- 04/20/05 21:08:49 (8 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2, stable
- Children:
- 945c381
- Parents:
- cea178b
- Location:
- modules/CheckSystem
- Files:
-
- 3 edited
-
CheckSystem.cpp (modified) (3 diffs)
-
CheckSystem.h (modified) (1 diff)
-
PDHCollector.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
modules/CheckSystem/CheckSystem.cpp
rcea178b rd656933 87 87 * This also handles a lot of the simpler responses (though some are deferred to other helper functions) 88 88 * 89 #define REQ_CLIENTVERSION 1 // Works fine!90 #define REQ_CPULOAD 2 // Quirks91 - Needs settings for default buffer size (backlog) and possibly other things.92 - Buffer needs to be synced with the client (don't know the size of that)93 - I think the idea was that the buffer would recursive to make a smaller memory footprint.94 (ie. the first level buffer have samples from every second, next level samples from every minute, next level hours etc...)95 (and I don't know the status of this, doesn't seem to be that way)96 #define REQ_UPTIME 3 // Works fine!97 #define REQ_USEDDISKSPACE 4 // Works fine!98 #define REQ_SERVICESTATE 5 // Works fine!99 #define REQ_PROCSTATE 6 // Works fine!100 #define REQ_MEMUSE 7 // Works fine!101 //#define REQ_COUNTER 8 // ! - not implemented Have to look at this, if anyone has a sample let me know...102 //#define REQ_FILEAGE 9 // ! - not implemented Don't know how to use103 //#define REQ_INSTANCES 10 // ! - not implemented Don't know how to use104 89 * 105 90 * @param command … … 121 106 } else if (command == "checkMem") { 122 107 return checkMem(command, argLen, char_args, msg, perf); 108 } else if (command == "checkCounter") { 109 return checkCounter(command, argLen, char_args, msg, perf); 123 110 } 124 111 /* … … 497 484 return ret; 498 485 } 486 487 NSCAPI::nagiosReturn CheckSystem::checkCounter(const std::string command, const unsigned int argLen, char **char_args, std::string &msg, std::string &perf) 488 { 489 std::list<std::string> stl_args = arrayBuffer::arrayBuffer2list(argLen, char_args); 490 if (stl_args.empty()) { 491 msg = "ERROR: Missing argument exception."; 492 return NSCAPI::returnUNKNOWN; 493 } 494 std::list<std::string> counters; 495 NSCAPI::nagiosReturn ret = NSCAPI::returnOK; 496 bool bShowAll = false; 497 bool bNSCLientCompatible = false; 498 499 for (arrayBuffer::arrayList::const_iterator it = stl_args.begin(); it != stl_args.end(); ++it) { 500 strEx::token t = strEx::getToken((*it), '='); 501 if (t.first == SHOW_ALL) 502 bShowAll = true; 503 else if (t.first == SHOW_FAIL) { 504 bShowAll = false; 505 } else if (t.first == NSCLIENT) { 506 bNSCLientCompatible = true; 507 } else if (t.first == "counter") { 508 counters.push_back(t.second); 509 } else { 510 counters.push_back(t.first); 511 } 512 } 513 514 for (std::list<std::string>::iterator it = counters.begin(); it != counters.end(); ++it) { 515 try { 516 try { 517 PDH::PDHQuery pdh; 518 PDHCollectors::StaticPDHCounterListener counter; 519 pdh.addCounter((*it), &counter); 520 pdh.open(); 521 pdh.collect(); 522 msg += strEx::itos(counter.getValue()); 523 pdh.close(); 524 } catch (const PDH::PDHException &e) { 525 NSC_LOG_ERROR_STD("ERROR: " + e.str_); 526 msg = static_cast<std::string>("ERROR: ") + e.str_; 527 return 0; 528 } 529 } catch (PDH::PDHException e) { 530 NSC_LOG_ERROR_STD("ERROR: " + e.str_); 531 msg = static_cast<std::string>("ERROR: ") + e.str_; 532 return NSCAPI::returnCRIT; 533 } 534 } 535 if (msg.empty()) 536 msg ="uhmm..."; 537 return ret; 538 } 499 539 NSC_WRAPPERS_MAIN_DEF(gNSClientCompat); 500 540 NSC_WRAPPERS_IGNORE_MSG_DEF(); -
modules/CheckSystem/CheckSystem.h
rcea178b rd656933 36 36 NSCAPI::nagiosReturn checkMem(const std::string command, const unsigned int argLen, char **char_args, std::string &msg, std::string &perf); 37 37 NSCAPI::nagiosReturn checkProcState(const std::string command, const unsigned int argLen, char **char_args, std::string &msg, std::string &perf); 38 NSCAPI::nagiosReturn checkCounter(const std::string command, const unsigned int argLen, char **char_args, std::string &msg, std::string &perf); 38 39 39 40 -
modules/CheckSystem/PDHCollector.cpp
rcea178b rd656933 113 113 int PDHCollector::getCPUAvrage(std::string time) { 114 114 unsigned int mseconds = strEx::stoui_as_time(time, checkIntervall_*100); 115 NSC_DEBUG_MSG_STD(time + " resolved to: " + strEx::itos(mseconds) + "ms (" + strEx::itos(mseconds / (checkIntervall_*100)) + "items)");116 115 MutexLock mutex(mutexHandler); 117 116 if (!mutex.hasMutex()) {
Note: See TracChangeset
for help on using the changeset viewer.








