Changeset ee52cdd in nscp
- Timestamp:
- 03/04/12 08:22:02 (15 months ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 465147a
- Parents:
- 84cdb9b
- Files:
-
- 21 added
- 3 deleted
- 21 edited
- 1 moved
-
changelog (modified) (1 diff)
-
include/NSCAPI.h (modified) (1 diff)
-
include/nscapi/macros.hpp (modified) (1 diff)
-
include/nscapi/nscapi_core_helper.cpp (added)
-
include/nscapi/nscapi_core_helper.hpp (added)
-
include/nscapi/nscapi_core_wrapper.cpp (modified) (9 diffs)
-
include/nscapi/nscapi_core_wrapper.hpp (modified) (2 diffs)
-
include/nscapi/nscapi_plugin_wrapper.cpp (modified) (2 diffs)
-
include/nscapi/nscapi_plugin_wrapper.hpp (modified) (2 diffs)
-
libs/dotnet-plugin-api/AssemblyInfo.cpp (added)
-
libs/dotnet-plugin-api/CMakeLists.txt (added)
-
libs/dotnet-plugin-api/NSCP.h (added)
-
libs/dotnet-plugin-api/stdafx.cpp (added)
-
libs/dotnet-plugin-api/stdafx.h (added)
-
libs/plugin_api/CMakeLists.txt (modified) (2 diffs)
-
modules/CheckEventLog/CheckEventLog.cpp (modified) (3 diffs)
-
modules/CheckExternalScripts/CheckExternalScripts.cpp (modified) (2 diffs)
-
modules/CheckHelpers/CheckHelpers.cpp (modified) (7 diffs)
-
modules/CsharpSamplePlugin/ClassDiagram1.cd (deleted)
-
modules/CsharpSamplePlugin/Program.cs (deleted)
-
modules/CsharpSamplePlugin/Properties/AssemblyInfo.cs (deleted)
-
modules/DotnetPlugins/AssemblyInfo.cpp (added)
-
modules/DotnetPlugins/CMakeLists.txt (added)
-
modules/DotnetPlugins/DotnetPlugins.cpp (added)
-
modules/DotnetPlugins/DotnetPlugins.def (added)
-
modules/DotnetPlugins/DotnetPlugins.h (added)
-
modules/DotnetPlugins/Stdafx.cpp (added)
-
modules/DotnetPlugins/Stdafx.h (added)
-
modules/DotnetPlugins/module.cmake (added)
-
modules/DotnetPlugins/plugin_instance.cpp (added)
-
modules/DotnetPlugins/plugin_instance.hpp (added)
-
modules/LUAScript/script_wrapper.hpp (modified) (4 diffs)
-
modules/NRPEServer/handler_impl.cpp (modified) (2 diffs)
-
modules/NSCAServer/handler_impl.cpp (modified) (2 diffs)
-
modules/NSClientServer/handler_impl.cpp (modified) (2 diffs)
-
modules/PythonScript/script_wrapper.cpp (modified) (4 diffs)
-
modules/Scheduler/Scheduler.cpp (modified) (2 diffs)
-
sample/CsharpSamplePlugin/CsharpSamplePlugin.csproj (moved) (moved from modules/CsharpSamplePlugin/CsharpSamplePlugin.csproj) (4 diffs)
-
sample/CsharpSamplePlugin/CsharpSamplePlugin.sln (added)
-
sample/CsharpSamplePlugin/CsharpSamplePlugin.suo (added)
-
sample/CsharpSamplePlugin/Plugin.cs (added)
-
sample/CsharpSamplePlugin/Program.cs (added)
-
service/NSClient++.cpp (modified) (1 diff)
-
service/NSClient++.h (modified) (1 diff)
-
service/core_api.cpp (modified) (2 diffs)
-
service/core_api.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
changelog
rc74d7b6 ree52cdd 4 4 * Fixa dependonservice LanManWorkStation (old win) 5 5 * Fix RtlStringFromGUID problem on NT4 6 7 2012-03-04 MickeM 8 * Added new dot-net API (Which does not require any strange wrappers) 9 * Added brand new sample C# plugin 6 10 7 11 2012-02-21 MickeM -
include/NSCAPI.h
r84cdb9b ree52cdd 148 148 typedef NSCAPI::errorReturn (*lpNSAPIReleaseSettingsSectionBuffer)(wchar_t***, unsigned int *); 149 149 typedef void (*lpNSAPIMessage)(const char*, unsigned int); 150 typedef void (*lpNSAPISimpleMessage)(int, const char*, int, const wchar_t*); 150 151 typedef NSCAPI::errorReturn (*lpNSAPIStopServer)(void); 151 152 typedef NSCAPI::errorReturn (*lpNSAPIExit)(void); -
include/nscapi/macros.hpp
r8013c0c ree52cdd 54 54 #ifdef _WIN32 55 55 #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; } \ 57 57 nscapi::helper_singleton* nscapi::plugin_singleton = new nscapi::helper_singleton(); 58 58 #else -
include/nscapi/nscapi_core_wrapper.cpp
r84cdb9b ree52cdd 24 24 #include <nscapi/nscapi_core_wrapper.hpp> 25 25 #include <nscapi/nscapi_helper.hpp> 26 #include <nscapi/nscapi_protobuf_functions.hpp>27 26 28 27 #include <strEx.h> 29 28 #include <arrayBuffer.h> 30 29 31 #include <protobuf/plugin.pb.h> 30 //#include <protobuf/plugin.pb.h> 31 //#include <nscapi/nscapi_protobuf_functions.hpp> 32 32 33 33 #define CORE_LOG_ERROR_STD(msg) if (should_log(NSCAPI::log_level::error)) { log(NSCAPI::log_level::error, __FILE__, __LINE__, (std::wstring)msg); } … … 63 63 if (!should_log(msgType)) 64 64 return; 65 if (!fNSAPI Message) {65 if (!fNSAPISimpleMessage) { 66 66 std::wcout << _T("NSCORE NOT LOADED Dumping log: ") << line << _T(": ") << std::endl << logMessage << std::endl; 67 67 return; … … 69 69 std::string str; 70 70 try { 71 /* 71 72 Plugin::LogEntry message; 72 73 Plugin::LogEntry::Entry *msg = message.add_entry(); … … 78 79 std::wcout << _T("Failed to generate message: SERIALIZATION ERROR"); 79 80 } 80 return fNSAPIMessage(str.c_str(), str.size()); 81 */ 82 return fNSAPISimpleMessage(msgType, file.c_str(), line, logMessage.c_str()); 81 83 } catch (const std::exception &e) { 82 84 std::wcout << _T("Failed to generate message: ") << utf8::to_unicode(e.what()); … … 154 156 return fNSAPIReload(module.c_str()); 155 157 } 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 173 158 NSCAPI::nagiosReturn nscapi::core_wrapper::submit_message(const wchar_t* channel, const char *request, const unsigned int request_len, char **response, unsigned int *response_len) 174 159 { … … 176 161 throw nscapi::nscapi_exception("NSCore has not been initiated..."); 177 162 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 buffer184 * @param **argument The argument buffer185 * @param message The return message buffer186 * @param perf The return performance data buffer187 * @return The return of the command188 */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 buffer209 * @param **argument The argument buffer210 * @param message The return message buffer211 * @param perf The return performance data buffer212 * @return The return of the command213 */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);227 163 } 228 164 … … 256 192 } 257 193 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 269 194 NSCAPI::nagiosReturn nscapi::core_wrapper::exec_command(const std::wstring target, const std::wstring command, std::string request, std::string & result) { 270 195 char *buffer = NULL; … … 297 222 return fNSAPIExecCommand(target, command, request, request_len, response, response_len); 298 223 } 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 309 224 310 225 /** … … 649 564 fNSAPIReleaseSettingsSectionBuffer = (nscapi::core_api::lpNSAPIReleaseSettingsSectionBuffer)f(_T("NSAPIReleaseSettingsSectionBuffer")); 650 565 fNSAPIMessage = (nscapi::core_api::lpNSAPIMessage)f(_T("NSAPIMessage")); 566 fNSAPISimpleMessage = (nscapi::core_api::lpNSAPISimpleMessage)f(_T("NSAPISimpleMessage")); 651 567 fNSAPIStopServer = (nscapi::core_api::lpNSAPIStopServer)f(_T("NSAPIStopServer")); 652 568 //fNSAPIExit = (nscapi::core_api::lpNSAPIExit)f(_T("NSAPIExit")); -
include/nscapi/nscapi_core_wrapper.hpp
r84cdb9b ree52cdd 40 40 nscapi::core_api::lpNSAPIGetSettingsBool fNSAPIGetSettingsBool; 41 41 nscapi::core_api::lpNSAPIMessage fNSAPIMessage; 42 nscapi::core_api::lpNSAPISimpleMessage fNSAPISimpleMessage; 42 43 nscapi::core_api::lpNSAPIStopServer fNSAPIStopServer; 43 44 nscapi::core_api::lpNSAPIExit fNSAPIExit; … … 135 136 NSCAPI::nagiosReturn query(const wchar_t* command, const char *request, const unsigned int request_len, char **response, unsigned int *response_len); 136 137 NSCAPI::nagiosReturn query(const std::wstring & command, const std::string & request, std::string & result); 138 /* 137 139 NSCAPI::nagiosReturn simple_query(const std::wstring command, const std::list<std::wstring> & argument, std::wstring & message, std::wstring & perf); 138 140 NSCAPI::nagiosReturn simple_query(const std::wstring command, const std::list<std::wstring> & argument, std::string & result); 139 141 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 */ 140 145 141 146 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); 142 147 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);144 148 145 bool submit_simple_message(std::wstring channel, std::wstring command, NSCAPI::nagiosReturn code, std::wstring & message, std::wstring & perf, std::wstring & response);146 149 NSCAPI::errorReturn submit_message(const wchar_t* channel, const char *request, const unsigned int request_len, char **response, unsigned int *response_len); 147 150 NSCAPI::errorReturn submit_message(std::wstring channel, std::string request, std::string &response); -
include/nscapi/nscapi_plugin_wrapper.cpp
r84cdb9b ree52cdd 33 33 */ 34 34 #ifdef WIN32 35 /* 35 36 int nscapi::plugin_wrapper::wrapDllMain(HANDLE hModule, DWORD ul_reason_for_call) 36 37 { … … 47 48 return TRUE; 48 49 } 50 */ 49 51 #endif 50 52 /** -
include/nscapi/nscapi_plugin_wrapper.hpp
r84cdb9b ree52cdd 47 47 }; 48 48 49 plugin_wrapper() : hModule_(NULL){}49 plugin_wrapper() /*: hModule_(NULL)*/ {} 50 50 int wrapReturnString(wchar_t *buffer, unsigned int bufLen, std::wstring str, int defaultReturnCode); 51 51 52 52 #ifdef WIN32 53 53 private: 54 HINSTANCE hModule_;54 //HINSTANCE hModule_; 55 55 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 //} 60 60 #else 61 void* hModule_;61 //void* hModule_; 62 62 #endif 63 63 int wrapModuleHelperInit(unsigned int id, nscapi::core_api::lpNSAPILoader f);; … … 114 114 static void wrap_string(std::string &string, char** buffer, unsigned int *buffer_len) { 115 115 // TODO: Make this global to allow remote deletion!!! 116 unsigned int buf_len = string.size();116 size_t buf_len = string.size(); 117 117 *buffer = new char[buf_len + 10]; 118 118 memcpy(*buffer, string.c_str(), buf_len+1); -
libs/plugin_api/CMakeLists.txt
r84cdb9b ree52cdd 14 14 15 15 ${NSCP_INCLUDEDIR}/nscapi/nscapi_core_wrapper.cpp 16 ${NSCP_INCLUDEDIR}/nscapi/nscapi_core_helper.cpp 16 17 ${NSCP_INCLUDEDIR}/nscapi/nscapi_helper.cpp 17 18 ${NSCP_INCLUDEDIR}/nscapi/nscapi_plugin_impl.cpp … … 33 34 34 35 ${NSCP_INCLUDEDIR}/nscapi/nscapi_core_wrapper.hpp 36 ${NSCP_INCLUDEDIR}/nscapi/nscapi_core_helper.hpp 35 37 ${NSCP_INCLUDEDIR}/nscapi/nscapi_helper.hpp 36 38 ${NSCP_INCLUDEDIR}/nscapi/nscapi_plugin_impl.hpp -
modules/CheckEventLog/CheckEventLog.cpp
r84cdb9b ree52cdd 39 39 40 40 #include <nscapi/nscapi_protobuf_functions.hpp> 41 #include <nscapi/nscapi_core_helper.hpp> 41 42 42 43 #include <parsers/where/unary_fun.hpp> … … 148 149 void real_time_thread::process_no_events() { 149 150 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)) { 151 152 NSC_LOG_ERROR(_T("Failed to submit evenhtlog result: ") + response); 152 153 } … … 156 157 std::wstring response; 157 158 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)) { 159 160 NSC_LOG_ERROR(_T("Failed to submit evenhtlog result: ") + response); 160 161 } -
modules/CheckExternalScripts/CheckExternalScripts.cpp
r523576e ree52cdd 32 32 #include <settings/client/settings_client.hpp> 33 33 #include <nscapi/functions.hpp> 34 #include <nscapi/nscapi_core_helper.hpp> 34 35 35 36 #include <config.h> … … 220 221 std::wstring message; 221 222 try { 222 return GET_CORE()->simple_query(cd.command, args, response);223 return nscapi::core_helper::simple_query(cd.command, args, response); 223 224 } catch (boost::escaped_list_error &e) { 224 225 NSC_LOG_MESSAGE(_T("Failed to parse alias expression: ") + strEx::string_to_wstring(e.what())); 225 226 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); 227 228 } 228 229 } else { -
modules/CheckHelpers/CheckHelpers.cpp
rf33c12f ree52cdd 29 29 #include <boost/thread/thread.hpp> 30 30 31 #include <nscapi/nscapi_core_helper.hpp> 32 31 33 #include <settings/client/settings_client.hpp> 32 34 … … 97 99 } 98 100 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); 100 102 return NSCAPI::returnOK; 101 103 } else if (command == _T("checkalwayscritical")) { … … 105 107 } 106 108 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); 108 110 return NSCAPI::returnCRIT; 109 111 } else if (command == _T("checkalwayswarning")) { … … 113 115 } 114 116 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); 116 118 return NSCAPI::returnWARN; 117 119 } else if (command == _T("checkok")) { … … 161 163 std::list<std::wstring> sub_args; 162 164 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); 164 166 returnCode = nscapi::plugin_helper::maxState(returnCode, tRet); 165 167 if (!message.empty()) … … 235 237 std::list<std::wstring> cmd_args_l(cmd_args.begin(), cmd_args.end()); 236 238 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); 238 240 switch (tRet) { 239 241 case NSCAPI::returnOK: … … 254 256 public: 255 257 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); 257 259 } 258 260 std::wstring msg; -
modules/LUAScript/script_wrapper.hpp
ra8c6e93 ree52cdd 8 8 9 9 #include <scripts/functions.hpp> 10 #include <nscapi/nscapi_core_helper.hpp> 10 11 11 12 namespace script_wrapper { … … 59 60 std::wstring message; 60 61 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); 62 63 lua.push_code(ret); 63 64 lua.push_string(message); … … 81 82 std::list<std::wstring> arguments = lua.checkarray(3); 82 83 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); 84 85 lua.push_code(ret); 85 86 lua.push_array(result); … … 104 105 std::wstring perf = lua.wstring(5); 105 106 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); 107 108 lua.push_code(ret); 108 109 lua.push_string(result); -
modules/NRPEServer/handler_impl.cpp
r35254d1 ree52cdd 2 2 3 3 #include <boost/asio.hpp> 4 #include <nscapi/nscapi_core_helper.hpp> 4 5 #include "handler_impl.hpp" 5 6 #include <config.h> … … 32 33 try { 33 34 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); 35 36 NSC_DEBUG_MSG_STD(_T("Running command: ") + cmd.first + _T(" = ") + msg); 36 37 } catch (...) { -
modules/NSCAServer/handler_impl.cpp
rc5ec0c8 ree52cdd 2 2 3 3 #include <boost/asio.hpp> 4 #include <nscapi/nscapi_core_helper.hpp> 4 5 #include "handler_impl.hpp" 5 6 #include <config.h> … … 11 12 std::wstring msg = utf8::cvt<std::wstring>(p.result.substr(0, pos)); 12 13 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); 14 15 } else { 15 16 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); 17 18 18 19 } -
modules/NSClientServer/handler_impl.cpp
r84cdb9b ree52cdd 3 3 #include <boost/asio.hpp> 4 4 #include <boost/lexical_cast.hpp> 5 #include <nscapi/nscapi_core_helper.hpp> 5 6 #include "handler_impl.hpp" 6 7 … … 121 122 122 123 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); 124 125 if (!nscapi::plugin_helper::isNagiosReturnCode(ret)) { 125 126 if (message.empty()) -
modules/PythonScript/script_wrapper.cpp
r0f7b655 ree52cdd 5 5 #include "PythonScript.h" 6 6 #include <nscapi/functions.hpp> 7 #include <nscapi/nscapi_core_helper.hpp> 7 8 #include <boost/thread.hpp> 8 9 … … 482 483 { 483 484 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); 485 486 } 486 487 return make_tuple(ret,utf8::cvt<std::string>(wresp)); … … 516 517 { 517 518 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); 519 520 } 520 521 return make_tuple(nagios_return_to_py(ret),utf8::cvt<std::string>(msg), utf8::cvt<std::string>(perf)); … … 539 540 { 540 541 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); 542 543 } 543 544 return make_tuple(ret, convert(result)); -
modules/Scheduler/Scheduler.cpp
r523576e ree52cdd 26 26 #include <settings/macros.h> 27 27 28 #include <nscapi/nscapi_core_helper.hpp> 28 29 #include <settings/client/settings_client.hpp> 29 30 … … 117 118 try { 118 119 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); 120 121 if (code == NSCAPI::returnIgnored) { 121 122 NSC_LOG_ERROR_STD(_T("Command was not found: ") + item.command.c_str()); -
sample/CsharpSamplePlugin/CsharpSamplePlugin.csproj
r739db5a ree52cdd 8 8 <OutputType>Library</OutputType> 9 9 <AppDesignerFolder>Properties</AppDesignerFolder> 10 <RootNamespace> CsharpSamplePlugin</RootNamespace>11 <AssemblyName> CsharpSamplePlugin</AssemblyName>10 <RootNamespace>test</RootNamespace> 11 <AssemblyName>test</AssemblyName> 12 12 <StartupObject> 13 13 </StartupObject> … … 17 17 <DebugType>full</DebugType> 18 18 <Optimize>false</Optimize> 19 <OutputPath>..\ SampleManagedPlugin\lib\</OutputPath>19 <OutputPath>..\..\..\build\x64\modules\dotnet\</OutputPath> 20 20 <DefineConstants>DEBUG;TRACE</DefineConstants> 21 21 <ErrorReport>prompt</ErrorReport> … … 31 31 </PropertyGroup> 32 32 <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> 33 41 <Reference Include="System" /> 34 42 <Reference Include="System.Data" /> … … 36 44 </ItemGroup> 37 45 <ItemGroup> 46 <Compile Include="Plugin.cs" /> 38 47 <Compile Include="Program.cs" /> 39 48 <Compile Include="Properties\AssemblyInfo.cs" /> 40 </ItemGroup>41 <ItemGroup>42 <None Include="ClassDiagram1.cd" />43 49 </ItemGroup> 44 50 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> -
service/NSClient++.cpp
rc74d7b6 ree52cdd 70 70 void NSClientT::log_info(const char* file, const int line, std::wstring message) { 71 71 std::string s = nsclient::logger_helper::create_info(file, line, message); 72 mainClient.reportMessage(s); 73 } 74 void 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); 72 76 mainClient.reportMessage(s); 73 77 } -
service/NSClient++.h
r8013c0c ree52cdd 248 248 static void log_error(const char* file, const int line, std::string message); 249 249 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); 250 251 251 252 -
service/core_api.cpp
r8013c0c ree52cdd 101 101 return nscapi::plugin_helper::wrapReturnString(buffer, bufLen, CURRENT_SERVICE_VERSION, NSCAPI::isSuccess); 102 102 } 103 void NSAPISimpleMessage(int loglevel, const char* file, int line, const wchar_t* message) { 104 mainClient.log_any(loglevel, file, line, message); 105 } 103 106 void NSAPIMessage(const char* data, unsigned int count) { 104 107 mainClient.reportMessage(std::string(data, count)); … … 457 460 if (wcscasecmp(buffer, _T("NSAPIMessage")) == 0) 458 461 return reinterpret_cast<LPVOID>(&NSAPIMessage); 462 if (wcscasecmp(buffer, _T("NSAPISimpleMessage")) == 0) 463 return reinterpret_cast<LPVOID>(&NSAPISimpleMessage); 459 464 if (wcscasecmp(buffer, _T("NSAPIStopServer")) == 0) 460 465 return reinterpret_cast<LPVOID>(&NSAPIStopServer); -
service/core_api.h
r8013c0c ree52cdd 37 37 int NSAPIGetSettingsInt(const wchar_t* section, const wchar_t* key, int defaultValue); 38 38 void NSAPIMessage(const char* data,unsigned int count); 39 void NSAPISimpleMessage(int loglevel, const char* file, int line, const wchar_t* message); 39 40 void NSAPIStopServer(void); 40 41 NSCAPI::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.








