Ignore:
Timestamp:
05/10/10 22:17:31 (3 years ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2, stable
Children:
f40d813
Parents:
d1029bd
Message:

2010-05-10 MickeM - 0.3.8 RC2

  • Fixed issue with listpdh and debugpdh (not works again) + Fixed issue and added support for IN ( ... ) and NOT IN ( ... ) operators (CheckEventLog)

2010-05-08 MickeM

+ Added new "script templating" thing to simplify adding scripts:

Two new sections: [Script Wrappings] for adding templates and [Wrapped Scripts] for adding the scripts.

%SCRIPT% is replaced with the script name
%ARGS% is replaced with arguments.

vbs=cscript.exe T:30 NoLogo scripts\wrapper.vbs %SCRIPT% %ARGS%

and

w_vbs=check_test.vbs /arg1:1 /arg2:1 /variable:1

is the same as:

w_vbs=cscript.exe T:30 NoLogo scripts\wrapper.vbs check_test.vbs /arg1:1 /arg2:1 /variable:1

  • Added correct syntax for VB scripts
  • Added correct syntax for powershell scripts
  • Cleaned up scripts folder + Added new "NagiosPlugin? library" from op5 + Added check_no_rdp.vbs (Checks that no RDP connection is online) + Added check_battery.vbs which checks batterys via WMI + Added check_printer.vbs to check printers via WMI
File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/CheckExternalScripts/CheckExternalScripts.cpp

    r4580c6c r9661f81  
    6464  } 
    6565  FindClose(hFind); 
     66} 
     67 
     68 
     69std::wstring CheckExternalScripts::getWrapping(std::wstring val) { 
     70  strEx::token tok = strEx::getToken(val, ' ', true); 
     71  std::wstring::size_type pos = tok.first.find_last_of(_T(".")); 
     72  if (pos == std::wstring::npos) 
     73    return _T(""); 
     74  return tok.first.substr(pos+1); 
     75} 
     76 
     77void CheckExternalScripts::addWrappedCommand(std::wstring key, std::wstring tpl, std::wstring command ) { 
     78  strEx::token tok = strEx::getToken(command, ' ', true); 
     79  strEx::replace(tpl, _T("%SCRIPT%"), tok.first); 
     80  strEx::replace(tpl, _T("%ARGS%"), tok.second); 
     81  tok = strEx::getToken(tpl, ' ', true); 
     82  addCommand(key.c_str(),tok.first, tok.second); 
    6683} 
    6784 
     
    96113  } 
    97114 
     115  std::map<std::wstring,std::wstring> wrappers; 
     116  std::list<std::wstring> wrappings = NSCModuleHelper::getSettingsSection(EXTSCRIPT_WRAPPINGS_SECTION_TITLE); 
     117  for (it = wrappings.begin(); it != wrappings.end(); ++it) { 
     118    std::wstring val = NSCModuleHelper::getSettingsString(EXTSCRIPT_WRAPPINGS_SECTION_TITLE, *it, _T("")); 
     119    if (!(*it).empty() && !val.empty()) { 
     120      wrappers[(*it)] = val; 
     121    } 
     122  } 
     123  std::list<std::wstring> wscript = NSCModuleHelper::getSettingsSection(EXTSCRIPT_WRAPPED_SCRIPT_SECTION_TITLE); 
     124  for (it = wrappings.begin(); it != wscript.end(); ++it) { 
     125    std::wstring val = NSCModuleHelper::getSettingsString(EXTSCRIPT_WRAPPED_SCRIPT_SECTION_TITLE, *it, _T("")); 
     126    if (!(*it).empty() && !val.empty()) { 
     127      std::wstring type = getWrapping(val); 
     128      std::map<std::wstring,std::wstring>::const_iterator cit = wrappers.find(type); 
     129      if (cit == wrappers.end()) { 
     130        NSC_LOG_ERROR_STD(_T("Failed to find wrappings for: ") + type + _T(" (" + (*it) + _T(")"))); 
     131      } else { 
     132        addWrappedCommand((*it), (*cit).second, val); 
     133      } 
     134    } 
     135  } 
     136 
    98137  if (!scriptDirectory_.empty()) { 
    99138    addAllScriptsFrom(scriptDirectory_); 
Note: See TracChangeset for help on using the changeset viewer.