Changeset ee52cdd in nscp


Ignore:
Timestamp:
03/04/12 08:22:02 (15 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
465147a
Parents:
84cdb9b
Message:
  • Added new dot-net API (Which does not require any strange wrappers)
  • Added brand new sample C# plugin
Files:
21 added
3 deleted
21 edited
1 moved

Legend:

Unmodified
Added
Removed
  • changelog

    rc74d7b6 ree52cdd  
    44 * Fixa dependonservice LanManWorkStation (old win) 
    55 * Fix RtlStringFromGUID problem on NT4 
     6 
     72012-03-04 MickeM 
     8 * Added new dot-net API (Which does not require any strange wrappers) 
     9 * Added brand new sample C# plugin 
    610 
    7112012-02-21 MickeM 
  • include/NSCAPI.h

    r84cdb9b ree52cdd  
    148148    typedef NSCAPI::errorReturn (*lpNSAPIReleaseSettingsSectionBuffer)(wchar_t***, unsigned int *); 
    149149    typedef void (*lpNSAPIMessage)(const char*, unsigned int); 
     150    typedef void (*lpNSAPISimpleMessage)(int, const char*, int, const wchar_t*); 
    150151    typedef NSCAPI::errorReturn (*lpNSAPIStopServer)(void); 
    151152    typedef NSCAPI::errorReturn (*lpNSAPIExit)(void); 
  • include/nscapi/macros.hpp

    r8013c0c ree52cdd  
    5454#ifdef _WIN32 
    5555#define NSC_WRAP_DLL() \ 
    56   BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved) { GET_PLUGIN()->wrapDllMain(hModule, ul_reason_for_call); return TRUE; } \ 
     56  BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved) { /*GET_PLUGIN()->wrapDllMain(hModule, ul_reason_for_call); */return TRUE; } \ 
    5757  nscapi::helper_singleton* nscapi::plugin_singleton = new nscapi::helper_singleton(); 
    5858#else 
  • include/nscapi/nscapi_core_wrapper.cpp

    r84cdb9b ree52cdd  
    2424#include <nscapi/nscapi_core_wrapper.hpp> 
    2525#include <nscapi/nscapi_helper.hpp> 
    26 #include <nscapi/nscapi_protobuf_functions.hpp> 
    2726 
    2827#include <strEx.h> 
    2928#include <arrayBuffer.h> 
    3029 
    31 #include <protobuf/plugin.pb.h> 
     30//#include <protobuf/plugin.pb.h> 
     31//#include <nscapi/nscapi_protobuf_functions.hpp> 
    3232 
    3333#define CORE_LOG_ERROR_STD(msg) if (should_log(NSCAPI::log_level::error)) { log(NSCAPI::log_level::error, __FILE__, __LINE__, (std::wstring)msg); } 
     
    6363  if (!should_log(msgType)) 
    6464    return; 
    65   if (!fNSAPIMessage) { 
     65  if (!fNSAPISimpleMessage) { 
    6666    std::wcout << _T("NSCORE NOT LOADED Dumping log: ") << line << _T(": ") << std::endl << logMessage << std::endl; 
    6767    return; 
     
    6969  std::string str; 
    7070  try { 
     71    /* 
    7172    Plugin::LogEntry message; 
    7273    Plugin::LogEntry::Entry *msg = message.add_entry(); 
     
    7879      std::wcout << _T("Failed to generate message: SERIALIZATION ERROR"); 
    7980    } 
    80     return fNSAPIMessage(str.c_str(), str.size()); 
     81    */ 
     82    return fNSAPISimpleMessage(msgType, file.c_str(), line, logMessage.c_str()); 
    8183  } catch (const std::exception &e) { 
    8284    std::wcout << _T("Failed to generate message: ") << utf8::to_unicode(e.what()); 
     
    154156  return fNSAPIReload(module.c_str()); 
    155157} 
    156  
    157 bool nscapi::core_wrapper::submit_simple_message(std::wstring channel, std::wstring command, NSCAPI::nagiosReturn code, std::wstring & message, std::wstring & perf, std::wstring & response) { 
    158   std::string request, buffer; 
    159   nscapi::functions::create_simple_submit_request(channel, command, code, message, perf, request); 
    160   NSCAPI::nagiosReturn ret = submit_message(channel, request, buffer); 
    161   if (ret == NSCAPI::returnIgnored) { 
    162     response = _T("No handler for this message"); 
    163     return false; 
    164   } 
    165   if (buffer.size() == 0) { 
    166     response = _T("Missing response from submission"); 
    167     return false; 
    168   } 
    169   nscapi::functions::parse_simple_submit_response(buffer, response); 
    170   return ret == NSCAPI::isSuccess; 
    171 } 
    172  
    173158NSCAPI::nagiosReturn nscapi::core_wrapper::submit_message(const wchar_t* channel, const char *request, const unsigned int request_len, char **response, unsigned int *response_len)  
    174159{ 
     
    176161    throw nscapi::nscapi_exception("NSCore has not been initiated..."); 
    177162  return fNSAPINotify(channel, request, request_len, response, response_len); 
    178 } 
    179  
    180 /** 
    181 * Inject a request command in the core (this will then be sent to the plug-in stack for processing) 
    182 * @param command Command to inject (password should not be included. 
    183 * @param argLen The length of the argument buffer 
    184 * @param **argument The argument buffer 
    185 * @param message The return message buffer 
    186 * @param perf The return performance data buffer 
    187 * @return The return of the command 
    188 */ 
    189 NSCAPI::nagiosReturn nscapi::core_wrapper::simple_query(const std::wstring command, const std::list<std::wstring> & argument, std::wstring & msg, std::wstring & perf)  
    190 { 
    191   if (!fNSAPIInject) 
    192     throw nscapi::nscapi_exception("NSCore has not been initiated..."); 
    193   std::string response; 
    194   NSCAPI::nagiosReturn ret = simple_query(command, argument, response); 
    195   if (!response.empty()) { 
    196     try { 
    197       return nscapi::functions::parse_simple_query_response(response, msg, perf); 
    198     } catch (std::exception &e) { 
    199       CORE_LOG_ERROR_STD(_T("Failed to extract return message: ") + utf8::cvt<std::wstring>(e.what())); 
    200       return NSCAPI::returnUNKNOWN; 
    201     } 
    202   } 
    203   return ret; 
    204 } 
    205 /** 
    206 * Inject a request command in the core (this will then be sent to the plug-in stack for processing) 
    207 * @param command Command to inject (password should not be included. 
    208 * @param argLen The length of the argument buffer 
    209 * @param **argument The argument buffer 
    210 * @param message The return message buffer 
    211 * @param perf The return performance data buffer 
    212 * @return The return of the command 
    213 */ 
    214 NSCAPI::nagiosReturn nscapi::core_wrapper::simple_query(const std::wstring command, const std::list<std::wstring> & arguments, std::string & result)  
    215 { 
    216   if (!fNSAPIInject) 
    217     throw nscapi::nscapi_exception("NSCore has not been initiated..."); 
    218  
    219   std::string request; 
    220   try { 
    221     nscapi::functions::create_simple_query_request(command, arguments, request); 
    222   } catch (std::exception &e) { 
    223     CORE_LOG_ERROR_STD(_T("Failed to extract return message: ") + utf8::cvt<std::wstring>(e.what())); 
    224     return NSCAPI::returnUNKNOWN; 
    225   } 
    226   return query(command.c_str(), request, result); 
    227163} 
    228164 
     
    256192} 
    257193 
    258  
    259 NSCAPI::nagiosReturn nscapi::core_wrapper::simple_query_from_nrpe(const std::wstring command, const std::wstring & buffer, std::wstring & message, std::wstring & perf) { 
    260   if (!fNSAPIInject) 
    261     throw nscapi::nscapi_exception("NSCore has not been initiated..."); 
    262   boost::tokenizer<boost::char_separator<wchar_t>, std::wstring::const_iterator, std::wstring > tok(buffer, boost::char_separator<wchar_t>(_T("!"))); 
    263   std::list<std::wstring> arglist; 
    264   BOOST_FOREACH(std::wstring s, tok) 
    265     arglist.push_back(s); 
    266   return simple_query(command, arglist, message, perf); 
    267 } 
    268  
    269194NSCAPI::nagiosReturn nscapi::core_wrapper::exec_command(const std::wstring target, const std::wstring command, std::string request, std::string & result) { 
    270195  char *buffer = NULL; 
     
    297222  return fNSAPIExecCommand(target, command, request, request_len, response, response_len); 
    298223} 
    299  
    300 NSCAPI::nagiosReturn nscapi::core_wrapper::exec_simple_command(const std::wstring target, const std::wstring command, const std::list<std::wstring> &argument, std::list<std::wstring> & result) { 
    301   std::string request, response; 
    302   nscapi::functions::create_simple_exec_request(command, argument, request); 
    303   NSCAPI::nagiosReturn ret = exec_command(target, command, request, response); 
    304   nscapi::functions::parse_simple_exec_result(response, result); 
    305   return ret; 
    306 } 
    307  
    308  
    309224 
    310225/** 
     
    649564  fNSAPIReleaseSettingsSectionBuffer = (nscapi::core_api::lpNSAPIReleaseSettingsSectionBuffer)f(_T("NSAPIReleaseSettingsSectionBuffer")); 
    650565  fNSAPIMessage = (nscapi::core_api::lpNSAPIMessage)f(_T("NSAPIMessage")); 
     566  fNSAPISimpleMessage = (nscapi::core_api::lpNSAPISimpleMessage)f(_T("NSAPISimpleMessage")); 
    651567  fNSAPIStopServer = (nscapi::core_api::lpNSAPIStopServer)f(_T("NSAPIStopServer")); 
    652568  //fNSAPIExit = (nscapi::core_api::lpNSAPIExit)f(_T("NSAPIExit")); 
  • include/nscapi/nscapi_core_wrapper.hpp

    r84cdb9b ree52cdd  
    4040    nscapi::core_api::lpNSAPIGetSettingsBool fNSAPIGetSettingsBool; 
    4141    nscapi::core_api::lpNSAPIMessage fNSAPIMessage; 
     42    nscapi::core_api::lpNSAPISimpleMessage fNSAPISimpleMessage; 
    4243    nscapi::core_api::lpNSAPIStopServer fNSAPIStopServer; 
    4344    nscapi::core_api::lpNSAPIExit fNSAPIExit; 
     
    135136    NSCAPI::nagiosReturn query(const wchar_t* command, const char *request, const unsigned int request_len, char **response, unsigned int *response_len); 
    136137    NSCAPI::nagiosReturn query(const std::wstring & command, const std::string & request, std::string & result); 
     138    /* 
    137139    NSCAPI::nagiosReturn simple_query(const std::wstring command, const std::list<std::wstring> & argument, std::wstring & message, std::wstring & perf); 
    138140    NSCAPI::nagiosReturn simple_query(const std::wstring command, const std::list<std::wstring> & argument, std::string & result); 
    139141    NSCAPI::nagiosReturn simple_query_from_nrpe(const std::wstring command, const std::wstring & buffer, std::wstring & message, std::wstring & perf); 
     142    NSCAPI::nagiosReturn exec_simple_command(const std::wstring target, const std::wstring command, const std::list<std::wstring> &argument, std::list<std::wstring> & result); 
     143    bool submit_simple_message(std::wstring channel, std::wstring command, NSCAPI::nagiosReturn code, std::wstring & message, std::wstring & perf, std::wstring & response); 
     144    */ 
    140145 
    141146    NSCAPI::nagiosReturn exec_command(const wchar_t* target, const wchar_t* command, const char *request, const unsigned int request_len, char **response, unsigned int *response_len); 
    142147    NSCAPI::nagiosReturn exec_command(const std::wstring target, const std::wstring command, std::string request, std::string & result); 
    143     NSCAPI::nagiosReturn exec_simple_command(const std::wstring target, const std::wstring command, const std::list<std::wstring> &argument, std::list<std::wstring> & result); 
    144148 
    145     bool submit_simple_message(std::wstring channel, std::wstring command, NSCAPI::nagiosReturn code, std::wstring & message, std::wstring & perf, std::wstring & response); 
    146149    NSCAPI::errorReturn submit_message(const wchar_t* channel, const char *request, const unsigned int request_len, char **response, unsigned int *response_len); 
    147150    NSCAPI::errorReturn submit_message(std::wstring channel, std::string request, std::string &response); 
  • include/nscapi/nscapi_plugin_wrapper.cpp

    r84cdb9b ree52cdd  
    3333 */ 
    3434#ifdef WIN32 
     35/* 
    3536int nscapi::plugin_wrapper::wrapDllMain(HANDLE hModule, DWORD ul_reason_for_call) 
    3637{ 
     
    4748  return TRUE; 
    4849} 
     50*/ 
    4951#endif 
    5052/** 
  • include/nscapi/nscapi_plugin_wrapper.hpp

    r84cdb9b ree52cdd  
    4747    }; 
    4848 
    49     plugin_wrapper() : hModule_(NULL) {} 
     49    plugin_wrapper() /*: hModule_(NULL)*/ {} 
    5050    int wrapReturnString(wchar_t *buffer, unsigned int bufLen, std::wstring str, int defaultReturnCode); 
    5151 
    5252#ifdef WIN32 
    5353  private: 
    54     HINSTANCE hModule_; 
     54    //HINSTANCE hModule_; 
    5555  public: 
    56     int wrapDllMain(HANDLE hModule, DWORD ul_reason_for_call); 
    57     HINSTANCE getModule() { 
    58       hModule_; 
    59     } 
     56    //int wrapDllMain(HANDLE hModule, DWORD ul_reason_for_call); 
     57    //HINSTANCE getModule() { 
     58    //  hModule_; 
     59    //} 
    6060#else 
    61     void* hModule_; 
     61    //void* hModule_; 
    6262#endif 
    6363    int wrapModuleHelperInit(unsigned int id, nscapi::core_api::lpNSAPILoader f);; 
     
    114114    static void wrap_string(std::string &string, char** buffer, unsigned int *buffer_len) { 
    115115      // TODO: Make this global to allow remote deletion!!! 
    116       unsigned int buf_len = string.size(); 
     116      size_t buf_len = string.size(); 
    117117      *buffer = new char[buf_len + 10]; 
    118118      memcpy(*buffer, string.c_str(), buf_len+1); 
  • libs/plugin_api/CMakeLists.txt

    r84cdb9b ree52cdd  
    1414   
    1515  ${NSCP_INCLUDEDIR}/nscapi/nscapi_core_wrapper.cpp 
     16  ${NSCP_INCLUDEDIR}/nscapi/nscapi_core_helper.cpp 
    1617  ${NSCP_INCLUDEDIR}/nscapi/nscapi_helper.cpp 
    1718  ${NSCP_INCLUDEDIR}/nscapi/nscapi_plugin_impl.cpp 
     
    3334     
    3435    ${NSCP_INCLUDEDIR}/nscapi/nscapi_core_wrapper.hpp 
     36    ${NSCP_INCLUDEDIR}/nscapi/nscapi_core_helper.hpp 
    3537    ${NSCP_INCLUDEDIR}/nscapi/nscapi_helper.hpp 
    3638    ${NSCP_INCLUDEDIR}/nscapi/nscapi_plugin_impl.hpp 
  • modules/CheckEventLog/CheckEventLog.cpp

    r84cdb9b ree52cdd  
    3939 
    4040#include <nscapi/nscapi_protobuf_functions.hpp> 
     41#include <nscapi/nscapi_core_helper.hpp> 
    4142 
    4243#include <parsers/where/unary_fun.hpp> 
     
    148149void real_time_thread::process_no_events() { 
    149150  std::wstring response; 
    150   if (!GET_CORE()->submit_simple_message(info.target, info.alias, NSCAPI::returnCRIT, info.ok_msg, info.perf_msg, response)) { 
     151  if (!nscapi::core_helper::submit_simple_message(info.target, info.alias, NSCAPI::returnCRIT, info.ok_msg, info.perf_msg, response)) { 
    151152    NSC_LOG_ERROR(_T("Failed to submit evenhtlog result: ") + response); 
    152153  } 
     
    156157  std::wstring response; 
    157158  std::wstring message = record.render(true, info.syntax, DATE_FORMAT, info.dwLang); 
    158   if (!GET_CORE()->submit_simple_message(info.target, info.alias, NSCAPI::returnCRIT, message, info.perf_msg, response)) { 
     159  if (!nscapi::core_helper::submit_simple_message(info.target, info.alias, NSCAPI::returnCRIT, message, info.perf_msg, response)) { 
    159160    NSC_LOG_ERROR(_T("Failed to submit evenhtlog result: ") + response); 
    160161  } 
  • modules/CheckExternalScripts/CheckExternalScripts.cpp

    r523576e ree52cdd  
    3232#include <settings/client/settings_client.hpp> 
    3333#include <nscapi/functions.hpp> 
     34#include <nscapi/nscapi_core_helper.hpp> 
    3435 
    3536#include <config.h> 
     
    220221    std::wstring message; 
    221222    try { 
    222       return GET_CORE()->simple_query(cd.command, args, response); 
     223      return nscapi::core_helper::simple_query(cd.command, args, response); 
    223224    } catch (boost::escaped_list_error &e) { 
    224225      NSC_LOG_MESSAGE(_T("Failed to parse alias expression: ") + strEx::string_to_wstring(e.what())); 
    225226      NSC_LOG_MESSAGE(_T("We will now try parsing the old syntax instead...")); 
    226       return GET_CORE()->simple_query(cd.command, args, response); 
     227      return nscapi::core_helper::simple_query(cd.command, args, response); 
    227228    } 
    228229  } else { 
  • modules/CheckHelpers/CheckHelpers.cpp

    rf33c12f ree52cdd  
    2929#include <boost/thread/thread.hpp> 
    3030 
     31#include <nscapi/nscapi_core_helper.hpp> 
     32 
    3133#include <settings/client/settings_client.hpp> 
    3234 
     
    9799    } 
    98100    std::wstring new_command = arguments.front(); arguments.pop_front(); 
    99     GET_CORE()->simple_query(new_command, arguments, message, perf); 
     101    nscapi::core_helper::simple_query(new_command, arguments, message, perf); 
    100102    return NSCAPI::returnOK; 
    101103  } else if (command == _T("checkalwayscritical")) { 
     
    105107    } 
    106108    std::wstring new_command = arguments.front(); arguments.pop_front(); 
    107     GET_CORE()->simple_query(new_command, arguments, message, perf); 
     109    nscapi::core_helper::simple_query(new_command, arguments, message, perf); 
    108110    return NSCAPI::returnCRIT; 
    109111  } else if (command == _T("checkalwayswarning")) { 
     
    113115    } 
    114116    std::wstring new_command = arguments.front(); arguments.pop_front(); 
    115     GET_CORE()->simple_query(new_command, arguments, message, perf); 
     117    nscapi::core_helper::simple_query(new_command, arguments, message, perf); 
    116118    return NSCAPI::returnWARN; 
    117119  } else if (command == _T("checkok")) { 
     
    161163    std::list<std::wstring> sub_args; 
    162164    std::wstring tMsg, tPerf; 
    163     NSCAPI::nagiosReturn tRet = GET_CORE()->simple_query((*cit2).first.c_str(), (*cit2).second, tMsg, tPerf); 
     165    NSCAPI::nagiosReturn tRet = nscapi::core_helper::simple_query((*cit2).first.c_str(), (*cit2).second, tMsg, tPerf); 
    164166    returnCode = nscapi::plugin_helper::maxState(returnCode, tRet); 
    165167    if (!message.empty()) 
     
    235237  std::list<std::wstring> cmd_args_l(cmd_args.begin(), cmd_args.end()); 
    236238 
    237   NSCAPI::nagiosReturn tRet = GET_CORE()->simple_query(command, cmd_args_l, msg, perf); 
     239  NSCAPI::nagiosReturn tRet = nscapi::core_helper::simple_query(command, cmd_args_l, msg, perf); 
    238240  switch (tRet) { 
    239241    case NSCAPI::returnOK: 
     
    254256public: 
    255257  void proc(std::wstring command, std::list<std::wstring> arguments) { 
    256     code = GET_CORE()->simple_query(command, arguments, msg, perf); 
     258    code = nscapi::core_helper::simple_query(command, arguments, msg, perf); 
    257259  } 
    258260  std::wstring msg; 
  • modules/LUAScript/script_wrapper.hpp

    ra8c6e93 ree52cdd  
    88 
    99#include <scripts/functions.hpp> 
     10#include <nscapi/nscapi_core_helper.hpp> 
    1011 
    1112namespace script_wrapper { 
     
    5960        std::wstring message; 
    6061        std::wstring perf; 
    61         NSCAPI::nagiosReturn ret = get_instance()->get_core()->simple_query(command, arguments, message, perf); 
     62        NSCAPI::nagiosReturn ret = nscapi::core_helper::simple_query(command, arguments, message, perf); 
    6263        lua.push_code(ret); 
    6364        lua.push_string(message); 
     
    8182        std::list<std::wstring> arguments = lua.checkarray(3); 
    8283        std::list<std::wstring> result; 
    83         NSCAPI::nagiosReturn ret = get_instance()->get_core()->exec_simple_command(target, command, arguments, result); 
     84        NSCAPI::nagiosReturn ret = nscapi::core_helper::exec_simple_command(target, command, arguments, result); 
    8485        lua.push_code(ret); 
    8586        lua.push_array(result); 
     
    104105        std::wstring perf = lua.wstring(5); 
    105106        std::wstring result; 
    106         NSCAPI::nagiosReturn ret = get_instance()->get_core()->submit_simple_message(channel, command, code, message, perf, result); 
     107        NSCAPI::nagiosReturn ret = nscapi::core_helper::submit_simple_message(channel, command, code, message, perf, result); 
    107108        lua.push_code(ret); 
    108109        lua.push_string(result); 
  • modules/NRPEServer/handler_impl.cpp

    r35254d1 ree52cdd  
    22 
    33#include <boost/asio.hpp> 
     4#include <nscapi/nscapi_core_helper.hpp> 
    45#include "handler_impl.hpp" 
    56#include <config.h> 
     
    3233  try { 
    3334    NSC_DEBUG_MSG_STD(_T("Running command: ") + cmd.first); 
    34     ret = nscapi::plugin_singleton->get_core()->simple_query_from_nrpe(cmd.first, cmd.second, msg, perf); 
     35    ret = nscapi::core_helper::simple_query_from_nrpe(cmd.first, cmd.second, msg, perf); 
    3536    NSC_DEBUG_MSG_STD(_T("Running command: ") + cmd.first + _T(" = ") + msg); 
    3637  } catch (...) { 
  • modules/NSCAServer/handler_impl.cpp

    rc5ec0c8 ree52cdd  
    22 
    33#include <boost/asio.hpp> 
     4#include <nscapi/nscapi_core_helper.hpp> 
    45#include "handler_impl.hpp" 
    56#include <config.h> 
     
    1112    std::wstring msg = utf8::cvt<std::wstring>(p.result.substr(0, pos)); 
    1213    std::wstring perf = utf8::cvt<std::wstring>(p.result.substr(++pos)); 
    13     GET_CORE()->submit_simple_message(channel_, utf8::cvt<std::wstring>(p.service), nscapi::plugin_helper::int2nagios(p.code), msg, perf, response); 
     14    nscapi::core_helper::submit_simple_message(channel_, utf8::cvt<std::wstring>(p.service), nscapi::plugin_helper::int2nagios(p.code), msg, perf, response); 
    1415  } else { 
    1516    std::wstring empty, msg = utf8::cvt<std::wstring>(p.result); 
    16     GET_CORE()->submit_simple_message(channel_, utf8::cvt<std::wstring>(p.service), nscapi::plugin_helper::int2nagios(p.code), msg, empty, response); 
     17    nscapi::core_helper::submit_simple_message(channel_, utf8::cvt<std::wstring>(p.service), nscapi::plugin_helper::int2nagios(p.code), msg, empty, response); 
    1718 
    1819  } 
  • modules/NSClientServer/handler_impl.cpp

    r84cdb9b ree52cdd  
    33#include <boost/asio.hpp> 
    44#include <boost/lexical_cast.hpp> 
     5#include <nscapi/nscapi_core_helper.hpp> 
    56#include "handler_impl.hpp" 
    67 
     
    121122 
    122123  std::wstring message, perf; 
    123   NSCAPI::nagiosReturn ret = nscapi::plugin_singleton->get_core()->simple_query(cmd.first.c_str(), args, message, perf); 
     124  NSCAPI::nagiosReturn ret = nscapi::core_helper::simple_query(cmd.first.c_str(), args, message, perf); 
    124125  if (!nscapi::plugin_helper::isNagiosReturnCode(ret)) { 
    125126    if (message.empty()) 
  • modules/PythonScript/script_wrapper.cpp

    r0f7b655 ree52cdd  
    55#include "PythonScript.h" 
    66#include <nscapi/functions.hpp> 
     7#include <nscapi/nscapi_core_helper.hpp> 
    78#include <boost/thread.hpp> 
    89 
     
    482483  { 
    483484    thread_unlocker unlocker; 
    484     ret = core->submit_simple_message(wchannel, wcommand, c, wmessage, wperf, wresp); 
     485    ret = nscapi::core_helper::submit_simple_message(wchannel, wcommand, c, wmessage, wperf, wresp); 
    485486  } 
    486487  return make_tuple(ret,utf8::cvt<std::string>(wresp)); 
     
    516517  { 
    517518    thread_unlocker unlocker; 
    518     ret = core->simple_query(utf8::cvt<std::wstring>(command), ws_argument, msg, perf); 
     519    ret = nscapi::core_helper::simple_query(utf8::cvt<std::wstring>(command), ws_argument, msg, perf); 
    519520  } 
    520521  return make_tuple(nagios_return_to_py(ret),utf8::cvt<std::string>(msg), utf8::cvt<std::string>(perf)); 
     
    539540    { 
    540541      thread_unlocker unlocker; 
    541       ret = core->exec_simple_command(ws_target, ws_command, ws_argument, result); 
     542      ret = nscapi::core_helper::exec_simple_command(ws_target, ws_command, ws_argument, result); 
    542543    } 
    543544    return make_tuple(ret, convert(result)); 
  • modules/Scheduler/Scheduler.cpp

    r523576e ree52cdd  
    2626#include <settings/macros.h> 
    2727 
     28#include <nscapi/nscapi_core_helper.hpp> 
    2829#include <settings/client/settings_client.hpp> 
    2930 
     
    117118  try { 
    118119    std::string response; 
    119     NSCAPI::nagiosReturn code = get_core()->simple_query(item.command.c_str(), item.arguments, response); 
     120    NSCAPI::nagiosReturn code = nscapi::core_helper::simple_query(item.command.c_str(), item.arguments, response); 
    120121    if (code == NSCAPI::returnIgnored) { 
    121122      NSC_LOG_ERROR_STD(_T("Command was not found: ") + item.command.c_str()); 
  • sample/CsharpSamplePlugin/CsharpSamplePlugin.csproj

    r739db5a ree52cdd  
    88    <OutputType>Library</OutputType> 
    99    <AppDesignerFolder>Properties</AppDesignerFolder> 
    10     <RootNamespace>CsharpSamplePlugin</RootNamespace> 
    11     <AssemblyName>CsharpSamplePlugin</AssemblyName> 
     10    <RootNamespace>test</RootNamespace> 
     11    <AssemblyName>test</AssemblyName> 
    1212    <StartupObject> 
    1313    </StartupObject> 
     
    1717    <DebugType>full</DebugType> 
    1818    <Optimize>false</Optimize> 
    19     <OutputPath>..\SampleManagedPlugin\lib\</OutputPath> 
     19    <OutputPath>..\..\..\build\x64\modules\dotnet\</OutputPath> 
    2020    <DefineConstants>DEBUG;TRACE</DefineConstants> 
    2121    <ErrorReport>prompt</ErrorReport> 
     
    3131  </PropertyGroup> 
    3232  <ItemGroup> 
     33    <Reference Include="Google.ProtocolBuffers, Version=2.4.1.473, Culture=neutral, PublicKeyToken=55f7125234beb589, processorArchitecture=MSIL"> 
     34      <SpecificVersion>False</SpecificVersion> 
     35      <HintPath>..\..\..\..\dotnet\protobuf\Protoc\Google.ProtocolBuffers.dll</HintPath> 
     36    </Reference> 
     37    <Reference Include="NSCPDOTNET, Version=1.0.4444.11607, Culture=neutral, processorArchitecture=AMD64"> 
     38      <SpecificVersion>False</SpecificVersion> 
     39      <HintPath>..\..\..\build\x64\NSCPDOTNET.dll</HintPath> 
     40    </Reference> 
    3341    <Reference Include="System" /> 
    3442    <Reference Include="System.Data" /> 
     
    3644  </ItemGroup> 
    3745  <ItemGroup> 
     46    <Compile Include="Plugin.cs" /> 
    3847    <Compile Include="Program.cs" /> 
    3948    <Compile Include="Properties\AssemblyInfo.cs" /> 
    40   </ItemGroup> 
    41   <ItemGroup> 
    42     <None Include="ClassDiagram1.cd" /> 
    4349  </ItemGroup> 
    4450  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> 
  • service/NSClient++.cpp

    rc74d7b6 ree52cdd  
    7070void NSClientT::log_info(const char* file, const int line, std::wstring message) { 
    7171  std::string s = nsclient::logger_helper::create_info(file, line, message); 
     72  mainClient.reportMessage(s); 
     73} 
     74void NSClientT::log_any(int level, const char* file, const int line, std::wstring message) { 
     75  std::string s = nsclient::logger_helper::create_message(nscapi::protobuf::functions::log_to_gpb(level), file, line, message); 
    7276  mainClient.reportMessage(s); 
    7377} 
  • service/NSClient++.h

    r8013c0c ree52cdd  
    248248    static void log_error(const char* file, const int line, std::string message); 
    249249    static void log_info(const char* file, const int line, std::wstring message); 
     250    static void log_any(int loglevel, const char* file, const int line, std::wstring message); 
    250251 
    251252 
  • service/core_api.cpp

    r8013c0c ree52cdd  
    101101  return nscapi::plugin_helper::wrapReturnString(buffer, bufLen, CURRENT_SERVICE_VERSION, NSCAPI::isSuccess); 
    102102} 
     103void NSAPISimpleMessage(int loglevel, const char* file, int line, const wchar_t* message) { 
     104  mainClient.log_any(loglevel, file, line, message); 
     105} 
    103106void NSAPIMessage(const char* data, unsigned int count) { 
    104107  mainClient.reportMessage(std::string(data, count)); 
     
    457460  if (wcscasecmp(buffer, _T("NSAPIMessage")) == 0) 
    458461    return reinterpret_cast<LPVOID>(&NSAPIMessage); 
     462  if (wcscasecmp(buffer, _T("NSAPISimpleMessage")) == 0) 
     463    return reinterpret_cast<LPVOID>(&NSAPISimpleMessage); 
    459464  if (wcscasecmp(buffer, _T("NSAPIStopServer")) == 0) 
    460465    return reinterpret_cast<LPVOID>(&NSAPIStopServer); 
  • service/core_api.h

    r8013c0c ree52cdd  
    3737int NSAPIGetSettingsInt(const wchar_t* section, const wchar_t* key, int defaultValue); 
    3838void NSAPIMessage(const char* data,unsigned int count); 
     39void NSAPISimpleMessage(int loglevel, const char* file, int line, const wchar_t* message); 
    3940void NSAPIStopServer(void); 
    4041NSCAPI::nagiosReturn NSAPIInject(const wchar_t* command, const char *request_buffer, const unsigned int request_buffer_len, char **response_buffer, unsigned int *response_buffer_len); 
Note: See TracChangeset for help on using the changeset viewer.