Changeset 53be5c8 in nscp


Ignore:
Timestamp:
07/12/12 07:43:42 (10 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.1, 0.4.2
Children:
c327ce5
Parents:
6090c98
Message:
  • LUAScript: Improved lua scripting module a lot
  • LUAScript: Added protocol buffer support to lua scripts
  • tests: Rewrote (halfway there) test_nrpe python script as a lua script.
  • CheckEventLog: Fixed command name when submitting real-time "no action checks"
Files:
5 added
1 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • CMakeLists.txt

    rc6a974c r53be5c8  
    5858  /usr/include/lua 
    5959) 
     60IF (LUA_INCLUE_DIR) 
     61  message(STATUS "Found lua in ${LUA_INCLUE_DIR}") 
     62  SET(HAVE_LUA TRUE PARENT_SCOPE) 
     63  SET(HAVE_LUA TRUE) 
     64  SET(LUA_SOURCE_DIR ${LUA_INCLUE_DIR}) 
     65ELSE (LUA_INCLUE_DIR) 
     66  message(STATUS "Lua was not found in LUA_INCLUE_DIR=${LUA_INCLUE_DIR}") 
     67ENDIF (LUA_INCLUE_DIR) 
     68 
    6069# ### ### ### ### 
    6170# Google breakpad 
     
    8796 
    8897INCLUDE(${BUILD_CMAKE_FOLDER}/SetMultiThread.cmake) 
    89 INCLUDE(${BUILD_CMAKE_FOLDER}/NSCPPBuffer.cmake) 
     98INCLUDE(${BUILD_CMAKE_FOLDER}/GoogleProtoBuf.cmake) 
    9099INCLUDE(${BUILD_CMAKE_FOLDER}/functions.cmake) 
    91100 
     
    107116ENDIF (TINYXML2_FOUND) 
    108117 
    109  
    110118FIND_PACKAGE(ZeroMQ) 
    111119IF (ZEROMQ_FOUND) 
     
    113121ENDIF (ZEROMQ_FOUND) 
    114122 
     123 
     124FIND_PACKAGE(GoogleProtoBuf) 
     125if(PROTOBUF_FOUND) 
     126  message(STATUS "Found proto in: ${PROTOBUF_INCLUDE_DIR} / ${PROTOBUF_LIBRARY} (${PROTOBUF_PROTOC_EXECUTABLE})") 
     127  INCLUDE_DIRECTORIES("${PROTOBUF_INCLUDE_DIR}") 
     128  IF(PROTOC_GEN_LUA_FOUND) 
     129    message(STATUS "Found lua protocol buffers (ie. advanced script support)") 
     130  ENDIF(PROTOC_GEN_LUA_FOUND) 
     131else(PROTOBUF_FOUND) 
     132  message(FATAL_ERROR "Protocol buffers NOT found (${PROTOBUF_LIBRARYDIR})") 
     133endif(PROTOBUF_FOUND) 
    115134 
    116135SET(VERSION_TXT ${CMAKE_CURRENT_SOURCE_DIR}/version.txt) 
     
    254273  MESSAGE(FATAL_ERROR "boost NOT fround: ${Boost_ERROR_REASON}") 
    255274endif(Boost_FOUND) 
    256  
    257 if(PROTOBUF_FOUND) 
    258   message(STATUS "Found proto in: ${PROTOBUF_INCLUDE_DIR} / ${PROTOBUF_LIBRARY} (${PROTOBUF_PROTOC_EXECUTABLE})") 
    259   INCLUDE_DIRECTORIES("${PROTOBUF_INCLUDE_DIR}") 
    260 else(PROTOBUF_FOUND) 
    261   message(FATAL_ERROR "Protocol buffers NOT found (${PROTOBUF_LIBRARYDIR})") 
    262 endif(PROTOBUF_FOUND) 
    263275 
    264276IF(WIN32) 
  • build.cmake

    rc6a974c r53be5c8  
    1919  ENDIF() 
    2020 
     21  SET(PROTOC_GEN_LUA_CMD "C:/Python/27x64/Scripts/protoc-gen-lua.cmd") 
     22   
    2123  SET(INC_GOOGLE_BREAKPAD_DIR "D:/source/libraries/google-breakpad-svn") 
    2224     
  • build/cmake/FindGoogleBreakpad.cmake

    r7ec3dd1 r53be5c8  
    2828ENDIF(NOT BREAKPAD_LIBRARY_SUFFIX_DEBUG) 
    2929 
    30 MESSAGE("Breakpad config: ${BREAKPAD_LIBRARY_PREFIX}...${BREAKPAD_LIBRARY_SUFFIX}, ${BREAKPAD_LIBRARY_PREFIX_DEBUG}...${BREAKPAD_LIBRARY_SUFFIX_DEBUG}" ) 
     30MESSAGE(STATUS "Breakpad config: ${BREAKPAD_LIBRARY_PREFIX}...${BREAKPAD_LIBRARY_SUFFIX}, ${BREAKPAD_LIBRARY_PREFIX_DEBUG}...${BREAKPAD_LIBRARY_SUFFIX_DEBUG}" ) 
    3131SET(BREAKPAD_FOUND TRUE) 
    3232FOREACH(COMPONENT ${GoogleBreakpad_FIND_COMPONENTS}) 
     
    4747ENDFOREACH(COMPONENT) 
    4848IF(BREAKPAD_FOUND) 
    49   MESSAGE("Looking for dump-symbols in: ${BREAKPAD_INCLUDE_DIR}/tools/windows/binaries" ) 
     49  MESSAGE(STATUS "Looking for dump-symbols in: ${BREAKPAD_INCLUDE_DIR}/tools/windows/binaries" ) 
    5050  FIND_PROGRAM(BREAKPAD_DUMPSYMS_EXE  
    5151    dump_syms.exe NAMES dump_syms dumpsyms 
    5252    PATHS ENV PATH ${BREAKPAD_INCLUDE_DIR}/tools/windows/binaries 
    5353    ) 
    54   MESSAGE("Looking for dump-symbols in: ${BREAKPAD_INCLUDE_DIR}/tools/windows/binaries: ${BREAKPAD_DUMPSYMS_EXE}" ) 
     54  MESSAGE(STATUS "Looking for dump-symbols in: ${BREAKPAD_INCLUDE_DIR}/tools/windows/binaries: ${BREAKPAD_DUMPSYMS_EXE}" ) 
    5555  IF(BREAKPAD_DUMPSYMS_EXE) 
    5656    SET(BREAKPAD_DUMPSYMS_EXE_FOUND TRUE) 
  • changelog

    r6090c98 r53be5c8  
    44 * Fix dependonservice LanManWorkStation (old win) 
    55 * Fix RtlStringFromGUID problem on NT4 
     6 
     72012-07-11 MickeM 
     8 * LUAScript: Improved lua scripting module a lot 
     9 * LUAScript: Added protocol buffer support to lua scripts 
     10 * tests: Rewrote (halfway there) test_nrpe python script as a lua script. 
     11 * CheckEventLog: Fixed command name when submitting real-time "no action checks" 
    612 
    7132012-06-18 MickeM 
  • include/nscapi/nscapi_plugin_impl.cpp

    rc3f233d r53be5c8  
    1515nscapi::core_wrapper* nscapi::impl::simple_plugin::get_core() { 
    1616  return plugin_singleton->get_core(); 
     17} 
     18 
     19 
     20void nscapi::impl::simple_plugin::register_command(std::wstring command, std::wstring description, std::list<std::wstring> aliases) { 
     21  BOOST_FOREACH(const std::wstring alias, aliases) { 
     22    register_command(alias, description); 
     23  } 
     24  register_command(command, description); 
    1725} 
    1826 
     
    4250} 
    4351 
     52 
     53 
    4454NSCAPI::nagiosReturn nscapi::impl::simple_command_line_exec::commandRAWLineExec(const wchar_t* char_command, const std::string &request, std::string &response) { 
    4555  nscapi::protobuf::types::decoded_simple_command_data data = nscapi::functions::parse_simple_exec_request(char_command, request); 
  • include/nscapi/nscapi_plugin_impl.hpp

    rc3f233d r53be5c8  
    2323        return boost::shared_ptr<nscapi::settings_proxy>(new nscapi::settings_proxy(get_core())); 
    2424      } 
     25       
    2526      void register_command(std::wstring command, std::wstring description) { 
    2627        get_core()->registerCommand(get_id(), command, description); 
    2728      } 
     29      void register_command(std::wstring command, std::wstring description, std::list<std::wstring> aliases); 
    2830 
    2931    }; 
     
    3335      NSCAPI::nagiosReturn handleRAWNotification(const wchar_t* channel, std::string request, std::string &response); 
    3436      virtual NSCAPI::nagiosReturn handleSimpleNotification(const std::wstring channel, const std::wstring source, const std::wstring command, NSCAPI::nagiosReturn code, std::wstring msg, std::wstring perf) = 0; 
    35  
    3637    }; 
    3738 
  • libs/dotnet-plugin-api/CMakeLists.txt

    r74e060a r53be5c8  
    2121  STRING(REPLACE "/GZ" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) 
    2222  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /clr") 
    23   MESSAGE(STATUS "---> DOT NET FLAGS: ${CMAKE_CXX_FLAGS}") 
    24   MESSAGE(STATUS "---> DOT NET FLAGS: ${CMAKE_CXX_FLAGS_DEBUG}") 
    25   MESSAGE(STATUS "---> DOT NET FLAGS: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") 
    26   MESSAGE(STATUS "---> DOT NET FLAGS: ${CMAKE_CXX_FLAGS_MINSIZEREL}") 
    2723   
    2824  ADD_LIBRARY(NSCPDOTNET MODULE ${SRCS}) 
  • libs/lua/CMakeLists.txt

    rd66ccee r53be5c8  
    22 
    33IF (HAVE_LUA) 
    4   message(STATUS "Found CACHED lua in ${LUA_SOURCE_DIR}") 
    5 ELSE (HAVE_LUA) 
    6   FIND_PATH(LUA_SOURCE_DIR lua.h ${LUA_INCLUE_DIR}/src) 
    7    
    8   IF (LUA_INCLUE_DIR) 
    9     message(STATUS "Found lua in ${LUA_INCLUE_DIR}") 
    10     SET(HAVE_LUA TRUE PARENT_SCOPE) 
    11     SET(HAVE_LUA TRUE) 
    12     SET(LUA_SOURCE_DIR ${LUA_INCLUE_DIR}) 
    13   ELSE (LUA_INCLUE_DIR) 
    14     message(STATUS "Lua was not found in ${LUA_SOURCE_DIR} (LUA_SOURCE_DIR)") 
    15   ENDIF (LUA_INCLUE_DIR) 
    16 ENDIF (HAVE_LUA) 
    17  
    18  
    19 IF (HAVE_LUA) 
     4  SET(LUA_SOURCE_DIR ${LUA_INCLUE_DIR}) 
    205  #FILE (GLOB lua_SOURCES "${LUA_SOURCE_DIR}/*.c") 
    216   
     
    5136    ${LUA_SOURCE_DIR}/lzio.c 
    5237  ) 
    53  
    5438   
    5539  FILE (GLOB lua_HEADERS "${LUA_SOURCE_DIR}/*.h") 
    56   message(STATUS "Using lua from ${LUA_SOURCE_DIR}") 
    5740  IF (MSVC) 
    5841    CMAKE_POLICY(SET CMP0008 NEW) 
     
    7053  SET_TARGET_PROPERTIES(lua_static PROPERTIES FOLDER "libraries") 
    7154 
    72 # IF (WIN32) 
    73 #   TARGET_LINK_LIBRARIES (cryptopp Ws2_32.lib) 
    74 #   TARGET_LINK_LIBRARIES (cryptopp_static Ws2_32.lib) 
    75 # ENDIF (WIN32) 
    76  
    7755  IF(APPLE) 
    7856     SET_TARGET_PROPERTIES(lua PROPERTIES COMPILE_FLAGS "-fPIC -w -DOSX  -DNDEBUG -finline-functions -O3 -DCRYPTOPP_DISABLE_ASM") 
  • libs/protobuf/plugin.proto

    r8d89d7a r53be5c8  
    126126    optional string data = 3; 
    127127  } 
     128  message ResponseData { 
     129    message ResponseDataCell { 
     130      required Common.AnyDataType data = 1; 
     131      optional string tag = 2; 
     132    } 
     133    message ResponseDataRow { 
     134      repeated ResponseDataCell cells = 1; 
     135    } 
     136    required string alias = 1; 
     137    optional ResponseDataRow headers = 2; 
     138    repeated ResponseDataRow rows = 3; 
     139 
     140  } 
    128141   
    129142}; 
     
    193206message ExecuteResponseMessage { 
    194207  message Response { 
    195    
    196     message ResponseData { 
    197       message ResponseDataCell { 
    198         required Common.AnyDataType data = 1; 
    199         optional string tag = 2; 
    200       } 
    201       message ResponseDataRow { 
    202         repeated ResponseDataCell cells = 1; 
    203       } 
    204       required string alias = 1; 
    205       optional ResponseDataRow headers = 2; 
    206       repeated ResponseDataRow rows = 3; 
    207  
    208     } 
    209  
    210208    optional int32 id = 2; 
    211209    required string command = 5; 
     
    215213    required string message = 10; 
    216214     
    217     optional ResponseData data = 11; 
     215    optional Common.ResponseData data = 11; 
    218216    repeated Common.Attachment attachments = 17; 
    219217     
     
    272270    required Settings node = 2; 
    273271     
    274     optional string default = 3; 
     272    //optional string default = 3; 
    275273    optional bool fetch_descriptions = 4; 
    276274     
     
    283281message QuerySettingsResponseMessage { 
    284282  message Response { 
    285     message SectionKeys { 
    286       repeated string key = 1; 
    287     } 
    288283    optional int64 id = 1; 
    289284    required Settings node = 2; 
    290285 
    291286    optional Common.AnyDataType value = 4; 
    292     optional SectionKeys keys = 5; 
     287    repeated string keys = 5; 
    293288     
    294289    optional string title = 6; 
  • modules/CheckEventLog/CheckEventLog.cpp

    rc3f233d r53be5c8  
    7171void real_time_thread::process_no_events(const filters::filter_config_object &object) { 
    7272  std::wstring response; 
    73   if (!nscapi::core_helper::submit_simple_message(object.target, object.alias, NSCAPI::returnOK, object.ok_msg, object.perf_msg, response)) { 
     73  std::wstring command = object.alias; 
     74  if (!object.command.empty()) 
     75    command = object.command; 
     76  if (!nscapi::core_helper::submit_simple_message(object.target, command, NSCAPI::returnOK, object.ok_msg, object.perf_msg, response)) { 
    7477    NSC_LOG_ERROR(_T("Failed to submit evenhtlog result: ") + response); 
    7578  } 
  • modules/CheckSystem/CheckSystem.cpp

    rc3f233d r53be5c8  
    2121 
    2222#include "stdafx.h" 
     23#include "CheckSystem.h" 
     24 
     25#include <map> 
     26#include <set> 
    2327 
    2428#include <boost/regex.hpp> 
    25 #include <boost/lexical_cast.hpp> 
    26  
    27 #include "CheckSystem.h" 
     29#include <boost/assign/list_of.hpp> 
     30 
     31#include <tlhelp32.h> 
     32 
     33 
    2834#include <utils.h> 
    29 #include <tlhelp32.h> 
    3035#include <EnumNtSrv.h> 
    3136#include <EnumProcess.h> 
    3237#include <checkHelpers.hpp> 
    33 #include <map> 
    34 #include <set> 
    3538#include <sysinfo.h> 
    3639#include <filter_framework.hpp> 
    3740#include <simple_registry.hpp> 
    3841#include <settings/client/settings_client.hpp> 
    39 #include <arrayBuffer.h> 
    40  
    4142#include <config.h> 
    4243 
     
    6970 */ 
    7071 
     72bool missing_system_counters(std::map<std::wstring,std::wstring> &counters)  
     73{ 
     74  wchar_t *keys[] = {PDH_SYSTEM_KEY_UPT, PDH_SYSTEM_KEY_MCL, PDH_SYSTEM_KEY_MCB, PDH_SYSTEM_KEY_CPU}; 
     75  BOOST_FOREACH(const wchar_t *cnt, keys) { 
     76    if (counters.find(cnt) == counters.end()) 
     77      return true; 
     78  } 
     79  return false; 
     80} 
     81 
    7182bool CheckSystem::loadModuleEx(std::wstring alias, NSCAPI::moduleLoadMode mode) { 
    7283  PDHCollector::system_counter_data *data = new PDHCollector::system_counter_data; 
     
    7485  try { 
    7586    typedef std::map<std::wstring,std::wstring> counter_map_type; 
    76     std::map<std::wstring,std::wstring> counters; 
    77     bool default_counters = true; 
     87    counter_map_type counters; 
    7888 
    7989    sh::settings_registry settings(get_settings_proxy()); 
     
    8191 
    8292    settings.alias().add_path_to_settings() 
     93      (_T("pdh/counters"), sh::wstring_map_path(&counters) 
     94      , _T("PDH COUNTERS"), _T("Define various PDH counters to check.")) 
     95      ; 
     96 
     97    settings.register_all(); 
     98    settings.notify(); 
     99    settings.clear(); 
     100 
     101    if (counters.empty() || missing_system_counters(counters)) { 
     102      std::wstring path = settings.alias().get_settings_path(_T("pdh/counters")); 
     103 
     104      get_core()->settings_register_key(path, PDH_SYSTEM_KEY_UPT, NSCAPI::key_string, _T("UPTIME"), _T("PDH Key for system uptime."), _T("\\2\\674"), false); 
     105      get_core()->settings_register_key(path, PDH_SYSTEM_KEY_MCL, NSCAPI::key_string, _T("Commit limit"), _T("PDH key for memory commit limit"), _T("\\4\\30"), false); 
     106      get_core()->settings_register_key(path, PDH_SYSTEM_KEY_MCB, NSCAPI::key_string, _T("Commit bytes"), _T("PDH Key for system CPU load."), _T("\\4\\26"), false); 
     107      get_core()->settings_register_key(path, PDH_SYSTEM_KEY_CPU, NSCAPI::key_string, _T("CPU Load"), _T("PDH Key for system CPU load."), _T("\\238(_total)\\6"), false); 
     108      get_core()->settings_register_key(path + _T("/") + PDH_SYSTEM_KEY_CPU, _T("collection strategy"), NSCAPI::key_string, _T("Collection Strategy"), _T("Collection strategy for CPP is usually round robin."), _T("round robin"), false); 
     109    } 
     110 
     111    settings.alias().add_path_to_settings() 
    83112      (_T("WINDOWS CHECK SYSTEM"), _T("Section for system checks and system settings")) 
    84113 
     
    87116      (_T("pdh"), _T("PDH COUNTER INFORMATION"), _T("")) 
    88117 
    89       (_T("pdh/counters"), sh::wstring_map_path(&counters) 
    90       , _T("PDH COUNTERS"), _T("")) 
    91  
    92118      ; 
    93119 
    94120    settings.alias().add_key_to_settings() 
    95       (_T("default"), sh::bool_key(&default_counters, true), 
    96       _T("DEFAULT COUNTERS"), _T("Load the default counters: ") PDH_SYSTEM_KEY_CPU _T(", ") PDH_SYSTEM_KEY_MCB _T(", ") PDH_SYSTEM_KEY_MCL _T(" and ") PDH_SYSTEM_KEY_UPT _T(" If not you need to specify these manually. ") ) 
    97  
    98121      (_T("default buffer length"), sh::wstring_key(&data->buffer_length, _T("1h")), 
    99122      _T("DEFAULT LENGTH"), _T("Used to define the default intervall for range buffer checks (ie. CPU).")) 
     
    129152    settings.notify(); 
    130153 
     154     
    131155    typedef PDHCollector::system_counter_data::counter cnt; 
     156    /* 
    132157    if (default_counters) { 
    133158      data->counters.push_back(cnt(PDH_SYSTEM_KEY_MCL, _T("\\4\\30"), cnt::type_int64, cnt::format_large, cnt::value)); 
     
    136161      data->counters.push_back(cnt(PDH_SYSTEM_KEY_UPT, _T("\\2\\674"), cnt::type_int64, cnt::format_large, cnt::value)); 
    137162    } 
     163    */ 
    138164    BOOST_FOREACH(counter_map_type::value_type c, counters) { 
    139165      data->counters.push_back(cnt(c.first, c.second, cnt::type_int64, cnt::format_large, cnt::value)); 
    140166    } 
    141167 
    142     register_command(_T("checkCPU"), _T("Check the CPU load of the computer.")); 
    143     register_command(_T("checkUpTime"), _T("Check the up-time of the computer.")); 
    144     register_command(_T("checkServiceState"), _T("Check the state of one or more of the computer services.")); 
    145     register_command(_T("checkProcState"), _T("Check the state of one or more of the processes running on the computer.")); 
    146     register_command(_T("checkMem"), _T("Check free/used memory on the system.")); 
    147     register_command(_T("checkCounter"), _T("Check a PDH counter.")); 
    148     register_command(_T("listCounterInstances"), _T("List all instances for a counter.")); 
    149     register_command(_T("checkSingleRegEntry"), _T("Check registry key")); 
     168    register_command(_T("check_CPU"), _T("Check that the load of the CPU(s) are within bounds."),  
     169      boost::assign::list_of(_T("checkCPU"))); 
     170    register_command(_T("check_uptime"), _T("Check time since last server re-boot."),  
     171      boost::assign::list_of(_T("checkUpTime"))); 
     172    register_command(_T("check_service"), _T("Check the state of one or more of the computer services."),  
     173      boost::assign::list_of(_T("checkServiceState"))); 
     174    register_command(_T("check_process"), _T("Check the state of one or more of the processes running on the computer."),  
     175      boost::assign::list_of(_T("checkProcState"))); 
     176    register_command(_T("check_memory"), _T("Check free/used memory on the system."),  
     177      boost::assign::list_of(_T("checkMem"))); 
     178    register_command(_T("check_pdh"), _T("Check a PDH counter."),  
     179      boost::assign::list_of(_T("checkCounter"))); 
     180    register_command(_T("check_registry"), _T("Check values in the registry."),  
     181      boost::assign::list_of(_T("checkSingleRegEntry"))); 
     182 
     183    register_command(_T("listCounterInstances"), _T("*DEPRECATED* List all instances for a counter.")); 
     184 
    150185  } catch (nscapi::nscapi_exception &e) { 
    151186    NSC_LOG_ERROR_STD(_T("Failed to register command: ") + utf8::cvt<std::wstring>(e.what())); 
  • modules/LUAScript/CMakeLists.txt

    ra06e6af r53be5c8  
    88  stdafx.cpp 
    99  "${TARGET}.cpp" 
     10  lua_wrappers.cpp 
     11 
    1012  ${NSCP_DEF_PLUGIN_CPP} 
    1113) 
     
    2830add_library(${TARGET} MODULE ${SRCS}) 
    2931 
     32SET(LUA_PB) 
     33IF (PROTOC_GEN_LUA_FOUND) 
     34  MESSAGE(STATUS "Lua has PB support") 
     35  SET(LUA_PB lua_pb_static) 
     36  ADD_DEFINITIONS(-DHAVE_LUA_PB) 
     37  INCLUDE_DIRECTORIES(${NSCP_PROJECT_BINARY_DIR}/libs/lua_pb) 
     38  INCLUDE_DIRECTORIES(${NSCP_PROJECT_BINARY_DIR}/libs/protobuf) 
     39ENDIF() 
     40 
     41 
    3042target_link_libraries(${TARGET} 
    3143  ${Boost_FILESYSTEM_LIBRARY} 
     44  ${Boost_PROGRAM_OPTIONS_LIBRARY} 
    3245  ${NSCP_DEF_PLUGIN_LIB} 
    3346  lua_static 
     47  ${LUA_PB} 
    3448) 
    3549INCLUDE(${BUILD_CMAKE_FOLDER}/module.cmake) 
  • modules/LUAScript/LUAScript.cpp

    ra8c6e93 r53be5c8  
    2121#include "stdafx.h" 
    2222#include "LUAScript.h" 
     23 
     24#include <boost/program_options.hpp> 
     25 
    2326#include <strEx.h> 
    2427#include <time.h> 
     
    3639 
    3740namespace sh = nscapi::settings_helper; 
     41namespace po = boost::program_options; 
    3842 
    3943bool LUAScript::loadModule() { 
     
    167171 
    168172 
    169 NSCAPI::nagiosReturn LUAScript::handleCommand(const std::wstring &target, const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &message, std::wstring &perf) { 
    170   if (command == _T("luareload")) { 
    171     return reload(message)?NSCAPI::returnOK:NSCAPI::returnCRIT; 
    172   } 
    173   if (!registry->has_command(command)) 
     173NSCAPI::nagiosReturn LUAScript::handleRAWCommand(const wchar_t* char_command, const std::string &request, std::string &response) { 
     174  if (!registry->has_command(char_command)) 
    174175    return NSCAPI::returnIgnored; 
    175   return registry->on_query(target, command, arguments, message, perf); 
    176     // const std::wstring &target, const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &message, std::wstring &perf 
     176  return registry->on_query(char_command, request, response); 
     177} 
     178 
     179 
     180 
     181NSCAPI::nagiosReturn LUAScript::execute_and_load(std::list<std::wstring> args, std::wstring &message) { 
     182  try { 
     183    po::options_description desc("Options for the following commands: (exec, execute)"); 
     184    boost::program_options::variables_map vm; 
     185    std::wstring file; 
     186    desc.add_options() 
     187      ("help", "Display help") 
     188      ("script", po::wvalue<std::wstring>(&file), "The script to run") 
     189      ("file", po::wvalue<std::wstring>(&file), "The script to run") 
     190      ; 
     191 
     192    std::vector<std::wstring> vargs(args.begin(), args.end()); 
     193    po::wparsed_options parsed = po::basic_command_line_parser<wchar_t>(vargs).options(desc).run(); 
     194    po::store(parsed, vm); 
     195    po::notify(vm); 
     196 
     197    if (vm.count("help") > 0) { 
     198      std::stringstream ss; 
     199      ss << desc; 
     200      message = utf8::to_unicode(ss.str()); 
     201      return NSCAPI::returnUNKNOWN; 
     202    } 
     203 
     204    boost::optional<boost::filesystem::wpath> ofile = find_file(file); 
     205    if (!ofile) { 
     206      message = _T("Script not found: ") + file; 
     207      NSC_LOG_ERROR_STD(message); 
     208      return NSCAPI::returnUNKNOWN; 
     209    } 
     210 
     211    try { 
     212      instances_.push_back(script_wrapper::lua_script::create_instance(get_core(), get_id(), registry, _T("cmdline"), (*ofile).string())); 
     213    } catch (const lua_wrappers::LUAException &e) { 
     214      NSC_LOG_ERROR_STD(_T("Could not load script ") + _T(": ") + e.getMessage()); 
     215    } catch (const std::exception &e) { 
     216      NSC_LOG_ERROR_STD(_T("Could not load script ") + _T(": ") + utf8::to_unicode(e.what())); 
     217    } 
     218    return NSCAPI::returnOK; 
     219  } catch (const std::exception &e) { 
     220    message = _T("Failed to execute script ") + utf8::to_unicode(e.what()); 
     221    NSC_LOG_ERROR_STD(message); 
     222    return NSCAPI::returnUNKNOWN; 
     223  } catch (...) { 
     224    message = _T("Failed to execute script "); 
     225    NSC_LOG_ERROR_STD(message); 
     226    return NSCAPI::returnUNKNOWN; 
     227  } 
    177228} 
    178229 
    179230NSCAPI::nagiosReturn LUAScript::commandLineExec(const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &result) { 
     231  if (command == _T("help")) { 
     232    std::list<std::wstring> args; 
     233    args.push_back(_T("--help")); 
     234    std::wstring result; 
     235    int ret = execute_and_load(args, result); 
     236    return ret; 
     237  } else if (command == _T("lua-execute") || command == _T("lua-run") 
     238    || command == _T("run") || command == _T("execute") || command == _T("exec") || command == _T("")) { 
     239      return execute_and_load(arguments, result); 
     240  }  
    180241  if (!registry->has_exec(command)) 
    181242    return NSCAPI::returnIgnored; 
  • modules/LUAScript/LUAScript.h

    ra8c6e93 r53be5c8  
    3434 
    3535 
    36 class LUAScript : public nscapi::impl::simple_command_handler, public nscapi::impl::simple_command_line_exec, public nscapi::impl::simple_submission_handler, public nscapi::impl::simple_plugin { 
     36class LUAScript : public nscapi::impl::simple_command_line_exec, public nscapi::impl::simple_submission_handler, public nscapi::impl::simple_plugin { 
    3737private: 
    3838 
     
    7070  boost::optional<boost::filesystem::wpath> find_file(std::wstring file); 
    7171  bool loadScript(std::wstring alias, std::wstring file); 
    72   NSCAPI::nagiosReturn handleCommand(const std::wstring &target, const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &message, std::wstring &perf); 
     72  NSCAPI::nagiosReturn execute_and_load(std::list<std::wstring> args, std::wstring &message); 
     73  NSCAPI::nagiosReturn handleSimpleNotification(const std::wstring channel, const std::wstring source, const std::wstring command, NSCAPI::nagiosReturn code, std::wstring msg, std::wstring perf); 
     74  NSCAPI::nagiosReturn handleRAWCommand(const wchar_t* char_command, const std::string &request, std::string &response); 
    7375  NSCAPI::nagiosReturn commandLineExec(const std::wstring &command, std::list<std::wstring> &arguments, std::wstring &result); 
    74   NSCAPI::nagiosReturn handleSimpleNotification(const std::wstring channel, const std::wstring source, const std::wstring command, NSCAPI::nagiosReturn code, std::wstring msg, std::wstring perf); 
    7576 
    7677 
  • modules/LUAScript/lua_wrappers.hpp

    ra8c6e93 r53be5c8  
    88#include "luna.h" 
    99 
     10#include <string> 
     11#include <list> 
     12 
     13#include <NSCAPI.h> 
     14#include <nscapi/nscapi_core_wrapper.hpp> 
     15 
     16#include <strEx.h> 
    1017 
    1118namespace lua_wrappers { 
    12  
    13  
    14  
    1519  class Lua_State { 
    1620    lua_State *L; 
     
    5559      return _T("<NOT_A_STRING>"); 
    5660    } 
     61    bool get_string(std::wstring &str, int pos = -1) { 
     62      if (pos == -1) 
     63        pos = lua_gettop(L); 
     64      if (pos == 0) 
     65        return false; 
     66      if (is_string(pos)) 
     67        str = utf8::cvt<std::wstring>(lua_tostring(L, pos)); 
     68      else if (is_number(pos)) 
     69        str = strEx::itos(lua_tonumber(L, pos)); 
     70      else 
     71        return false; 
     72      return true; 
     73    } 
    5774    int get_int(int pos = -1) { 
    5875      if (pos == -1) 
     
    6683      return 0; 
    6784    } 
    68     boolean get_boolean(int pos = -1) { 
     85    bool get_boolean(int pos = -1) { 
    6986      if (pos == -1) 
    7087        pos = lua_gettop(L); 
     
    7794      return false; 
    7895    } 
    79     NSCAPI::nagiosReturn get_code(int pos = -1) { 
    80       std::string str; 
    81       if (pos == -1) 
    82         pos = lua_gettop(L); 
    83       if (pos == 0) 
    84         return NSCAPI::returnUNKNOWN; 
    85       switch (lua_type(L, pos)) { 
    86         case LUA_TNUMBER:  
    87           return static_cast<int>(lua_tonumber(L, pos)); 
    88         case LUA_TSTRING: 
    89           return string_to_code(lua_tostring(L, pos)); 
    90         case LUA_TBOOLEAN: 
    91           return lua_toboolean(L, pos)?NSCAPI::returnOK:NSCAPI::returnCRIT; 
    92       } 
    93       NSC_LOG_ERROR_STD(_T("Incorrect return from script: should be error, ok, warning or unknown")); 
    94       return NSCAPI::returnUNKNOWN; 
    95     } 
     96    NSCAPI::nagiosReturn get_code(int pos = -1); 
    9697    std::list<std::wstring> get_array(const int pos = -1) { 
    9798      std::list<std::wstring> ret; 
     
    125126      return ret; 
    126127    } 
     128    bool pop_string(std::wstring &str) { 
     129      int top = lua_gettop(L); 
     130      if (top == 0) 
     131        return false; 
     132      if (!get_string(str, top)) 
     133        return false; 
     134      pop(); 
     135      return true; 
     136    } 
     137    bool pop_function(int &funref) { 
     138      int top = lua_gettop(L); 
     139      if (top == 0) 
     140        return false; 
     141      if (!is_function(top)) 
     142        return false; 
     143      funref = luaL_ref(L, LUA_REGISTRYINDEX); 
     144      if (funref == 0) 
     145        return false; 
     146      return true; 
     147    } 
    127148    int pop_int() { 
    128149      int ret; 
     
    151172      return ret; 
    152173    } 
     174 
     175    void getglobal(const std::wstring &name) { 
     176      lua_getglobal(L, utf8::cvt<std::string>(name).c_str()); 
     177    } 
     178 
     179 
    153180    ////////////////////////////////////////////////////////////////////////// 
    154181    // Converters 
    155     NSCAPI::nagiosReturn string_to_code(std::string str) { 
    156       if ((str == "critical")||(str == "crit")||(str == "error")) { 
    157         return NSCAPI::returnCRIT; 
    158       } else if ((str == "warning")||(str == "warn")) { 
    159         return NSCAPI::returnWARN; 
    160       } else if (str == "ok") { 
    161         return NSCAPI::returnOK; 
    162       } else if (str == "unknown") { 
    163         return NSCAPI::returnUNKNOWN; 
    164       } 
    165       NSC_LOG_ERROR_STD(_T("Invalid code: ") + utf8::to_unicode(str)); 
    166       return NSCAPI::returnUNKNOWN; 
    167     } 
     182    NSCAPI::nagiosReturn string_to_code(std::string str); 
    168183 
    169184 
     
    245260      lua_pushstring(L, s.c_str()); 
    246261    } 
     262    void push_raw_string(std::string s) { 
     263      lua_pushlstring(L, s.c_str(), s.size()); 
     264    } 
    247265    void push_array(std::list<std::wstring> &arr) { 
    248266      lua_createtable(L, 0, arr.size()); 
     
    260278      return size() == 0; 
    261279    } 
    262     void log_stack() { 
    263       int args = size(); 
    264       NSC_DEBUG_MSG_STD(_T("Invalid lua stack state, dumping stack")); 
    265       for (int i=1;i<args+1;i++) { 
    266         NSC_DEBUG_MSG_STD(get_type_as_string(i) +_T(": ") + get_string(i)); 
    267       } 
    268     } 
     280    void log_stack(); 
    269281 
    270282    int error(std::string s) { 
     
    404416      boost::shared_ptr<lua_script_instance> instance; 
    405417      int func_ref; 
     418      bool simple; 
    406419    }; 
    407420 
     
    418431  public: 
    419432 
    420     NSCAPI::nagiosReturn on_query(const std::wstring & target, const std::wstring & command, std::list<std::wstring> & arguments, std::wstring & message, std::wstring & perf) { 
    421       function_map::iterator it = functions.find(command); 
    422       if (it == functions.end()) 
    423         throw LUAException(_T("Invalid function: ") + command); 
    424       function_container c = it->second; 
    425       lua_wrapper lua(prep_function(c)); 
    426       lua.push_string(command); 
    427       lua.push_array(arguments); 
    428       if (lua.pcall(2, LUA_MULTRET, 0) != 0) { 
    429         NSC_LOG_ERROR_STD(_T("Failed to handle command: ") + command + _T(": ") + lua.pop_string()); 
    430         return NSCAPI::returnUNKNOWN; 
    431       } 
    432       int arg_count = lua.size(); 
    433       if (arg_count > 2) 
    434         perf = lua.pop_string(); 
    435       if (arg_count > 1) 
    436         message = lua.pop_string(); 
    437       if (arg_count > 0) 
    438         return lua.pop_code(); 
    439       NSC_LOG_ERROR_STD(_T("No arguments returned from script.")); 
    440       return NSCAPI::returnUNKNOWN; 
    441     } 
    442  
    443     NSCAPI::nagiosReturn on_exec(const std::wstring & command, std::list<std::wstring> & arguments, std::wstring & result) { 
    444       function_map::iterator it = execs.find(command); 
    445       if (it == execs.end()) 
    446         throw LUAException(_T("Invalid function: ") + command); 
    447       function_container c = it->second; 
    448       lua_wrapper lua(prep_function(c)); 
    449       lua.push_string(command); 
    450       lua.push_array(arguments); 
    451       if (lua.pcall(2, LUA_MULTRET, 0) != 0) { 
    452         NSC_LOG_ERROR_STD(_T("Failed to handle command: ") + command + _T(": ") + lua.pop_string()); 
    453         return NSCAPI::returnUNKNOWN; 
    454       } 
    455       int arg_count = lua.size(); 
    456       if (arg_count > 1) 
    457         result = lua.pop_string(); 
    458       if (arg_count > 0) 
    459         return lua.pop_code(); 
    460       NSC_LOG_ERROR_STD(_T("No arguments returned from script.")); 
    461       return NSCAPI::returnUNKNOWN; 
    462     } 
    463     NSCAPI::nagiosReturn on_submission(const std::wstring channel, const std::wstring source, const std::wstring command, NSCAPI::nagiosReturn code, std::wstring msg, std::wstring perf) { 
    464       function_map::iterator it = channels.find(channel); 
    465       if (it == channels.end()) 
    466         throw LUAException(_T("Invalid function: ") + channel); 
    467       function_container c = it->second; 
    468       lua_wrapper lua(prep_function(c)); 
    469       lua.push_string(source); 
    470       lua.push_string(command); 
    471       lua.push_code(code); 
    472       lua.push_string(msg); 
    473       lua.push_string(perf); 
    474       if (lua.pcall(5, LUA_MULTRET, 0) != 0) { 
    475         NSC_LOG_ERROR_STD(_T("Failed to handle command: ") + command + _T(": ") + lua.pop_string()); 
    476         return NSCAPI::returnUNKNOWN; 
    477       } 
    478       if (lua.size() > 0) 
    479         return lua.pop_code(); 
    480       NSC_LOG_ERROR_STD(_T("No arguments returned from script.")); 
    481       return NSCAPI::returnUNKNOWN; 
    482     } 
    483  
    484     void register_query(const std::wstring &command, boost::shared_ptr<lua_script_instance> instance, int func_ref) { 
     433    NSCAPI::nagiosReturn on_query(const wchar_t* command, const std::string &request, std::string &response); 
     434    NSCAPI::nagiosReturn on_exec(const std::wstring & command, std::list<std::wstring> & arguments, std::wstring & result); 
     435    NSCAPI::nagiosReturn on_submission(const std::wstring channel, const std::wstring source, const std::wstring command, NSCAPI::nagiosReturn code, std::wstring msg, std::wstring perf); 
     436 
     437    void register_query(const std::wstring &command, boost::shared_ptr<lua_script_instance> instance, int func_ref, bool simple = true) { 
    485438      function_container c; 
    486439      c.func_ref = func_ref; 
    487440      c.instance = instance; 
     441      c.simple = simple; 
    488442      functions[command] = c; 
    489443    } 
     
    562516  }; 
    563517 
    564   lua_instance_manager::script_map_type lua_instance_manager::scripts; 
    565518 
    566519 
  • modules/LUAScript/script_wrapper.hpp

    ree52cdd r53be5c8  
    11#pragma once 
     2 
     3#include <map> 
    24 
    35#include <boost/enable_shared_from_this.hpp> 
    46#include <boost/shared_ptr.hpp> 
    5 #include <map> 
     7#include <boost/optional.hpp> 
    68 
    79#include "lua_wrappers.hpp" 
     
    1012#include <nscapi/nscapi_core_helper.hpp> 
    1113 
     14#ifdef HAVE_LUA_PB 
     15#include <Plugin.pb-lua.h> 
     16#endif 
    1217namespace script_wrapper { 
    1318 
     
    7176    int query(lua_State *L) { 
    7277      lua_wrappers::lua_wrapper lua(L); 
    73       NSC_LOG_ERROR_STD(_T("Unsupported API called: query")); 
    74       return lua.error("Unsupported API called: query"); 
     78      try { 
     79        int nargs = lua.size(); 
     80        if (nargs != 2) 
     81          return lua.error("nscp.query requires 2 arguments!"); 
     82        std::string data = utf8::cvt<std::string>(lua.pop_string()); 
     83        std::wstring command = lua.pop_string(); 
     84        std::string response; 
     85        NSCAPI::nagiosReturn ret = nscapi::plugin_singleton->get_core()->query(command, data, response); 
     86        lua.push_code(ret); 
     87        lua.push_raw_string(response); 
     88        return lua.size(); 
     89      } catch (...) { 
     90        return lua.error("Unknown exception in: simple_query"); 
     91      } 
    7592    } 
    7693    int simple_exec(lua_State *L) { 
     
    152169    static const Luna<registry_wrapper>::RegType methods[]; 
    153170 
     171    boost::optional<int> read_registration(lua_wrapper &lua, std::wstring &command, int &funref, std::wstring &description) { 
     172      std::wstring funname; 
     173      if (lua.size() != 2 && lua.size() != 3) 
     174        return lua.error("Invalid number of arguments: " + strEx::s::xtos(lua.size()) + " expected 2 or 3"); 
     175      if (lua.size() > 2 && !lua.pop_string(description)) 
     176        return lua.error("Invalid description"); 
     177      if (lua.pop_string(funname)) { 
     178        lua.getglobal(funname); 
     179      } 
     180      if (!lua.pop_function(funref)) 
     181        return lua.error("Invalid function"); 
     182      if (!lua.pop_string(command)) 
     183        return lua.error("Invalid command"); 
     184      return boost::optional<int>(); 
     185    } 
    154186    int register_function(lua_State *L) { 
    155       lua_wrappers::lua_wrapper lua(L); 
    156       NSC_LOG_ERROR_STD(_T("Unsupported API called: exec")); 
    157       return lua.error("Unsupported API called: exec"); 
     187      // void = (cmd, function, desc) 
     188      std::wstring command, description; 
     189      int funref = 0; 
     190      lua_wrapper lua(L); 
     191      boost::optional<int> error = read_registration(lua, command, funref, description); 
     192      if (error) 
     193        return *error; 
     194 
     195      if (description.empty())  
     196        description = _T("Lua script: ") + command; 
     197      get_instance()->get_core()->registerCommand(get_instance()->get_plugin_id(), command, description); 
     198      get_instance()->get_registry()->register_query(command, get_instance(), funref, false); 
     199      return 0; 
    158200    } 
    159201    int register_simple_function(lua_State *L) { 
    160       lua_wrapper lua(L); 
    161       std::wstring description; 
    162       if (lua.size() > 2) 
    163         description = lua.pop_string(); 
    164       std::wstring name; 
    165       if (lua.is_string()) { 
    166         name = lua.pop_string(); 
    167         lua_getglobal(L, utf8::cvt<std::string>(name).c_str()); 
    168       } 
    169       if (!lua.is_function()) 
    170         return lua.error("Invalid argument not a function: " + utf8::cvt<std::string>(name)); 
    171  
    172       int func_ref = luaL_ref(L, LUA_REGISTRYINDEX); 
    173  
    174       if (func_ref == 0) 
    175         return lua.error("Invalid function: " + utf8::cvt<std::string>(name)); 
    176       std::wstring script = lua.pop_string(); 
     202      // void = (cmd, function, desc) 
     203      std::wstring command, description; 
     204      int funref = 0; 
     205      lua_wrapper lua(L); 
     206      boost::optional<int> error = read_registration(lua, command, funref, description); 
     207      if (error) 
     208        return *error; 
     209 
    177210      if (description.empty())  
    178         description = _T("Lua script: ") + script; 
    179       get_instance()->get_core()->registerCommand(get_instance()->get_plugin_id(), script, description); 
    180       get_instance()->get_registry()->register_query(script, get_instance(), func_ref); 
     211        description = _T("Lua script: ") + command; 
     212      get_instance()->get_core()->registerCommand(get_instance()->get_plugin_id(), command, description); 
     213      get_instance()->get_registry()->register_query(command, get_instance(), funref, true); 
    181214      return 0; 
    182215    } 
     
    232265  const char registry_wrapper::className[] = "Registry"; 
    233266  const Luna<registry_wrapper>::RegType registry_wrapper::methods[] = { 
    234     { "function", &registry_wrapper::register_function }, 
    235     { "simple_function", &registry_wrapper::register_simple_function }, 
     267    { "query", &registry_wrapper::register_function }, 
     268    { "simple_query", &registry_wrapper::register_simple_function }, 
    236269    { "cmdline", &registry_wrapper::register_cmdline }, 
    237270    { "simple_cmdline", &registry_wrapper::register_simple_cmdline }, 
     
    411444      Luna<registry_wrapper>::Register(L); 
    412445      Luna<settings_wrapper>::Register(L); 
     446#ifdef HAVE_LUA_PB 
     447      GET_CORE()->log(NSCAPI::log_level::error, "test", 123, "Loading lua pb"); 
     448      lua_protobuf_Plugin_open(L); 
     449#endif 
    413450    } 
    414451 
  • service/NSClient++.cpp

    r52c5bf2 r53be5c8  
    10231023} 
    10241024 
    1025 int NSClientT::simple_exec(std::wstring module, std::wstring command, std::vector<std::wstring> arguments, std::list<std::wstring> &resp) { 
     1025int NSClientT::simple_exec(std::wstring command, std::vector<std::wstring> arguments, std::list<std::wstring> &resp) { 
    10261026  std::string request; 
    10271027  std::list<std::string> responses; 
    10281028  std::list<std::wstring> errors; 
    10291029  nscapi::functions::create_simple_exec_request(command, arguments, request); 
     1030  std::wstring module; 
     1031  std::wstring::size_type pos = command.find(L'.'); 
     1032  if (pos != std::wstring::npos) { 
     1033    module = command.substr(0, pos); 
     1034    command = command.substr(pos+1); 
     1035  } 
    10301036  int ret = load_and_run(module, boost::bind(&exec_helper, _1, command, arguments, request, &responses), errors); 
    10311037 
  • service/NSClient++.h

    r440c0cb r53be5c8  
    135135  NSCAPI::nagiosReturn inject(std::wstring command, std::wstring arguments, std::wstring &msg, std::wstring & perf); 
    136136  std::wstring execute(std::wstring password, std::wstring cmd, std::list<std::wstring> args); 
    137   int simple_exec(std::wstring module, std::wstring command, std::vector<std::wstring> arguments, std::list<std::wstring> &resp); 
     137  int simple_exec(std::wstring command, std::vector<std::wstring> arguments, std::list<std::wstring> &resp); 
    138138  int simple_query(std::wstring module, std::wstring command, std::vector<std::wstring> arguments, std::list<std::wstring> &resp); 
    139139  NSCAPI::nagiosReturn exec_command(const wchar_t* target, const wchar_t* raw_command, std::string &request, std::string &response); 
  • service/cli_parser.hpp

    rc3f233d r53be5c8  
    8888      ("argument,a", po::wvalue<std::vector<std::wstring> >(), "List of arguments (gets -- prefixed automatically)") 
    8989      ("raw-argument", po::wvalue<std::vector<std::wstring> >(), "List of arguments (does not get -- prefixed)") 
     90      ("load-all", "Load all plugins.") 
    9091      ; 
    9192 
     
    344345    modes mode; 
    345346    bool boot; 
    346     client_arguments() : mode(none), boot(false) {} 
     347    bool load_all; 
     348    client_arguments() : mode(none), boot(false), load_all(false) {} 
    347349 
    348350    void debug() { 
     
    398400        args.mode = client_arguments::submit; 
    399401      } 
     402      args.load_all = vm.count("load-all")==1; 
    400403 
    401404      if (vm.count("module")) 
     
    469472          args.mode = client_arguments::combined; 
    470473          args.module = _T("PythonScript"); 
     474        } else if (lang == _T("lua")) { 
     475            args.command = _T("LUAScript.run"); 
     476            args.combined_query = _T("lua_unittest"); 
     477            args.mode = client_arguments::combined; 
     478            args.module = _T("LuaScript"); 
    471479        } else { 
    472480          std::wcerr << _T("Unknown language: ") << lang << std::endl; 
     
    522530 
    523531      core_->boot_init(log_level); 
     532      if (args.load_all)                                                                                                                                                     
     533        core_->preboot_load_all_plugin_files(); 
    524534      if (args.module.empty()) 
    525535        core_->boot_load_all_plugins(); 
     
    536546        ret = mainClient.simple_query(args.module, args.command, args.arguments, resp); 
    537547      } else if (args.mode == client_arguments::exec || args.mode == client_arguments::combined) { 
    538         ret = mainClient.simple_exec(args.module, args.command, args.arguments, resp); 
     548        ret = mainClient.simple_exec(args.command, args.arguments, resp); 
    539549        if (ret == NSCAPI::returnIgnored) { 
    540550          ret = 1; 
    541551          std::wcout << _T("Command not found (by module): ") << args.command << std::endl; 
    542552          resp.push_back(_T("Command not found: ") + args.command); 
    543           mainClient.simple_exec(args.module, _T("help"), args.arguments, resp); 
     553          mainClient.simple_exec(_T("help"), args.arguments, resp); 
    544554        } else if (args.mode == client_arguments::combined) { 
    545555          if (ret == NSCAPI::returnOK) { 
Note: See TracChangeset for help on using the changeset viewer.