Changeset cad08fb in nscp for modules/CheckHelpers


Ignore:
Timestamp:
02/18/10 12:22:51 (3 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
b0e7ecf
Parents:
60375ed
Message:

Major update with a new plugin glue that works better with *nix.
Everything should be the same but look tidier

Location:
modules/CheckHelpers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • modules/CheckHelpers/CheckHelpers.cpp

    rb4110d8 rcad08fb  
    3535bool CheckHelpers::loadModule(NSCAPI::moduleLoadMode mode) { 
    3636  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) { 
    4747    NSC_LOG_ERROR_STD(_T("Failed to register command: ") + e.msg_); 
    4848  } catch (...) { 
     
    6565  NSCAPI::nagiosReturn returnCode = NSCAPI::returnOK; 
    6666  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."); 
    6868    return status; 
    6969  } 
     
    7676NSCAPI::nagiosReturn CheckHelpers::handleCommand(const std::wstring command, std::list<std::wstring> arguments, std::wstring &message, std::wstring &perf) { 
    7777  if (command == _T("CheckVersion")) { 
    78     message = NSCModuleHelper::getApplicationVersionString(); 
     78    message = GET_CORE()->getApplicationVersionString(); 
    7979    return NSCAPI::returnOK; 
    8080  } else if (command == _T("CheckAlwaysOK")) { 
     
    8484    } 
    8585    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); 
    8787    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); 
    9788  } else if (command == _T("CheckAlwaysCRITICAL")) { 
    9889    if (arguments.size() < 1) { 
     
    10192    } 
    10293    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); 
    10495    return NSCAPI::returnCRIT; 
    10596  } else if (command == _T("CheckAlwaysWARNING")) { 
     
    109100    } 
    110101    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); 
    112103    return NSCAPI::returnWARN; 
    113104  } else if (command == _T("CheckOK")) { 
     
    153144    std::list<std::wstring> sub_args; 
    154145    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); 
    157148    if (!message.empty()) 
    158149      message += _T(", "); 
  • modules/CheckHelpers/CheckHelpers.h

    rb4110d8 rcad08fb  
    2323#include <strEx.h> 
    2424 
    25 class CheckHelpers : public NSCModuleHelper::SimpleCommand { 
     25class CheckHelpers : public nscapi::impl::SimpleCommand { 
    2626private: 
    2727 
     
    3737    return _T("Helper function"); 
    3838  } 
    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 }; 
    4141    return version; 
    4242  } 
  • modules/CheckHelpers/stdafx.h

    rd05c3f0 rcad08fb  
    2828 
    2929#include <NSCAPI.h> 
    30 #include <nsc_module_wrapper.hpp> 
    31 #include <NSCHelper.h> 
     30#include <nscapi/plugin.hpp> 
    3231 
Note: See TracChangeset for help on using the changeset viewer.