Changeset 9661f81 in nscp


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
Files:
10 added
17 edited

Legend:

Unmodified
Added
Removed
  • AutoBuild.h

    rd1029bd r9661f81  
    33// change the FALSE to TRUE for autoincrement of build number 
    44#define INCREMENT_VERSION TRUE 
    5 #define FILEVER        0,3,8,46 
    6 #define PRODUCTVER     0,3,8,46 
    7 #define STRFILEVER     _T("0.3.8.46") 
    8 #define STRPRODUCTVER  _T("0.3.8.46") 
    9 #define STRPRODUCTDATE  _T("2010-04-21") 
     5#define FILEVER        0,3,8,64 
     6#define PRODUCTVER     0,3,8,64 
     7#define STRFILEVER     _T("0.3.8.64") 
     8#define STRPRODUCTVER  _T("0.3.8.64") 
     9#define STRPRODUCTDATE  _T("2010-05-10") 
    1010#endif // AUTOBUILD_H 
  • Jamroot

    r9bb220f r9661f81  
    182182    ; 
    183183local all-scripts-lst ; 
     184all-script-libs = 
     185    [ MATCH .*scripts/lib/(.+\\..*) : [ glob scripts/lib/* ] ] 
     186    ; 
     187local all-script-libs-lst ; 
    184188if $(toolset) = "msvc" { 
    185189  if ! ( [ bjam/lua.isEnabled ] = true ) { 
     
    229233    all-scripts-lst = $(all-scripts-lst) scripts/$(l) ; 
    230234  } 
     235  for local l in $(all-script-libs) { 
     236    all-script-libs-lst = $(all-script-libs-lst) scripts/lib/$(l) ; 
     237  } 
    231238} else { 
    232239  all-installers = 
     
    265272explicit all-scripts-targets ; 
    266273 
     274alias all-script-libs-targets : $(all-script-libs-lst) ; 
     275explicit all-script-libs-targets ; 
     276 
    267277alias all-root-targets : $(target) $(target-config) $(target-readme) $(target-guide) $(target-refman) $(target-license) $(target-changelog) $(target-counters) helpers/systray_helper ; 
    268278explicit all-root-targets ; 
     
    307317  return <location>$(BOOST_STAGE_LOCATE)/$(tag)/binaries/scripts ; 
    308318} 
     319rule generate-script-libs-location ( properties * ) 
     320{ 
     321  local tag = [ get-root-prefix $(properties) ] ; 
     322  return <location>$(BOOST_STAGE_LOCATE)/$(tag)/binaries/scripts/lib ; 
     323} 
    309324rule generate-module-location ( properties * ) 
    310325{ 
     
    325340explicit dist-scripts ; 
    326341 
    327 alias build-binaries : dist dist-modules dist-helpers dist-scripts ; 
     342install dist-script-libs : all-script-libs-targets : <conditional>@generate-script-libs-location ; 
     343explicit dist-script-libs ; 
     344 
     345alias build-binaries : dist dist-modules dist-helpers dist-scripts dist-script-libs ; 
    328346explicit build-binaries ; 
    329347 
  • NSC.dist

    r42ff14d r9661f81  
    184184;script_dir=c:\my\script\dir 
    185185 
     186[Script Wrappings] 
     187vbs=cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs %SCRIPT% %ARGS% 
     188ps1=cmd /c echo scripts\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command - 
     189bat=scripts\%SCRIPT% %ARGS% 
     190 
    186191[External Scripts] 
    187192;check_es_long=scripts\long.bat 
     
    202207alias_file_size=checkFile2 filter=out "file=$ARG1$" filter-size=>$ARG2$ MaxWarn=1 MaxCrit=1 "syntax=%filename% %size%" 
    203208alias_file_size_in_dir=checkFile2 filter=out pattern=*.txt "file=$ARG1$" filter-size=>$ARG2$ MaxWarn=1 MaxCrit=1 "syntax=%filename% %size%" 
    204 alias_event_log=CheckEventLog file=application file=system filter=new filter=out MaxWarn=1 MaxCrit=1 filter-generated=>2d filter-severity==success filter-severity==informational truncate=1023 unique descriptions  "syntax=%severity%: %source%: %message% (%count%)" 
    205 alias_event_log2=CheckEventLog file=application file=system filter=new filter=in MaxWarn=1 MaxCrit=1 filter+generated=<2d "filter+eventSource==Service Control Manager" filter+severity==error truncate=1023 unique descriptions  "syntax=%severity%: %source%: %message% (%count%)" 
     209alias_event_log_old=CheckEventLog file=application file=system filter=new filter=out MaxWarn=1 MaxCrit=1 filter-generated=>2d filter-severity==success filter-severity==informational truncate=800 unique descriptions  "syntax=%severity%: %source%: %message% (%count%)" 
     210alias_event_log_new=CheckEventLog file=application file=system MaxWarn=1 MaxCrit=1 "filter=generated gt -2d AND severity NOT IN ('success', 'informational')" truncate=800 unique descriptions "syntax=%severity%: %source%: %message% (%count%)" 
     211alias_event_log=alias_event_log_new 
     212 
    206213check_ok=CheckOK Everything is fine! 
    207214 
     215[Wrapped Scripts] 
     216;check_test_vbs=check_test.vbs /arg1:1 /arg2:1 /variable:1 
     217;check_test_ps1=check_test.ps1 arg1 arg2 
     218;check_test_bat=check_test.bat arg1 arg2 
     219;check_battery=check_battery.vbs 
     220;check_printer=check_printer.vbs 
    208221 
    209222 
  • NSClient++.cpp

    r5b10435 r9661f81  
    408408    } else if ( _wcsicmp( _T("noboot"), argv[1]+1 ) == 0 ) { 
    409409      g_bConsoleLog = true; 
    410       mainClient.enableDebug(false); 
    411       mainClient.initCore(false); 
    412       int nRetCode = -1; 
    413       if (argc>=4) 
    414         nRetCode = mainClient.commandLineExec(argv[2], argv[3], argc-4, &argv[4]); 
    415       else if (argc>=3) 
    416         nRetCode = mainClient.commandLineExec(argv[2], argv[3], 0, NULL); 
    417       mainClient.exitCore(false); 
     410      try { 
     411        mainClient.enableDebug(false); 
     412        mainClient.initCore(false); 
     413        int nRetCode = -1; 
     414        if (argc>=4) 
     415          nRetCode = mainClient.commandLineExec(argv[2], argv[3], argc-4, &argv[4]); 
     416        else if (argc>=3) 
     417          nRetCode = mainClient.commandLineExec(argv[2], argv[3], 0, NULL); 
     418        else 
     419          std::wcerr << _T("No arguments specified...") << std::endl; 
     420        mainClient.exitCore(false); 
     421      } catch (...) { 
     422        std::wcerr << _T("Unknown error...") << std::endl; 
     423      } 
    418424      return nRetCode; 
    419425    } else if ( _wcsicmp( _T("svc"), argv[1]+1 ) == 0 ) { 
  • changelog

    rd1029bd r9661f81  
    66 * Fix depend onservice LanManWorkStation (old win) 
    77 * Fix RtlStringFromGUID problem on NT4 
     8 
     92010-05-10 MickeM - 0.3.8 RC2 
     10 * Fixed issue with listpdh and debugpdh (not works again) 
     11 + Fixed issue and added support for IN ( ... ) and NOT IN ( ... ) operators (CheckEventLog) 
     12 
     132010-05-08 MickeM 
     14 + Added new "script templating" thing to simplify adding scripts: 
     15   Two new sections: [Script Wrappings] for adding templates and [Wrapped Scripts] for adding the scripts. 
     16    %SCRIPT% is replaced with the script name 
     17    %ARGS% is replaced with arguments. 
     18     vbs=cscript.exe //T:30 //NoLogo scripts\wrapper.vbs %SCRIPT% %ARGS% 
     19    and 
     20     w_vbs=check_test.vbs /arg1:1 /arg2:1 /variable:1 
     21    is the same as: 
     22     w_vbs=cscript.exe //T:30 //NoLogo scripts\wrapper.vbs check_test.vbs /arg1:1 /arg2:1 /variable:1 
     23 * Added correct syntax for VB scripts 
     24 * Added correct syntax for powershell scripts 
     25 * Cleaned up scripts folder 
     26 + Added new "NagiosPlugin library" from op5 
     27 + Added check_no_rdp.vbs (Checks that no RDP connection is online) 
     28 + Added check_battery.vbs which checks batterys via WMI 
     29 + Added check_printer.vbs to check printers via WMI 
    830 
    9312010-04-21 MickeM - 0.3.8 RC1 
     
    6688  
    67892010-02-26 MickeM 
    68  * Changed fo missing files and such generate an error 
     90 * Changed so missing files and such generate an error 
    6991 * Added option to return error messages to the client [CheckDisk] show_errors=1 (defauilt is off 0) 
    7092 * Added warning message ewhen numerical filters evaluate to zero (and are not 0) 
  • helpers/installer/Product.wxs

    r3d782f8 r9661f81  
    150150              </Component> 
    151151            </Directory> 
    152             <Directory Id="INSTALLLOCATION_SCRIPTS" Name="scripts"> 
    153               <Component Id="Scripts" Guid="9B490E67-5472-4267-96DC-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
    154                 <File Id="scriptargs.bat" Name="args.bat" LongName="args.bat" DiskId="1" Source="$(var.Source)/scripts/args.bat" Vital="no" /> 
    155                 <File Id="scriptcheck_vb.vbs" Name="check_vb.vbs" LongName="check_vb.vbs" DiskId="1" Source="$(var.Source)/scripts/check_vb.vbs" Vital="no" /> 
    156                 <File Id="scriptcritical.bat" Name="critical.bat" LongName="critical.bat" DiskId="1" Source="$(var.Source)/scripts/critical.bat" Vital="no" /> 
    157                 <File Id="scriptmulti_line.bat" Name="mline.bat" LongName="multi_line.bat" DiskId="1" Source="$(var.Source)/scripts/multi_line.bat" Vital="no" /> 
    158                 <File Id="scriptok.bat" Name="ok.bat" LongName="ok.bat" DiskId="1" Source="$(var.Source)/scripts/ok.bat" Vital="no" /> 
    159                 <File Id="scriptpowershell.ps1" Name="pwrshell.ps1" LongName="powershell.ps1" DiskId="1" Source="$(var.Source)/scripts/powershell.ps1" Vital="no" /> 
    160                 <File Id="scripttest.lua" Name="test.lua" LongName="test.lua" DiskId="1" Source="$(var.Source)/scripts/test.lua" Vital="no" /> 
    161               </Component> 
     152            <Directory Id="INSTALLLOCATION_SCRIPTS" Name="scripts"> 
     153              <Component Id="Scripts" Guid="9B490E67-5472-4268-96DF-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     154                <File Id="script001" Name="c_60s.bat" LongName="check_60s.bat" DiskId="1" Source="$(var.Source)/scripts/check_60s.bat" Vital="no" /> 
     155                <File Id="script002" Name="c_btry.vbs" LongName="check_battery.vbs" DiskId="1" Source="$(var.Source)/scripts/check_battery.vbs" Vital="no" /> 
     156                <File Id="script003" Name="c_nrdb.bat" LongName="check_no_rdp.bat" DiskId="1" Source="$(var.Source)/scripts/check_no_rdp.bat" Vital="no" /> 
     157                <File Id="script004" Name="c_prt.vbs" LongName="check_printer.vbs" DiskId="1" Source="$(var.Source)/scripts/check_printer.vbs" Vital="no" /> 
     158                <File Id="script005" Name="c_ok.bat" LongName="check_ok.bat" DiskId="1" Source="$(var.Source)/scripts/check_ok.bat" Vital="no" /> 
     159                <File Id="sample001" Name="c_test.bat" LongName="check_test.bat" DiskId="1" Source="$(var.Source)/scripts/check_test.bat" Vital="no" /> 
     160                <File Id="sample002" Name="c_test.ps1" LongName="check_test.ps1" DiskId="1" Source="$(var.Source)/scripts/check_test.ps1" Vital="no" /> 
     161                <File Id="sample003" Name="c_test.vbs" LongName="check_test.vbs" DiskId="1" Source="$(var.Source)/scripts/check_test.vbs" Vital="no" /> 
     162                <File Id="lua001" Name="test.lua" LongName="test.lua" DiskId="1" Source="$(var.Source)/scripts/test.lua" Vital="no" /> 
     163              </Component> 
     164              <Directory Id="INSTALLLOCATION_SCRIPTS_LIB" Name="lib"> 
     165                <Component Id="ScriptLibs" Guid="9B490E67-5472-4267-96DF-$(var.Postfix.GUID)" Win64="$(var.Win64)"> 
     166                  <File Id="lib001" Name="nagplug.vbs" LongName="NagiosPlugins.vbs" DiskId="1" Source="$(var.Source)/scripts/lib/NagiosPlugins.vbs" Vital="no" /> 
     167                  <File Id="lib002" Name="wrapper.vbs" LongName="wrapper.vbs" DiskId="1" Source="$(var.Source)/scripts/lib/wrapper.vbs" Vital="no" /> 
     168                </Component> 
     169              </Directory> 
    162170            </Directory> 
    163171          </Directory> 
     
    200208        <Feature Id="SampleScripts" Title="Sample Scripts" Description="Some sample client-side scripts to use with NRPE" Level="1" Absent="disallow"> 
    201209          <ComponentRef Id="Scripts" /> 
    202         </Feature> 
     210          <ComponentRef Id="ScriptLibs" /> 
     211        </Feature> 
    203212      </Feature> 
    204213    </Feature> 
  • helpers/installer_dll_fw/firewall.cpp

    r8170e81 r9661f81  
    443443        case msi_helper::WCA_TODO_INSTALL: 
    444444        case msi_helper::WCA_TODO_REINSTALL: 
    445           h.logMessage(_T("Installing firewall exception: ") + name + _T(", ") + file); 
    446           AddApplicationException(file, name, remote_addr, fIgnoreFailures); 
     445          try { 
     446            h.logMessage(_T("Installing firewall exception: ") + name + _T(", ") + file); 
     447            AddApplicationException(file, name, remote_addr, fIgnoreFailures); 
     448          } catch (installer_exception &e) { 
     449            h.logMessage(_T("Failed to install firewall exception: ") + name + _T(", ") + e.what()); 
     450          } catch (...) { 
     451            h.logMessage(_T("Failed to install firewall exception: ") + name); 
     452          } 
    447453          break; 
    448454 
    449455        case msi_helper::WCA_TODO_UNINSTALL: 
    450456          h.logMessage(_T("Uninstalling firewall exception: ") + name + _T(", ") + file); 
    451           RemoveApplicationException(file, fIgnoreFailures); 
     457          try { 
     458            RemoveApplicationException(file, fIgnoreFailures); 
     459          } catch (installer_exception &e) { 
     460            h.logMessage(_T("Failed to un-install firewall exception: ") + name + _T(", ") + e.what()); 
     461          } catch (...) { 
     462            h.logMessage(_T("Failed to un-install firewall exception: ") + name); 
     463          } 
    452464          break; 
    453465        default: 
  • include/config.h

    r9bb220f r9661f81  
    117117#define EXTSCRIPT_ALIAS_SECTION_TITLE _T("External Alias") 
    118118#define EXTSCRIPT_SETTINGS_TIMEOUT _T("command_timeout") 
     119#define EXTSCRIPT_WRAPPINGS_SECTION_TITLE _T("Script Wrappings") 
     120#define EXTSCRIPT_WRAPPED_SCRIPT_SECTION_TITLE _T("Wrapped Scripts") 
    119121#define EXTSCRIPT_SETTINGS_TIMEOUT_DEFAULT 60 
    120122#define EXTSCRIPT_SETTINGS_ALLOW_ARGUMENTS _T("allow_arguments") 
  • include/parsers/ast.cpp

    redf0848 r9661f81  
    7373 
    7474      bool operator()(binary_op<THandler> & expr) { 
     75        //std::wcout << "force_bin_op" << std::endl; 
    7576        expr.left.force_type(type); 
    7677        expr.right.force_type(type); 
     
    7879      } 
    7980      bool operator()(unary_op<THandler> & expr) { 
     81        //std::wcout << "force_un_op" << std::endl; 
    8082        expr.subject.force_type(type); 
    8183        return true; 
     
    8385 
    8486      bool operator()(unary_fun<THandler> & expr) { 
     87        //std::wcout << "force_fun" << std::endl; 
    8588        if (expr.is_transparent(type)) 
    8689          expr.subject.force_type(type); 
     
    8992 
    9093      bool operator()(list_value<THandler> & expr) { 
    91         BOOST_FOREACH(expression_ast<THandler> e, expr.list) { 
     94        BOOST_FOREACH(expression_ast<THandler> &e, expr.list) { 
    9295          e.force_type(type); 
    9396          //boost::apply_visitor(*this, e.expr); 
    9497        } 
    95         return false; 
     98        return true; 
    9699      } 
    97100 
     
    105108    template<typename THandler> 
    106109    void expression_ast<THandler>::force_type(value_type newtype) { 
    107       std::wcout << _T("Forcing type: ") << type_to_string(type) << _T(" to ") << type_to_string(newtype) << _T(" for ") << to_string() << std::endl; 
     110      //std::wcout << _T("Forcing type: ") << type_to_string(type) << _T(" to ") << type_to_string(newtype) << _T(" for ") << to_string() << std::endl; 
    108111      if (type == newtype) 
    109112        return; 
     
    114117        expr = unary_fun<THandler>(_T("auto_convert"), subnode); 
    115118        type = newtype; 
     119        //std::wcout << _T("Forcing type (D1): ") << type_to_string(type) << _T(" to ") << type_to_string(newtype) << _T(" for ") << to_string() << std::endl; 
    116120        return; 
    117121      } 
     
    120124        set_type(newtype); 
    121125      } 
     126      //std::wcout << _T("Forcing type (D2): ") << type_to_string(type) << _T(" to ") << type_to_string(newtype) << _T(" for ") << to_string() << std::endl; 
    122127    } 
    123128 
     
    163168        result << _T(" { "); 
    164169        BOOST_FOREACH(const expression_ast<THandler> e, expr.list) { 
    165           boost::apply_visitor(*this, e.expr); 
     170          operator()(e); 
     171          //boost::apply_visitor(*this, e.expr); 
    166172          result << _T(", "); 
    167173        } 
     
    421427    template<typename THandler> 
    422428    expression_ast<THandler> binary_op<THandler>::evaluate(THandler &handler) const { 
    423       factory<THandler>::bin_op_type impl = factory<THandler>::get_binary_operator(op); 
     429      factory<THandler>::bin_op_type impl = factory<THandler>::get_binary_operator(op, left, right); 
    424430      if (get_return_type(op, type_invalid) == type_bool) { 
    425431        return impl->evaluate(handler, left, right); 
  • include/parsers/ast.hpp

    redf0848 r9661f81  
    123123      if (identifier == op_le) 
    124124        return _T("<="); 
     125      if (identifier == op_in) 
     126        return _T("in"); 
     127      if (identifier == op_nin) 
     128        return _T("not in"); 
    125129      return _T("?"); 
    126130    } 
  • include/parsers/eval.hpp

    redf0848 r9661f81  
    77      struct simple_bool_binary_operator_impl : public binary_operator_impl<THandler> { 
    88        expression_ast<THandler> evaluate(THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
    9           if (left.get_type() != right.get_type()) { 
     9          value_type ltype = left.get_type(); 
     10          value_type rtype = right.get_type(); 
     11 
     12          if ( (ltype != rtype) && (rtype != type_tbd) ) { 
    1013            handler.error(_T("Invalid types (not same) for binary operator")); 
    1114            return expression_ast<THandler>(int_value(FALSE)); 
     
    114117          //  std::wcout << _T("Found: ") << s1 << _T(" in ") << s2 << std::endl; 
    115118          return res; 
     119        }; 
     120      }; 
     121      template<typename THandler> 
     122      struct operator_not_in : public simple_bool_binary_operator_impl<THandler> { 
     123 
     124        typedef typename expression_ast<THandler>::list_type list_type; 
     125        typedef typename expression_ast<THandler> list_item_type; 
     126        typename expression_ast<THandler>::list_type list; 
     127        operator_not_in(const expression_ast<THandler> &subject) : list(subject.get_list()) {} 
     128 
     129        bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     130          long long val = left.get_int(handler); 
     131          BOOST_FOREACH(list_item_type itm, list) { 
     132            if (itm.get_int(handler) == val) 
     133              return false; 
     134          } 
     135          return true; 
     136        } 
     137        bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     138          std::wstring val = left.get_string(handler); 
     139          BOOST_FOREACH(list_item_type itm, list) { 
     140            if (itm.get_string(handler) == val) 
     141              return false; 
     142          } 
     143          return true; 
     144        }; 
     145      }; 
     146      template<typename THandler> 
     147      struct operator_in : public simple_bool_binary_operator_impl<THandler> { 
     148 
     149        typedef typename expression_ast<THandler>::list_type list_type; 
     150        typedef typename expression_ast<THandler> list_item_type; 
     151        typename expression_ast<THandler>::list_type list; 
     152        operator_in(const expression_ast<THandler> &subject) : list(subject.get_list()) {} 
     153 
     154        bool eval_int(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     155          long long val = left.get_int(handler); 
     156          BOOST_FOREACH(list_item_type itm, list) { 
     157            if (itm.get_int(handler) == val) 
     158              return true; 
     159          } 
     160          return false; 
     161        } 
     162        bool eval_string(value_type type, THandler &handler, const expression_ast<THandler> &left, const expression_ast<THandler> & right) const { 
     163          std::wstring val = left.get_string(handler); 
     164          BOOST_FOREACH(list_item_type itm, list) { 
     165            if (itm.get_string(handler) == val) 
     166              return true; 
     167          } 
     168          return false; 
    116169        }; 
    117170      }; 
     
    226279    } 
    227280    template<typename THandler> 
    228     typename factory<THandler>::bin_op_type factory<THandler>::get_binary_operator(operators op) { 
     281    typename factory<THandler>::bin_op_type factory<THandler>::get_binary_operator(operators op, const expression_ast<THandler> &left, const expression_ast<THandler> &right) { 
    229282      // op_in, op_nin 
    230283      if (op == op_eq) 
     
    247300      if (op == op_or) 
    248301        return bin_op_type(new operator_impl::operator_or<THandler>()); 
     302      if (op == op_in) 
     303        return bin_op_type(new operator_impl::operator_in<THandler>(right)); 
     304      if (op == op_nin) 
     305        return bin_op_type(new operator_impl::operator_not_in<THandler>(right)); 
    249306      std::cout << "======== UNHANDLED OPERATOR\n"; 
    250307      return bin_op_type(new operator_impl::operator_false<THandler>()); 
  • include/parsers/where.cpp

    redf0848 r9661f81  
    3737 
    3838      value_type operator()(expression_ast<THandler> & ast) { 
     39        //std::wcout << _T(">>>Setting type: ") << ast.to_string() << _T(" to: ") << ast.get_type() << std::endl; 
    3940        value_type type = ast.get_type(); 
     41        //std::wcout << _T("!!!Setting type: ") << ast.to_string() << _T(" to: ") << type << std::endl; 
    4042        if (type != type_tbd) 
    4143          return type; 
    4244        type = boost::apply_visitor(*this, ast.expr); 
    4345        ast.set_type(type); 
     46        //std::wcout << _T("<<<Setting type: ") << ast.to_string() << _T(" to: ") << ast.get_type() << std::endl; 
    4447        return type; 
    4548      } 
     
    7174          return type_tbd; 
    7275        if (handler.can_convert(rt, lt)) { 
    73           std::wcout << _T("FORCE 001") << std::endl; 
     76          //std::wcout << _T("FORCE 001") << std::endl; 
    7477          right.force_type(lt); 
    7578          return lt; 
    7679        } 
    7780        if (handler.can_convert(lt, rt)) { 
    78           std::wcout << _T("FORCE 002") << std::endl; 
     81          //std::wcout << _T("FORCE 002") << std::endl; 
    7982          left.force_type(rt); 
    8083          return rt; 
    8184        } 
    8285        if (can_convert(rt, lt)) { 
    83           std::wcout << _T("FORCE 003") << std::endl; 
     86          //std::wcout << _T("FORCE 003") << std::endl; 
    8487          right.force_type(lt); 
    8588          return rt; 
    8689        } 
    8790        if (can_convert(lt, rt)) { 
    88           std::wcout << _T("FORCE 004") << std::endl; 
     91          //std::wcout << _T("FORCE 004") << std::endl; 
    8992          left.force_type(rt); 
    9093          return lt; 
     
    110113 
    111114      value_type operator()(list_value<THandler> & expr) { 
     115        BOOST_FOREACH(expression_ast<THandler> &e, expr.list) { 
     116          operator()(e); 
     117        } 
    112118        return type_tbd; 
    113119      } 
     
    171177 
    172178      bool operator()(list_value<THandler> & expr) { 
    173         // TODO: this is incorrect! 
     179        BOOST_FOREACH(expression_ast<THandler> e, expr.list) { 
     180          operator()(e); 
     181        } 
    174182        return true; 
    175183      } 
     
    218226 
    219227      bool operator()(list_value<THandler> & expr) { 
    220         BOOST_FOREACH(expression_ast<THandler> e, expr.list) { 
     228        BOOST_FOREACH(expression_ast<THandler> &e, expr.list) { 
    221229          operator()(e); 
    222230        } 
     
    242250    bool parser<THandler>::parse(std::wstring expr) { 
    243251      constants::reset(); 
    244       std::wcout << _T("Current time is: ") << constants::get_now() << std::endl; 
     252      //std::wcout << _T("Current time is: ") << constants::get_now() << std::endl; 
    245253      typedef std::wstring::const_iterator iterator_type; 
    246254      typedef where_grammar<THandler, iterator_type> grammar; 
  • include/parsers/where.hpp

    r5b10435 r9661f81  
    2626      typedef boost::shared_ptr<unary_operator_impl<typename THandler> > un_op_type; 
    2727 
    28       static bin_op_type get_binary_operator(operators op); 
     28      static bin_op_type get_binary_operator(operators op, const expression_ast<THandler> &left, const expression_ast<THandler> &right); 
     29      //static bin_op_type get_binary_operator(operators op); 
    2930      //static varible_handler::bound_function_type get_binary_function(std::wstring name, const expression_ast<THandler> &subject); 
    3031      static bin_fun_type get_binary_function(std::wstring name, const expression_ast<THandler> &subject); 
  • include/pdh/enumerations.hpp

    r42ff14d r9661f81  
    7777        TCHAR* szInstanceBuffer = NULL; 
    7878        status = PDH::PDHFactory::get_impl()->PdhEnumObjectItems(NULL, NULL, (*it).name.c_str(), szCounterBuffer, &dwCounterBufLen, szInstanceBuffer, &dwInstanceBufLen, dwDetailLevel, 0); 
    79         if (!status.is_more_data()) { 
     79        if (status.is_more_data()) { 
    8080          szCounterBuffer = new TCHAR[dwCounterBufLen+1024]; 
    8181          szInstanceBuffer = new TCHAR[dwInstanceBufLen+1024]; 
  • 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_); 
  • modules/CheckExternalScripts/CheckExternalScripts.h

    r4580c6c r9661f81  
    8080  void addAllScriptsFrom(std::wstring path); 
    8181  void addCommand(strEx::blindstr key, std::wstring cmd, std::wstring args) { 
     82    NSC_DEBUG_MSG_STD(_T("Adding: ") + cmd + _T("Args: ") + args); 
    8283    commands[key] = command_data(cmd, args); 
    8384  } 
     
    8586    alias[key] = command_data(cmd, args); 
    8687  } 
     88  std::wstring getWrapping( std::wstring val ); 
     89  void addWrappedCommand( std::wstring key, std::wstring tpl, std::wstring command ); 
    8790}; 
    8891 
  • modules/CheckSystem/CheckSystem.cpp

    rd1029bd r9661f81  
    211211        } 
    212212      } else { 
     213        if ((*it).counters.size() == 0) { 
     214          std::wcout << _T("empty counter: ") << (*it).name << std::endl; 
     215        } 
    213216        for (PDH::Enumerations::Counters::const_iterator it2 = (*it).counters.begin();it2!=(*it).counters.end();++it2) { 
    214217          std::wstring counter = _T("\\") + (*it).name + _T("\\") + (*it2).name; 
     
    235238          } 
    236239          std::wcout << _T(" open "); 
    237           std::wcout << std::endl;; 
     240          std::wcout << std::endl; 
    238241        } 
    239242      } 
Note: See TracChangeset for help on using the changeset viewer.