Changeset cad08fb in nscp for modules/CheckHelpers
- Timestamp:
- 02/18/10 12:22:51 (3 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- b0e7ecf
- Parents:
- 60375ed
- Location:
- modules/CheckHelpers
- Files:
-
- 3 edited
-
CheckHelpers.cpp (modified) (7 diffs)
-
CheckHelpers.h (modified) (2 diffs)
-
stdafx.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
modules/CheckHelpers/CheckHelpers.cpp
rb4110d8 rcad08fb 35 35 bool CheckHelpers::loadModule(NSCAPI::moduleLoadMode mode) { 36 36 try { 37 NSCModuleHelper::registerCommand(_T("CheckAlwaysOK"), _T("Run another check and regardless of its return code return OK."));38 NSCModuleHelper::registerCommand(_T("CheckAlwaysCRITICAL"), _T("Run another check and regardless of its return code return CRIT."));39 NSCModuleHelper::registerCommand(_T("CheckAlwaysWARNING"), _T("Run another check and regardless of its return code return WARN."));40 NSCModuleHelper::registerCommand(_T("CheckMultiple"), _T("Run more then one check and return the worst state."));41 NSCModuleHelper::registerCommand(_T("CheckOK"), _T("Just return OK (anything passed along will be used as a message)."));42 NSCModuleHelper::registerCommand(_T("check_ok"), _T("Just return OK (anything passed along will be used as a message)."));43 NSCModuleHelper::registerCommand(_T("CheckWARNING"), _T("Just return WARN (anything passed along will be used as a message)."));44 NSCModuleHelper::registerCommand(_T("CheckCRITICAL"), _T("Just return CRIT (anything passed along will be used as a message)."));45 NSCModuleHelper::registerCommand(_T("CheckVersion"), _T("Just return the nagios version (along with OK status)."));46 } catch ( NSCModuleHelper::NSCMHExcpetion &e) {37 GET_CORE()->registerCommand(_T("CheckAlwaysOK"), _T("Run another check and regardless of its return code return OK.")); 38 GET_CORE()->registerCommand(_T("CheckAlwaysCRITICAL"), _T("Run another check and regardless of its return code return CRIT.")); 39 GET_CORE()->registerCommand(_T("CheckAlwaysWARNING"), _T("Run another check and regardless of its return code return WARN.")); 40 GET_CORE()->registerCommand(_T("CheckMultiple"), _T("Run more then one check and return the worst state.")); 41 GET_CORE()->registerCommand(_T("CheckOK"), _T("Just return OK (anything passed along will be used as a message).")); 42 GET_CORE()->registerCommand(_T("check_ok"), _T("Just return OK (anything passed along will be used as a message).")); 43 GET_CORE()->registerCommand(_T("CheckWARNING"), _T("Just return WARN (anything passed along will be used as a message).")); 44 GET_CORE()->registerCommand(_T("CheckCRITICAL"), _T("Just return CRIT (anything passed along will be used as a message).")); 45 GET_CORE()->registerCommand(_T("CheckVersion"), _T("Just return the nagios version (along with OK status).")); 46 } catch (nscapi::nscapi_exception &e) { 47 47 NSC_LOG_ERROR_STD(_T("Failed to register command: ") + e.msg_); 48 48 } catch (...) { … … 65 65 NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 66 66 if (arguments.empty()) { 67 message = NSCHelper::translateReturn(status) + _T(": Lets pretend everything is going to be ok.");67 message = nscapi::plugin_helper::translateReturn(status) + _T(": Lets pretend everything is going to be ok."); 68 68 return status; 69 69 } … … 76 76 NSCAPI::nagiosReturn CheckHelpers::handleCommand(const std::wstring command, std::list<std::wstring> arguments, std::wstring &message, std::wstring &perf) { 77 77 if (command == _T("CheckVersion")) { 78 message = NSCModuleHelper::getApplicationVersionString();78 message = GET_CORE()->getApplicationVersionString(); 79 79 return NSCAPI::returnOK; 80 80 } else if (command == _T("CheckAlwaysOK")) { … … 84 84 } 85 85 std::wstring new_command = arguments.front(); arguments.pop_front(); 86 NSCModuleHelper::InjectSimpleCommand(new_command, arguments, message, perf);86 GET_CORE()->InjectSimpleCommand(new_command, arguments, message, perf); 87 87 return NSCAPI::returnOK; 88 } else if (command == _T("CheckVersion")) {89 message = NSCModuleHelper::getApplicationVersionString();90 return NSCAPI::returnOK;91 } else if (command == _T("CheckOK")) {92 return checkSimpleStatus(NSCAPI::returnOK, arguments, message, perf);93 } else if (command == _T("CheckWARNING")) {94 return checkSimpleStatus(NSCAPI::returnWARN, arguments, message, perf);95 } else if (command == _T("CheckCRITICAL")) {96 return checkSimpleStatus(NSCAPI::returnCRIT, arguments, message, perf);97 88 } else if (command == _T("CheckAlwaysCRITICAL")) { 98 89 if (arguments.size() < 1) { … … 101 92 } 102 93 std::wstring new_command = arguments.front(); arguments.pop_front(); 103 NSCModuleHelper::InjectSimpleCommand(new_command, arguments, message, perf);94 GET_CORE()->InjectSimpleCommand(new_command, arguments, message, perf); 104 95 return NSCAPI::returnCRIT; 105 96 } else if (command == _T("CheckAlwaysWARNING")) { … … 109 100 } 110 101 std::wstring new_command = arguments.front(); arguments.pop_front(); 111 NSCModuleHelper::InjectSimpleCommand(new_command, arguments, message, perf);102 GET_CORE()->InjectSimpleCommand(new_command, arguments, message, perf); 112 103 return NSCAPI::returnWARN; 113 104 } else if (command == _T("CheckOK")) { … … 153 144 std::list<std::wstring> sub_args; 154 145 std::wstring tMsg, tPerf; 155 NSCAPI::nagiosReturn tRet = NSCModuleHelper::InjectSimpleCommand((*cit2).first.c_str(), (*cit2).second, tMsg, tPerf);156 returnCode = NSCHelper::maxState(returnCode, tRet);146 NSCAPI::nagiosReturn tRet = GET_CORE()->InjectSimpleCommand((*cit2).first.c_str(), (*cit2).second, tMsg, tPerf); 147 returnCode = nscapi::plugin_helper::maxState(returnCode, tRet); 157 148 if (!message.empty()) 158 149 message += _T(", "); -
modules/CheckHelpers/CheckHelpers.h
rb4110d8 rcad08fb 23 23 #include <strEx.h> 24 24 25 class CheckHelpers : public NSCModuleHelper::SimpleCommand {25 class CheckHelpers : public nscapi::impl::SimpleCommand { 26 26 private: 27 27 … … 37 37 return _T("Helper function"); 38 38 } 39 NSCModuleWrapper::module_version getModuleVersion() {40 NSCModuleWrapper::module_version version = {0, 3, 0 };39 nscapi::plugin_wrapper::module_version getModuleVersion() { 40 nscapi::plugin_wrapper::module_version version = {0, 3, 0 }; 41 41 return version; 42 42 } -
modules/CheckHelpers/stdafx.h
rd05c3f0 rcad08fb 28 28 29 29 #include <NSCAPI.h> 30 #include <nsc_module_wrapper.hpp> 31 #include <NSCHelper.h> 30 #include <nscapi/plugin.hpp> 32 31
Note: See TracChangeset
for help on using the changeset viewer.








