Changeset 81e420c in nscp
- Timestamp:
- 09/01/11 07:05:41 (21 months ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- 3b11e65
- Parents:
- 1307e3f5
- Files:
-
- 2 added
- 57 edited
-
changelog (modified) (1 diff)
-
include/NSCAPI.h (modified) (2 diffs)
-
include/nscapi/functions.hpp (modified) (7 diffs)
-
include/nscapi/macros.hpp (modified) (15 diffs)
-
include/nscapi/nscapi_plugin_wrapper.cpp (modified) (1 diff)
-
include/nscapi/nscapi_plugin_wrapper.hpp (modified) (2 diffs)
-
libs/protobuf/plugin.proto (modified) (8 diffs)
-
modules/CheckDisk/CheckDisk.cpp (modified) (2 diffs)
-
modules/CheckDisk/CheckDisk.h (modified) (1 diff)
-
modules/CheckEventLog/CheckEventLog.cpp (modified) (2 diffs)
-
modules/CheckEventLog/CheckEventLog.h (modified) (2 diffs)
-
modules/CheckExternalScripts/CheckExternalScripts.cpp (modified) (2 diffs)
-
modules/CheckExternalScripts/CheckExternalScripts.h (modified) (1 diff)
-
modules/CheckHelpers/CheckHelpers.cpp (modified) (2 diffs)
-
modules/CheckHelpers/CheckHelpers.h (modified) (1 diff)
-
modules/CheckNSCP/CheckNSCP.cpp (modified) (2 diffs)
-
modules/CheckNSCP/CheckNSCP.h (modified) (1 diff)
-
modules/CheckSystem/CheckSystem.cpp (modified) (2 diffs)
-
modules/CheckSystem/CheckSystem.h (modified) (2 diffs)
-
modules/CheckTaskSched/CheckTaskSched.cpp (modified) (2 diffs)
-
modules/CheckTaskSched/CheckTaskSched.h (modified) (1 diff)
-
modules/CheckTaskSched2/CheckTaskSched2.cpp (modified) (2 diffs)
-
modules/CheckTaskSched2/CheckTaskSched2.h (modified) (1 diff)
-
modules/CheckWMI/CheckWMI.cpp (modified) (2 diffs)
-
modules/CheckWMI/CheckWMI.h (modified) (1 diff)
-
modules/FileLogger/FileLogger.cpp (modified) (2 diffs)
-
modules/FileLogger/FileLogger.h (modified) (1 diff)
-
modules/LUAScript/LUAScript.cpp (modified) (2 diffs)
-
modules/LUAScript/LUAScript.h (modified) (1 diff)
-
modules/NRPEClient/NRPEClient.cpp (modified) (2 diffs)
-
modules/NRPEClient/NRPEClient.h (modified) (2 diffs)
-
modules/NRPEServer/NRPEServer.cpp (modified) (2 diffs)
-
modules/NRPEServer/NRPEServer.h (modified) (2 diffs)
-
modules/NSCAAgent/NSCAAgent.cpp (modified) (2 diffs)
-
modules/NSCAAgent/NSCAAgent.h (modified) (2 diffs)
-
modules/NSCPClient/NSCPClient.cpp (modified) (2 diffs)
-
modules/NSCPClient/NSCPClient.h (modified) (2 diffs)
-
modules/NSCPServer/NSCPServer.cpp (modified) (2 diffs)
-
modules/NSCPServer/NSCPServer.h (modified) (2 diffs)
-
modules/NSClientServer/NSClientServer.cpp (modified) (2 diffs)
-
modules/NSClientServer/NSClientServer.h (modified) (1 diff)
-
modules/PythonScript/PythonScript.cpp (modified) (4 diffs)
-
modules/PythonScript/PythonScript.h (modified) (1 diff)
-
modules/PythonScript/script_wrapper.cpp (modified) (2 diffs)
-
modules/PythonScript/script_wrapper.hpp (modified) (1 diff)
-
modules/Scheduler/Scheduler.cpp (modified) (2 diffs)
-
modules/Scheduler/Scheduler.h (modified) (1 diff)
-
scripts/python/test.py (modified) (3 diffs)
-
service/CMakeLists.txt (modified) (1 diff)
-
service/NSCPlugin.cpp (modified) (13 diffs)
-
service/NSCPlugin.h (modified) (3 diffs)
-
service/NSClient++.cpp (modified) (4 diffs)
-
service/NSClient++.h (modified) (4 diffs)
-
service/channels.hpp (modified) (1 diff)
-
service/core_api.cpp (modified) (1 diff)
-
service/core_api.h (modified) (1 diff)
-
service/logger.hpp (modified) (2 diffs)
-
service/plugin_list.hpp (added)
-
service/routers.hpp (added)
Legend:
- Unmodified
- Added
- Removed
-
changelog
r4b1e6fe r81e420c 5 5 * Fixa dependonservice LanManWorkStation (old win) 6 6 * Fix RtlStringFromGUID problem on NT4 7 8 2011-08-31 MickeM 9 * Added support for loading same plugin twice (in different sessions) 10 * Added preliminary support for routing passive checks 7 11 8 12 2011-08-30 MickeM -
include/NSCAPI.h
r4b1e6fe r81e420c 74 74 const int key_integer = 200; 75 75 const int key_bool = 300; 76 77 const int message_processed = 0x01; 78 const int message_routed = 0x02; 79 const int message_ignored = 0x04; 80 const int message_digested = 0x08; 81 const int message_modified = 0x10; 76 82 77 83 typedef int nagiosReturn; … … 168 174 169 175 namespace plugin_api { 170 typedef int (*lpModuleHelperInit)(unsigned int, ::nscapi::core_api::lpNSAPILoader f); 171 typedef int (*lpLoadModule)(const wchar_t*,int); 172 typedef int (*lpGetName)(wchar_t*,unsigned int); 173 typedef int (*lpGetDescription)(wchar_t*,unsigned int); 174 typedef int (*lpGetVersion)(int*,int*,int*); 175 typedef int (*lpHasCommandHandler)(); 176 typedef int (*lpHasMessageHandler)(); 177 typedef NSCAPI::nagiosReturn (*lpHandleCommand)(const wchar_t*,const char*,const unsigned int,char**,unsigned int*); 178 typedef int (*lpDeleteBuffer)(char**); 179 typedef int (*lpCommandLineExec)(const wchar_t*,const char*,const unsigned int,char**,unsigned int*); 180 typedef int (*lpHandleMessage)(const char*); 181 typedef int (*lpUnLoadModule)(); 182 typedef void (*lpShowTray)(); 183 typedef void (*lpHideTray)(); 184 typedef int (*lpHasNotificationHandler)(); 185 typedef int (*lpHandleNotification)(const wchar_t *channel, const wchar_t* command, NSCAPI::nagiosReturn code, char* result, unsigned int result_len); 176 typedef NSCAPI::errorReturn (*lpGetName)(wchar_t*,unsigned int); 177 typedef NSCAPI::errorReturn (*lpGetDescription)(wchar_t*,unsigned int); 178 typedef NSCAPI::errorReturn (*lpModuleHelperInit)(unsigned int, ::nscapi::core_api::lpNSAPILoader f); 179 typedef NSCAPI::errorReturn (*lpGetVersion)(int* major, int* minor, int* revision); 180 typedef NSCAPI::errorReturn (*lpDeleteBuffer)(char** buffer); 181 182 typedef NSCAPI::errorReturn (*lpLoadModule)(unsigned int plugin_id, const wchar_t* alias, int mode); 183 typedef NSCAPI::errorReturn (*lpUnLoadModule)(unsigned int plugin_id); 184 185 typedef NSCAPI::errorReturn (*lpHasCommandHandler)(unsigned int plugin_id); 186 typedef NSCAPI::errorReturn (*lpHandleCommand)(unsigned int plugin_id, const wchar_t* command, const char* in_buffer, const unsigned int in_buffer_len, char** out_buffer, unsigned int* out_buffer_len); 187 188 typedef NSCAPI::errorReturn (*lpHasMessageHandler)(unsigned int plugin_id); 189 typedef NSCAPI::errorReturn (*lpHandleMessage)(unsigned int plugin_id, const char* buffer, const unsigned int buffer_len); 190 191 typedef NSCAPI::errorReturn (*lpHasNotificationHandler)(unsigned int plugin_id); 192 typedef NSCAPI::errorReturn (*lpHandleNotification)(unsigned int plugin_id, const wchar_t *channel, const wchar_t* command, const char* buffer, unsigned int buffer_len); 193 194 typedef NSCAPI::errorReturn (*lpHasRoutingHandler)(unsigned int plugin_id); 195 typedef NSCAPI::errorReturn (*lpRouteMessage)(unsigned int plugin_id, const wchar_t *channel, const wchar_t* command, const char* buffer, unsigned int buffer_len, wchar_t **new_channel_buffer, char **new_buffer, unsigned int *new_buffer_len); 196 197 typedef NSCAPI::errorReturn (*lpCommandLineExec)(unsigned int plugin_id, const wchar_t* command, const char* in_buffer ,const unsigned int in_buffer_len, char** out_buffer, unsigned int* out_buffer_len); 186 198 } 187 199 } -
include/nscapi/functions.hpp
r4b1e6fe r81e420c 105 105 106 106 107 static void create_simple_header(Plugin::Common::Header* hdr, Plugin::Common_Header_Type type) { 108 hdr->set_type(type); 107 static void create_simple_header(Plugin::Common::Header* hdr) { 109 108 hdr->set_version(Plugin::Common_Version_VERSION_1); 110 109 hdr->set_max_supported_version(Plugin::Common_Version_VERSION_1); … … 117 116 static void create_simple_query_request(std::wstring command, std::vector<std::wstring> arguments, std::string &buffer) { 118 117 Plugin::QueryRequestMessage message; 119 create_simple_header(message.mutable_header() , Plugin::Common_Header_Type_QUERY_REQUEST);118 create_simple_header(message.mutable_header()); 120 119 121 120 Plugin::QueryRequestMessage::Request *payload = message.add_payload(); … … 129 128 static void create_simple_query_request(std::wstring command, std::list<std::wstring> arguments, std::string &buffer) { 130 129 Plugin::QueryRequestMessage message; 131 create_simple_header(message.mutable_header() , Plugin::Common_Header_Type_QUERY_REQUEST);130 create_simple_header(message.mutable_header()); 132 131 133 132 Plugin::QueryRequestMessage::Request *payload = message.add_payload(); … … 146 145 static void create_simple_query_response(std::wstring command, NSCAPI::nagiosReturn ret, std::wstring msg, std::wstring perf, std::string &buffer) { 147 146 Plugin::QueryResponseMessage message; 148 create_simple_header(message.mutable_header() , Plugin::Common_Header_Type_QUERY_RESPONSE);147 create_simple_header(message.mutable_header()); 149 148 150 149 Plugin::QueryResponseMessage::Response *payload = message.add_payload(); … … 197 196 198 197 Plugin::ExecuteRequestMessage message; 199 create_simple_header(message.mutable_header() , Plugin::Common_Header_Type_EXEC_REQUEST);198 create_simple_header(message.mutable_header()); 200 199 201 200 Plugin::ExecuteRequestMessage::Request *payload = message.add_payload(); … … 210 209 211 210 Plugin::ExecuteRequestMessage message; 212 create_simple_header(message.mutable_header() , Plugin::Common_Header_Type_EXEC_REQUEST);211 create_simple_header(message.mutable_header()); 213 212 214 213 Plugin::ExecuteRequestMessage::Request *payload = message.add_payload(); … … 231 230 static void create_simple_exec_response(std::wstring command, NSCAPI::nagiosReturn ret, std::wstring result, std::string &response) { 232 231 Plugin::ExecuteResponseMessage message; 233 create_simple_header(message.mutable_header() , Plugin::Common_Header_Type_EXEC_RESPONSE);232 create_simple_header(message.mutable_header()); 234 233 235 234 Plugin::ExecuteResponseMessage::Response *payload = message.add_payload(); -
include/nscapi/macros.hpp
r4b1e6fe r81e420c 1 1 #pragma once 2 2 #include <unicode_char.hpp> 3 #include <boost/shared_ptr.hpp> 4 #include <map> 3 5 4 6 ////////////////////////////////////////////////////////////////////////// … … 7 9 extern "C" int NSModuleHelperInit(unsigned int id, nscapi::core_api::lpNSAPILoader f); \ 8 10 extern "C" int NSLoadModule(); \ 9 extern "C" int NSLoadModuleEx( wchar_t* alias, int mode); \11 extern "C" int NSLoadModuleEx(unsigned int plugin_id, wchar_t* alias, int mode); \ 10 12 extern "C" void NSDeleteBuffer(char**buffer); \ 11 13 extern "C" int NSGetModuleName(wchar_t* buf, int buflen); \ 12 14 extern "C" int NSGetModuleDescription(wchar_t* buf, int buflen); \ 13 15 extern "C" int NSGetModuleVersion(int *major, int *minor, int *revision); \ 14 extern "C" NSCAPI::boolReturn NSHasCommandHandler( ); \15 extern "C" NSCAPI::boolReturn NSHasMessageHandler( ); \16 extern "C" void NSHandleMessage( const char* data); \17 extern "C" NSCAPI::nagiosReturn NSHandleCommand( const wchar_t* command, const char* request_buffer, const unsigned int request_buffer_len, char** reply_buffer, unsigned int *reply_buffer_len); \18 extern "C" int NSUnloadModule( );16 extern "C" NSCAPI::boolReturn NSHasCommandHandler(unsigned int plugin_id); \ 17 extern "C" NSCAPI::boolReturn NSHasMessageHandler(unsigned int plugin_id); \ 18 extern "C" void NSHandleMessage(unsigned int plugin_id, const char* data, unsigned int len); \ 19 extern "C" NSCAPI::nagiosReturn NSHandleCommand(unsigned int plugin_id, const wchar_t* command, const char* request_buffer, const unsigned int request_buffer_len, char** reply_buffer, unsigned int *reply_buffer_len); \ 20 extern "C" int NSUnloadModule(unsigned int plugin_id); 19 21 20 22 21 23 #define NSC_WRAPPERS_CLI() \ 22 extern "C" int NSCommandLineExec( wchar_t *command, char *request_buffer, unsigned int request_len, char **response_buffer, unsigned int *response_len);24 extern "C" int NSCommandLineExec(unsigned int plugin_id, wchar_t *command, char *request_buffer, unsigned int request_len, char **response_buffer, unsigned int *response_len); 23 25 24 26 #define NSC_WRAPPERS_CHANNELS() \ 25 extern "C" int NSHasNotificationHandler(); \ 26 extern "C" int NSHandleNotification(const wchar_t*, const wchar_t*, NSCAPI::nagiosReturn, const char*, unsigned int); 27 extern "C" int NSHasNotificationHandler(unsigned int plugin_id); \ 28 extern "C" int NSHandleNotification(unsigned int plugin_id, const wchar_t*, const wchar_t*, NSCAPI::nagiosReturn, const char*, unsigned int); 29 30 #define NSC_WRAPPERS_ROUTING() \ 31 extern "C" int NSHasRoutingHandler(unsigned int plugin_id); \ 32 extern "C" int NSRouteMessage(unsigned int plugin_id, const wchar_t*, const wchar_t*, NSCAPI::nagiosReturn, const char*, unsigned int); 27 33 28 34 ////////////////////////////////////////////////////////////////////////// … … 70 76 #endif 71 77 72 #define NSC_WRAPPERS_MAIN_DEF(toObject) \ 78 template<class impl_type> 79 struct plugin_instance_data { 80 typedef std::map<unsigned int, boost::shared_ptr<impl_type> > plugin_list_type; 81 plugin_list_type plugins; 82 boost::shared_ptr<impl_type> get(unsigned int id) { 83 plugin_list_type::iterator it = plugins.find(id); 84 if (it != plugins.end()) 85 return it->second; 86 boost::shared_ptr<impl_type> impl = boost::shared_ptr<impl_type>(new impl_type()); 87 plugins[id] = impl; 88 return impl; 89 } 90 void erase(unsigned int id) { 91 plugins.erase(id); 92 } 93 }; 94 95 96 #define NSC_WRAPPERS_MAIN_DEF(impl_class) \ 97 static plugin_instance_data<impl_class> plugin_instance; \ 73 98 extern int NSModuleHelperInit(unsigned int id, nscapi::core_api::lpNSAPILoader f) { \ 74 99 try { \ … … 79 104 } \ 80 105 } \ 81 extern int NSLoadModuleEx( wchar_t* alias, int mode) { \82 try { \ 83 return GET_PLUGIN()->wrapLoadModule( toObject.loadModuleEx(alias, mode)); \106 extern int NSLoadModuleEx(unsigned int id, wchar_t* alias, int mode) { \ 107 try { \ 108 return GET_PLUGIN()->wrapLoadModule(plugin_instance.get(id)->loadModuleEx(alias, mode)); \ 84 109 } catch (...) { \ 85 110 NSC_LOG_CRITICAL(_T("Unknown exception in: wrapLoadModule(...)")); \ … … 88 113 } \ 89 114 extern int NSLoadModule() { \ 90 try { \91 return GET_PLUGIN()->wrapLoadModule(toObject.loadModule()); \92 } catch (...) { \93 NSC_LOG_CRITICAL(_T("Unknown exception in: wrapLoadModule(...)")); \94 115 return NSCAPI::hasFailed; \ 95 } \96 116 } \ 97 117 extern int NSGetModuleName(wchar_t* buf, int buflen) { \ 98 118 try { \ 99 return GET_PLUGIN()->wrapGetModuleName(buf, buflen, toObject.getModuleName()); \119 return GET_PLUGIN()->wrapGetModuleName(buf, buflen, impl_class::getModuleName()); \ 100 120 } catch (...) { \ 101 121 NSC_LOG_CRITICAL(_T("Unknown exception in: wrapGetModuleName(...)")); \ … … 105 125 extern int NSGetModuleDescription(wchar_t* buf, int buflen) { \ 106 126 try { \ 107 return GET_PLUGIN()->wrapGetModuleName(buf, buflen, toObject.getModuleDescription()); \127 return GET_PLUGIN()->wrapGetModuleName(buf, buflen, impl_class::getModuleDescription()); \ 108 128 } catch (...) { \ 109 129 NSC_LOG_CRITICAL(_T("Unknown exception in: wrapGetModuleName(...)")); \ … … 113 133 extern int NSGetModuleVersion(int *major, int *minor, int *revision) { \ 114 134 try { \ 115 return GET_PLUGIN()->wrapGetModuleVersion(major, minor, revision, toObject.getModuleVersion()); \135 return GET_PLUGIN()->wrapGetModuleVersion(major, minor, revision, impl_class::getModuleVersion()); \ 116 136 } catch (...) { \ 117 137 NSC_LOG_CRITICAL(_T("Unknown exception in: wrapGetModuleVersion(...)")); \ … … 119 139 } \ 120 140 } \ 121 extern int NSUnloadModule() { \ 122 try { \ 123 return GET_PLUGIN()->wrapUnloadModule(toObject.unloadModule()); \ 141 extern int NSUnloadModule(unsigned int id) { \ 142 try { \ 143 int ret = GET_PLUGIN()->wrapUnloadModule(plugin_instance.get(id)->unloadModule()); \ 144 plugin_instance.erase(id); \ 145 return ret; \ 124 146 } catch (...) { \ 125 147 NSC_LOG_CRITICAL(_T("Unknown exception in: wrapGetModuleVersion(...)")); \ … … 135 157 } 136 158 #define NSC_WRAPPERS_HANDLE_MSG_DEF(toObject) \ 137 extern void NSHandleMessage(const char* data) { \ 138 try { \ 139 toObject.handleMessageRAW(data); \ 159 extern void NSHandleMessage(unsigned int id, const char* request_buffer, unsigned int request_buffer_len) { \ 160 try { \ 161 std::string request(request_buffer, request_buffer_len); \ 162 plugin_instance.get(id)->handleMessageRAW(request); \ 140 163 } catch (...) { \ 141 164 NSC_LOG_CRITICAL(_T("Unknown exception in: handleMessage(...)")); \ 142 165 } \ 143 166 } \ 144 extern NSCAPI::boolReturn NSHasMessageHandler( ) { \145 try { \ 146 return GET_PLUGIN()->wrapHasMessageHandler( toObject.hasMessageHandler()); \167 extern NSCAPI::boolReturn NSHasMessageHandler(unsigned int id) { \ 168 try { \ 169 return GET_PLUGIN()->wrapHasMessageHandler(plugin_instance.get(id)->hasMessageHandler()); \ 147 170 } catch (...) { \ 148 171 NSC_LOG_CRITICAL(_T("Unknown exception in: wrapHasMessageHandler(...)")); \ … … 151 174 } 152 175 #define NSC_WRAPPERS_IGNORE_MSG_DEF() \ 153 extern void NSHandleMessage( const char* data) {} \154 extern NSCAPI::boolReturn NSHasMessageHandler( ) { return NSCAPI::isfalse; }155 #define NSC_WRAPPERS_HANDLE_CMD_DEF( toObject) \156 extern NSCAPI::nagiosReturn NSHandleCommand( const wchar_t* command, const char* request_buffer, const unsigned int request_buffer_len, char** reply_buffer, unsigned int *reply_buffer_len) \176 extern void NSHandleMessage(unsigned int id, const char* data, unsigned int len) {} \ 177 extern NSCAPI::boolReturn NSHasMessageHandler(unsigned int id) { return NSCAPI::isfalse; } 178 #define NSC_WRAPPERS_HANDLE_CMD_DEF() \ 179 extern NSCAPI::nagiosReturn NSHandleCommand(unsigned int id, const wchar_t* command, const char* request_buffer, const unsigned int request_buffer_len, char** reply_buffer, unsigned int *reply_buffer_len) \ 157 180 { \ 158 181 try { \ 159 182 std::string request(request_buffer, request_buffer_len), reply; \ 160 NSCAPI::nagiosReturn retCode = (&toObject)->handleRAWCommand(command, request, reply); \183 NSCAPI::nagiosReturn retCode = plugin_instance.get(id)->handleRAWCommand(command, request, reply); \ 161 184 return GET_PLUGIN()->wrapHandleCommand(retCode, reply, reply_buffer, reply_buffer_len); \ 162 185 } catch (...) { \ … … 165 188 } \ 166 189 } \ 167 extern NSCAPI::boolReturn NSHasCommandHandler( ) { \168 try { \ 169 return GET_PLUGIN()->wrapHasCommandHandler( toObject.hasCommandHandler()); \190 extern NSCAPI::boolReturn NSHasCommandHandler(unsigned int id) { \ 191 try { \ 192 return GET_PLUGIN()->wrapHasCommandHandler(plugin_instance.get(id)->hasCommandHandler()); \ 170 193 } catch (...) { \ 171 194 NSC_LOG_CRITICAL(_T("Unknown exception in: wrapHasCommandHandler(...)")); \ … … 173 196 } \ 174 197 } 198 #define NSC_WRAPPERS_ROUTING_DEF() \ 199 extern NSCAPI::nagiosReturn NSRouteMessage(unsigned int id, const wchar_t* channel, const wchar_t* command, const char* request_buffer, const unsigned int request_buffer_len) \ 200 { \ 201 try { \ 202 std::string request(request_buffer, request_buffer_len), reply; \ 203 return GET_PLUGIN()->wrapRouteMessage(plugin_instance.get(id)->RAWRouteMessage(channel, command, request)); \ 204 } catch (...) { \ 205 NSC_LOG_CRITICAL(_T("Unknown exception in: wrapHandleCommand(...)")); \ 206 return NSCAPI::returnIgnored; \ 207 } \ 208 } \ 209 extern NSCAPI::boolReturn NSHasRoutingHandler(unsigned int id) { \ 210 try { \ 211 return GET_PLUGIN()->wrapHasRoutingHandler(plugin_instance.get(id)->hasRoutingHandler()); \ 212 } catch (...) { \ 213 NSC_LOG_CRITICAL(_T("Unknown exception in: wrapHasCommandHandler(...)")); \ 214 return NSCAPI::isfalse; \ 215 } \ 216 } 175 217 #define NSC_WRAPPERS_IGNORE_CMD_DEF() \ 176 extern NSCAPI::nagiosReturn NSHandleCommand( const wchar_t* IN_cmd, const unsigned int IN_argsLen, wchar_t **IN_args, \218 extern NSCAPI::nagiosReturn NSHandleCommand(unsigned int id, const wchar_t* IN_cmd, const unsigned int IN_argsLen, wchar_t **IN_args, \ 177 219 wchar_t *OUT_retBufMessage, unsigned int IN_retBufMessageLen, wchar_t *OUT_retBufPerf, unsigned int IN_retBufPerfLen) { \ 178 220 return NSCAPI::returnIgnored; \ 179 221 } \ 180 extern NSCAPI::boolReturn NSHasCommandHandler( ) { return NSCAPI::isfalse; }222 extern NSCAPI::boolReturn NSHasCommandHandler(unsigned int id) { return NSCAPI::isfalse; } 181 223 #define NSC_WRAPPERS_IGNORE_NOTIFICATION_DEF() \ 182 224 extern void NSHandleNotification(const wchar_t*, const wchar_t*, NSCAPI::nagiosReturn, const char*, unsigned int) {} \ 183 extern NSCAPI::boolReturn NSHasNotificationHandler( ) { return NSCAPI::isfalse; }184 #define NSC_WRAPPERS_HANDLE_NOTIFICATION_DEF( toObject) \185 extern NSCAPI::nagiosReturn NSHandleNotification( const wchar_t* channel, const wchar_t* command, NSCAPI::nagiosReturn code, const char* result_buffer, unsigned int result_buffer_len) \225 extern NSCAPI::boolReturn NSHasNotificationHandler(unsigned int id) { return NSCAPI::isfalse; } 226 #define NSC_WRAPPERS_HANDLE_NOTIFICATION_DEF() \ 227 extern NSCAPI::nagiosReturn NSHandleNotification(unsigned int id, const wchar_t* channel, const wchar_t* command, NSCAPI::nagiosReturn code, const char* result_buffer, unsigned int result_buffer_len) \ 186 228 { \ 187 229 try { \ 188 230 std::string result(result_buffer, result_buffer_len); \ 189 return GET_PLUGIN()->wrapHandleNotification( (&toObject)->handleRAWNotification(channel, command, code, result)); \231 return GET_PLUGIN()->wrapHandleNotification(plugin_instance.get(id)->handleRAWNotification(channel, command, code, result)); \ 190 232 } catch (...) { \ 191 233 NSC_LOG_CRITICAL(_T("Unknown exception in: wrapHasNotificationHandler(...)")); \ … … 193 235 } \ 194 236 } \ 195 extern NSCAPI::boolReturn NSHasNotificationHandler( ) { \196 try { \ 197 return GET_PLUGIN()->wrapHasNotificationHandler( toObject.hasNotificationHandler()); \237 extern NSCAPI::boolReturn NSHasNotificationHandler(unsigned int id) { \ 238 try { \ 239 return GET_PLUGIN()->wrapHasNotificationHandler(plugin_instance.get(id)->hasNotificationHandler()); \ 198 240 } catch (...) { \ 199 241 NSC_LOG_CRITICAL(_T("Unknown exception in: wrapHasNotificationHandler(...)")); \ … … 203 245 204 246 205 #define NSC_WRAPPERS_CLI_DEF( toObject) \206 extern int NSCommandLineExec( wchar_t *command, char *request_buffer, unsigned int request_len, char **response_buffer, unsigned int *response_len) { \247 #define NSC_WRAPPERS_CLI_DEF() \ 248 extern int NSCommandLineExec(unsigned int id, wchar_t *command, char *request_buffer, unsigned int request_len, char **response_buffer, unsigned int *response_len) { \ 207 249 try { \ 208 250 std::string request = std::string(request_buffer, request_len); \ 209 251 std::string response; \ 210 NSCAPI::nagiosReturn retCode = (&toObject)->commandRAWLineExec(command, request, response); \252 NSCAPI::nagiosReturn retCode = plugin_instance.get(id)->commandRAWLineExec(command, request, response); \ 211 253 return GET_PLUGIN()->wrapCommandLineExec(retCode, response, response_buffer, response_len); \ 212 254 } catch (const std::exception &e) { \ … … 220 262 } \ 221 263 } \ 222 223 264 224 265 -
include/nscapi/nscapi_plugin_wrapper.cpp
rd7e265d r81e420c 135 135 return has?NSCAPI::istrue:NSCAPI::isfalse; 136 136 } 137 NSCAPI::boolReturn nscapi::plugin_wrapper::wrapHasRoutingHandler(bool has) { 138 return has?NSCAPI::istrue:NSCAPI::isfalse; 139 } 137 140 138 141 NSCAPI::nagiosReturn nscapi::plugin_wrapper::wrapHandleNotification(NSCAPI::nagiosReturn retResult) { 142 return retResult; 143 } 144 NSCAPI::nagiosReturn nscapi::plugin_wrapper::wrapRouteMessage(NSCAPI::nagiosReturn retResult) { 139 145 return retResult; 140 146 } -
include/nscapi/nscapi_plugin_wrapper.hpp
rb38e845 r81e420c 66 66 NSCAPI::boolReturn wrapHasCommandHandler(bool has); 67 67 NSCAPI::boolReturn wrapHasMessageHandler(bool has); 68 NSCAPI::boolReturn wrapHasRoutingHandler(bool has); 68 69 NSCAPI::boolReturn wrapHasNotificationHandler(bool has); 69 70 NSCAPI::nagiosReturn wrapHandleNotification(NSCAPI::nagiosReturn retResult); … … 71 72 NSCAPI::nagiosReturn wrapHandleCommand(NSCAPI::nagiosReturn retResult, const std::string &reply, char **reply_buffer, unsigned int *size); 72 73 NSCAPI::nagiosReturn wrapCommandLineExec(NSCAPI::nagiosReturn retResult, const std::string &reply, char **reply_buffer, unsigned int *size); 74 NSCAPI::nagiosReturn wrapRouteMessage(NSCAPI::nagiosReturn retResult); 73 75 74 76 void wrapDeleteBuffer(char**buffer); -
libs/protobuf/plugin.proto
rb38e845 r81e420c 23 23 optional bool bool_data = 5; 24 24 } 25 26 message KeyValue { 27 required string key = 1; 28 required string value = 2; 29 repeated string data = 3; 30 } 25 31 26 32 … … 30 36 31 37 message Header { 32 enum Type { 33 QUERY_REQUEST = 1; 34 QUERY_RESPONSE = 2; 35 36 EXEC_REQUEST = 3; 37 EXEC_RESPONSE = 4; 38 39 LOG_MESSAGE = 5; 40 }; 41 required Type type = 1; 42 required Common.Version version = 2; 43 optional Common.Version max_supported_version = 3; 44 45 optional string sender = 17; 46 optional string recipient = 18; 47 optional int64 id = 19; 48 }; 49 38 39 required Common.Version version = 1; 40 optional Common.Version max_supported_version = 2; 41 42 optional string sender = 3; 43 optional string recipient = 4; 44 45 optional int64 id = 16; 46 47 repeated Common.KeyValue metadata = 5; 48 repeated string tags = 6; 49 }; 50 51 message Attachment { 52 53 optional int64 id = 1; 54 required string type = 2; 55 repeated Common.KeyValue metadata = 3; 56 repeated string tags = 4; 57 required string data = 5; 58 }; 59 50 60 message PerformanceData { 51 61 message IntValue { … … 97 107 required string command = 2; 98 108 repeated string arguments = 3; 109 repeated Common.Attachment attachments = 17; 99 110 }; 100 111 101 112 required Common.Header header = 1; 102 113 repeated Request payload = 2; 114 repeated Common.Attachment attachments = 3; 103 115 } 104 116 message QueryResponseMessage { … … 112 124 required Common.ResultCode result = 3; 113 125 required string message = 4; 114 optional string legacyPerf = 17;115 126 repeated Common.PerformanceData perf = 5; 127 repeated Common.Attachment attachments = 17; 116 128 117 129 } … … 119 131 required Common.Header header = 1; 120 132 repeated Response payload = 2; 133 repeated Common.Attachment attachments = 3; 121 134 } 122 135 … … 160 173 required string command = 2; 161 174 repeated string arguments = 3; 175 repeated Common.Attachment attachments = 17; 162 176 }; 163 177 164 178 required Common.Header header = 1; 165 179 repeated Request payload = 2; 180 repeated Common.Attachment attachments = 3; 166 181 } 167 182 message ExecuteResponseMessage { … … 190 205 191 206 optional ResponseData data = 11; 207 repeated Common.Attachment attachments = 17; 192 208 193 209 } 194 210 required Common.Header header = 1; 195 211 repeated Response payload = 2; 212 repeated Common.Attachment attachments = 3; 196 213 } 197 214 … … 206 223 required Common.Header header = 1; 207 224 repeated QueryResponseMessage.Response payload = 2; 225 repeated Common.Attachment attachments = 3; 208 226 } 209 227 -
modules/CheckDisk/CheckDisk.cpp
r4b1e6fe r81e420c 41 41 42 42 namespace sh = nscapi::settings_helper; 43 44 CheckDisk gCheckDisk;45 43 46 44 CheckDisk::CheckDisk() : show_errors_(false) { … … 787 785 788 786 NSC_WRAP_DLL(); 789 NSC_WRAPPERS_MAIN_DEF( gCheckDisk);787 NSC_WRAPPERS_MAIN_DEF(CheckDisk); 790 788 NSC_WRAPPERS_IGNORE_MSG_DEF(); 791 NSC_WRAPPERS_HANDLE_CMD_DEF( gCheckDisk);789 NSC_WRAPPERS_HANDLE_CMD_DEF(); -
modules/CheckDisk/CheckDisk.h
rfe75eff r81e420c 38 38 bool unloadModule(); 39 39 40 st d::wstring getModuleName() {40 static std::wstring getModuleName() { 41 41 return _T("CheckDisk"); 42 42 } 43 st d::wstring getModuleDescription() {43 static std::wstring getModuleDescription() { 44 44 return _T("CheckDisk can check various file and disk related things.\nThe current version has commands to check Size of hard drives and directories."); 45 45 } 46 nscapi::plugin_wrapper::module_version getModuleVersion() {46 static nscapi::plugin_wrapper::module_version getModuleVersion() { 47 47 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 48 48 return version; -
modules/CheckEventLog/CheckEventLog.cpp
r4b1e6fe r81e420c 51 51 #include "simple_registry.hpp" 52 52 #include "eventlog_record.hpp" 53 54 CheckEventLog gCheckEventLog;55 53 56 54 CheckEventLog::CheckEventLog() { … … 375 373 376 374 NSC_WRAP_DLL(); 377 NSC_WRAPPERS_MAIN_DEF( gCheckEventLog);375 NSC_WRAPPERS_MAIN_DEF(CheckEventLog); 378 376 NSC_WRAPPERS_IGNORE_MSG_DEF(); 379 NSC_WRAPPERS_HANDLE_CMD_DEF( gCheckEventLog);377 NSC_WRAPPERS_HANDLE_CMD_DEF(); -
modules/CheckEventLog/CheckEventLog.h
rfe75eff r81e420c 27 27 28 28 29 class CheckEventLog : public nscapi::impl::simple_command, nscapi::impl::simple_plugin {29 class CheckEventLog : public nscapi::impl::simple_command, nscapi::impl::simple_plugin { 30 30 private: 31 31 bool debug_; … … 42 42 bool unloadModule(); 43 43 44 st d::wstring getModuleName() {44 static std::wstring getModuleName() { 45 45 return _T("Event log Checker."); 46 46 } 47 nscapi::plugin_wrapper::module_version getModuleVersion() {47 static nscapi::plugin_wrapper::module_version getModuleVersion() { 48 48 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 49 49 return version; 50 50 } 51 st d::wstring getModuleDescription() {51 static std::wstring getModuleDescription() { 52 52 return _T("Check for errors and warnings in the event log.\nThis is only supported through NRPE so if you plan to use only NSClient this wont help you at all."); 53 53 } -
modules/CheckExternalScripts/CheckExternalScripts.cpp
rd7e265d r81e420c 34 34 35 35 namespace sh = nscapi::settings_helper; 36 37 38 CheckExternalScripts gCheckExternalScripts;39 36 40 37 CheckExternalScripts::CheckExternalScripts() {} … … 198 195 } 199 196 } 200 //201 //202 //203 // std::wstring msg, perf;204 // NSCAPI::nagiosReturn ret = handleCommand(data.command, data.args, msg, perf);205 // return nscapi::functions::process_simple_command_result(data.command, ret, msg, perf);206 // }207 //208 // NSCAPI::nagiosReturn CheckExternalScripts::handleCommand(const std::wstring command, std::list<std::wstring> arguments, std::wstring &message, std::wstring &perf) {209 // command_list::const_iterator cit = commands.find(command);210 // bool isAlias = false;211 // if (cit == commands.end()) {212 // cit = alias.find(command);213 // if (cit == alias.end())214 // return NSCAPI::returnIgnored;215 // isAlias = true;216 // }217 //218 // const command_data cd = (*cit).second;219 // std::wstring args = cd.arguments;220 // if (isAlias || allowArgs_) {221 // int i=1;222 // BOOST_FOREACH(std::wstring str, arguments) {223 // if (!isAlias && !allowNasty_) {224 // if (str.find_first_of(NASTY_METACHARS) != std::wstring::npos) {225 // NSC_LOG_ERROR(_T("Request string contained illegal metachars!"));226 // return NSCAPI::returnIgnored;227 // }228 // }229 // strEx::replace(args, _T("$ARG") + strEx::itos(i++) + _T("$"), str);230 // }231 // }232 // if (isAlias) {233 // try {234 // return GET_CORE()->InjectSplitAndCommand(cd.command, args, ' ', message, perf, true);235 // } catch (boost::escaped_list_error &e) {236 // NSC_LOG_MESSAGE(_T("Failed to parse alias expression: ") + strEx::string_to_wstring(e.what()));237 // NSC_LOG_MESSAGE(_T("We will now try parsing the old syntax instead..."));238 // return GET_CORE()->InjectSplitAndCommand(cd.command, args, ' ', message, perf, false);239 // }240 // } else {241 // int result = process::executeProcess(process::exec_arguments(root_, cd.command + _T(" ") + args, timeout), message, perf);242 // if (!nscapi::plugin_helper::isNagiosReturnCode(result)) {243 // NSC_LOG_ERROR_STD(_T("The command (") + cd.command + _T(") returned an invalid return code: ") + strEx::itos(result));244 // return NSCAPI::returnUNKNOWN;245 // }246 // return nscapi::plugin_helper::int2nagios(result);247 // }248 //249 // }250 251 252 197 NSC_WRAP_DLL(); 253 NSC_WRAPPERS_MAIN_DEF( gCheckExternalScripts);198 NSC_WRAPPERS_MAIN_DEF(CheckExternalScripts); 254 199 NSC_WRAPPERS_IGNORE_MSG_DEF(); 255 NSC_WRAPPERS_HANDLE_CMD_DEF( gCheckExternalScripts);256 200 NSC_WRAPPERS_HANDLE_CMD_DEF(); 201 -
modules/CheckExternalScripts/CheckExternalScripts.h
rc391984 r81e420c 80 80 81 81 82 st d::wstring getModuleName() {82 static std::wstring getModuleName() { 83 83 return _T("Check External Scripts"); 84 84 } 85 nscapi::plugin_wrapper::module_version getModuleVersion() {85 static nscapi::plugin_wrapper::module_version getModuleVersion() { 86 86 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 87 87 return version; 88 88 } 89 st d::wstring getModuleDescription() {89 static std::wstring getModuleDescription() { 90 90 return _T("A simple wrapper to run external scripts and batch files."); 91 91 } -
modules/CheckHelpers/CheckHelpers.cpp
r4b1e6fe r81e420c 31 31 #include <settings/client/settings_client.hpp> 32 32 33 34 CheckHelpers gCheckHelpers;35 36 33 CheckHelpers::CheckHelpers() { 37 34 } … … 332 329 333 330 NSC_WRAP_DLL(); 334 NSC_WRAPPERS_MAIN_DEF( gCheckHelpers);331 NSC_WRAPPERS_MAIN_DEF(CheckHelpers); 335 332 NSC_WRAPPERS_IGNORE_MSG_DEF(); 336 NSC_WRAPPERS_HANDLE_CMD_DEF( gCheckHelpers);333 NSC_WRAPPERS_HANDLE_CMD_DEF(); -
modules/CheckHelpers/CheckHelpers.h
rfe75eff r81e420c 35 35 36 36 37 st d::wstring getModuleName() {37 static std::wstring getModuleName() { 38 38 return _T("Helper function"); 39 39 } 40 nscapi::plugin_wrapper::module_version getModuleVersion() {40 static nscapi::plugin_wrapper::module_version getModuleVersion() { 41 41 nscapi::plugin_wrapper::module_version version = {0, 3, 0 }; 42 42 return version; 43 43 } 44 st d::wstring getModuleDescription() {44 static std::wstring getModuleDescription() { 45 45 return _T("Various helper function to extend other checks.\nThis is also only supported through NRPE."); 46 46 } -
modules/CheckNSCP/CheckNSCP.cpp
r4b1e6fe r81e420c 26 26 #include <settings/client/settings_client.hpp> 27 27 namespace sh = nscapi::settings_helper; 28 29 CheckNSCP gCheckNSCP;30 31 32 28 33 29 bool CheckNSCP::loadModule() { … … 163 159 164 160 NSC_WRAP_DLL(); 165 NSC_WRAPPERS_MAIN_DEF( gCheckNSCP);166 NSC_WRAPPERS_HANDLE_MSG_DEF( gCheckNSCP);167 NSC_WRAPPERS_HANDLE_CMD_DEF( gCheckNSCP);161 NSC_WRAPPERS_MAIN_DEF(CheckNSCP); 162 NSC_WRAPPERS_HANDLE_MSG_DEF(); 163 NSC_WRAPPERS_HANDLE_CMD_DEF(); -
modules/CheckNSCP/CheckNSCP.h
rfe75eff r81e420c 47 47 48 48 49 st d::wstring getModuleName() {49 static std::wstring getModuleName() { 50 50 return _T("Check NSCP"); 51 51 } 52 nscapi::plugin_wrapper::module_version getModuleVersion() {52 static nscapi::plugin_wrapper::module_version getModuleVersion() { 53 53 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 54 54 return version; 55 55 } 56 st d::wstring getModuleDescription() {56 static std::wstring getModuleDescription() { 57 57 return _T("Checkes the state of the agent"); 58 58 } -
modules/CheckSystem/CheckSystem.cpp
r4b1e6fe r81e420c 38 38 #include <settings/client/settings_client.hpp> 39 39 #include <arrayBuffer.h> 40 41 CheckSystem gCheckSystem;42 40 43 41 /** … … 1625 1623 1626 1624 NSC_WRAP_DLL(); 1627 NSC_WRAPPERS_MAIN_DEF( gCheckSystem);1625 NSC_WRAPPERS_MAIN_DEF(CheckSystem); 1628 1626 NSC_WRAPPERS_IGNORE_MSG_DEF(); 1629 NSC_WRAPPERS_HANDLE_CMD_DEF( gCheckSystem);1627 NSC_WRAPPERS_HANDLE_CMD_DEF(); 1630 1628 //NSC_WRAPPERS_CLI_DEF(gCheckSystem); 1631 1629 -
modules/CheckSystem/CheckSystem.h
rfe75eff r81e420c 59 59 * @return The module name 60 60 */ 61 st d::wstring getModuleName() {61 static std::wstring getModuleName() { 62 62 return _T("CheckSystem"); 63 63 } … … 66 66 * @return module version 67 67 */ 68 nscapi::plugin_wrapper::module_version getModuleVersion() {68 static nscapi::plugin_wrapper::module_version getModuleVersion() { 69 69 nscapi::plugin_wrapper::module_version version = {0, 3, 0 }; 70 70 return version; 71 71 } 72 st d::wstring getModuleDescription() {72 static std::wstring getModuleDescription() { 73 73 return _T("Various system related checks, such as CPU load, process state, service state memory usage and PDH counters."); 74 74 } -
modules/CheckTaskSched/CheckTaskSched.cpp
r4b1e6fe r81e420c 38 38 #include "settings.hpp" 39 39 40 41 CheckTaskSched gCheckTaskSched;42 40 43 41 bool CheckTaskSched::loadModule() { … … 184 182 185 183 NSC_WRAP_DLL(); 186 NSC_WRAPPERS_MAIN_DEF( gCheckTaskSched);184 NSC_WRAPPERS_MAIN_DEF(CheckTaskSched); 187 185 NSC_WRAPPERS_IGNORE_MSG_DEF(); 188 NSC_WRAPPERS_HANDLE_CMD_DEF( gCheckTaskSched);186 NSC_WRAPPERS_HANDLE_CMD_DEF(); 189 187 //NSC_WRAPPERS_CLI_DEF(gCheckTaskSched); -
modules/CheckTaskSched/CheckTaskSched.h
rfe75eff r81e420c 38 38 bool unloadModule(); 39 39 40 st d::wstring getModuleName() {40 static std::wstring getModuleName() { 41 41 return _T("CheckTaskSched"); 42 42 } 43 st d::wstring getModuleDescription() {43 static std::wstring getModuleDescription() { 44 44 return _T("CheckTaskSched can check various file and disk related things.\nThe current version has commands to check Size of hard drives and directories."); 45 45 } 46 nscapi::plugin_wrapper::module_version getModuleVersion() {46 static nscapi::plugin_wrapper::module_version getModuleVersion() { 47 47 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 48 48 return version; -
modules/CheckTaskSched2/CheckTaskSched2.cpp
r4b1e6fe r81e420c 37 37 #include <settings/client/settings_client.hpp> 38 38 #include "../CheckTaskSched/settings.hpp" 39 40 CheckTaskSched2 gCheckTaskSched2;41 39 42 40 bool CheckTaskSched2::loadModule() { … … 183 181 184 182 NSC_WRAP_DLL(); 185 NSC_WRAPPERS_MAIN_DEF( gCheckTaskSched2);183 NSC_WRAPPERS_MAIN_DEF(CheckTaskSched2); 186 184 NSC_WRAPPERS_IGNORE_MSG_DEF(); 187 NSC_WRAPPERS_HANDLE_CMD_DEF( gCheckTaskSched2);185 NSC_WRAPPERS_HANDLE_CMD_DEF(CheckTaskSched2); 188 186 //NSC_WRAPPERS_CLI_DEF(gCheckTaskSched); -
modules/CheckTaskSched2/CheckTaskSched2.h
rfe75eff r81e420c 38 38 bool unloadModule(); 39 39 40 st d::wstring getModuleName() {40 static std::wstring getModuleName() { 41 41 return _T("CheckTaskSched2"); 42 42 } 43 st d::wstring getModuleDescription() {43 static std::wstring getModuleDescription() { 44 44 return _T("CheckTaskSched2 can check various file and disk related things.\nThe current version has commands to check Size of hard drives and directories."); 45 45 } 46 nscapi::plugin_wrapper::module_version getModuleVersion() {46 static nscapi::plugin_wrapper::module_version getModuleVersion() { 47 47 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 48 48 return version; -
modules/CheckWMI/CheckWMI.cpp
r4b1e6fe r81e420c 32 32 33 33 #include <arrayBuffer.h> 34 35 CheckWMI gCheckWMI;36 34 37 35 CheckWMI::CheckWMI() { … … 443 441 444 442 NSC_WRAP_DLL(); 445 NSC_WRAPPERS_MAIN_DEF( gCheckWMI);443 NSC_WRAPPERS_MAIN_DEF(CheckWMI); 446 444 NSC_WRAPPERS_IGNORE_MSG_DEF(); 447 NSC_WRAPPERS_HANDLE_CMD_DEF( gCheckWMI);445 NSC_WRAPPERS_HANDLE_CMD_DEF(); 448 446 //NSC_WRAPPERS_CLI_DEF(gCheckWMI); -
modules/CheckWMI/CheckWMI.h
rfe75eff r81e420c 97 97 bool unloadModule(); 98 98 99 st d::wstring getModuleName() {99 static std::wstring getModuleName() { 100 100 return _T("CheckWMI"); 101 101 } 102 st d::wstring getModuleDescription() {102 static std::wstring getModuleDescription() { 103 103 return _T("CheckWMI can check various file and disk related things.\nThe current version has commands to check Size of hard drives and directories."); 104 104 } 105 nscapi::plugin_wrapper::module_version getModuleVersion() {105 static nscapi::plugin_wrapper::module_version getModuleVersion() { 106 106 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 107 107 return version; -
modules/FileLogger/FileLogger.cpp
r4b1e6fe r81e420c 36 36 37 37 namespace sh = nscapi::settings_helper; 38 39 FileLogger gFileLogger;40 38 41 39 FileLogger::FileLogger() : init_(false) { … … 232 230 233 231 NSC_WRAP_DLL(); 234 NSC_WRAPPERS_MAIN_DEF( gFileLogger);235 NSC_WRAPPERS_HANDLE_MSG_DEF( gFileLogger);232 NSC_WRAPPERS_MAIN_DEF(FileLogger); 233 NSC_WRAPPERS_HANDLE_MSG_DEF(); 236 234 NSC_WRAPPERS_IGNORE_CMD_DEF(); -
modules/FileLogger/FileLogger.h
r3bdaf18 r81e420c 44 44 45 45 46 st d::wstring getModuleName() {46 static std::wstring getModuleName() { 47 47 return _T("File logger"); 48 48 } 49 nscapi::plugin_wrapper::module_version getModuleVersion() {49 static nscapi::plugin_wrapper::module_version getModuleVersion() { 50 50 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 51 51 return version; 52 52 } 53 st d::wstring getModuleDescription() {53 static std::wstring getModuleDescription() { 54 54 return _T("Writes errors and (if configured) debug info to a text file."); 55 55 } -
modules/LUAScript/LUAScript.cpp
rfe75eff r81e420c 29 29 #include <settings/client/settings_client.hpp> 30 30 31 32 LUAScript gLUAScript;33 31 34 32 LUAScript::LUAScript() { … … 183 181 184 182 NSC_WRAP_DLL(); 185 NSC_WRAPPERS_MAIN_DEF( gLUAScript);183 NSC_WRAPPERS_MAIN_DEF(LUAScript); 186 184 NSC_WRAPPERS_IGNORE_MSG_DEF(); 187 NSC_WRAPPERS_HANDLE_CMD_DEF( gLUAScript);185 NSC_WRAPPERS_HANDLE_CMD_DEF(); -
modules/LUAScript/LUAScript.h
rfe75eff r81e420c 65 65 bool reload(std::wstring &msg); 66 66 67 st d::wstring getModuleName() {67 static std::wstring getModuleName() { 68 68 return _T("LUAScript"); 69 69 } 70 st d::wstring getModuleDescription() {70 static std::wstring getModuleDescription() { 71 71 return _T("LUAScript..."); 72 72 } 73 nscapi::plugin_wrapper::module_version getModuleVersion() {73 static nscapi::plugin_wrapper::module_version getModuleVersion() { 74 74 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 75 75 return version; -
modules/NRPEClient/NRPEClient.cpp
rd7e265d r81e420c 88 88 namespace sh = nscapi::settings_helper; 89 89 90 NRPEClient gNRPEClient;91 92 90 NRPEClient::NRPEClient() : buffer_length_(0) { 93 91 } … … 320 318 321 319 NSC_WRAP_DLL(); 322 NSC_WRAPPERS_MAIN_DEF( gNRPEClient);320 NSC_WRAPPERS_MAIN_DEF(NRPEClient); 323 321 NSC_WRAPPERS_IGNORE_MSG_DEF(); 324 NSC_WRAPPERS_HANDLE_CMD_DEF( gNRPEClient);325 NSC_WRAPPERS_CLI_DEF( gNRPEClient);326 322 NSC_WRAPPERS_HANDLE_CMD_DEF(); 323 NSC_WRAPPERS_CLI_DEF(); 324 -
modules/NRPEClient/NRPEClient.h
rfe75eff r81e420c 101 101 102 102 103 st d::wstring getModuleName() {103 static std::wstring getModuleName() { 104 104 #ifdef USE_SSL 105 105 return _T("NRPE client (w/ SSL)"); … … 108 108 #endif 109 109 } 110 nscapi::plugin_wrapper::module_version getModuleVersion() {110 static nscapi::plugin_wrapper::module_version getModuleVersion() { 111 111 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 112 112 return version; 113 113 } 114 st d::wstring getModuleDescription() {114 static std::wstring getModuleDescription() { 115 115 return _T("A simple client for checking remote NRPE servers (think proxy).\n") 116 116 #ifndef USE_BOOST -
modules/NRPEServer/NRPEServer.cpp
rb9498ef r81e420c 32 32 namespace sh = nscapi::settings_helper; 33 33 34 NRPEListener gNRPEListener;35 34 36 35 NRPEListener::NRPEListener() : info_(boost::shared_ptr<nrpe::server::handler>(new handler_impl(1024))) { … … 183 182 } 184 183 185 186 187 188 // void NRPEListener::onAccept(simpleSocket::Socket *client)189 // {190 // if (!allowedHosts.inAllowedHosts(client->getAddr())) {191 // NSC_LOG_ERROR(_T("Unauthorize access from: ") + client->getAddrString());192 // client->close();193 // return;194 // }195 // try {196 // simpleSocket::DataBuffer block;197 // int i;198 // int maxWait = socketTimeout_*10;199 // for (i=0;i<maxWait;i++) {200 // bool lastReadHasMore = false;201 // try {202 // lastReadHasMore = client->readAll(block, 1048);203 // } catch (simpleSocket::SocketException e) {204 // NSC_LOG_MESSAGE(_T("Could not read NRPE packet from socket :") + e.getMessage());205 // client->close();206 // return;207 // }208 // if (block.getLength() >= NRPEPacket::getBufferLength(buffer_length_))209 // break;210 // if (!lastReadHasMore) {211 // NSC_LOG_MESSAGE(_T("Could not read a full NRPE packet from socket, only got: ") + strEx::itos(block.getLength()));212 // client->close();213 // return;214 // }215 // Sleep(100);216 // }217 // if (i >= maxWait) {218 // NSC_LOG_ERROR_STD(_T("Timeout reading NRPE-packet (increase socket_timeout), we only got: ") + strEx::itos(block.getLength()));219 // client->close();220 // return;221 // }222 // if (block.getLength() == NRPEPacket::getBufferLength(buffer_length_)) {223 // try {224 // NRPEPacket out = handlePacket(NRPEPacket(block.getBuffer(), block.getLength(), buffer_length_));225 // block.copyFrom(out.getBuffer(), out.getBufferLength());226 // } catch (NRPEPacket::NRPEPacketException e) {227 // NSC_LOG_ERROR_STD(_T("NRPESocketException: ") + e.getMessage());228 // try {229 // NRPEPacket err(NRPEPacket::responsePacket, NRPEPacket::version2, NSCAPI::returnUNKNOWN, _T("Could not construct return paket in NRPE handler check clientside (nsclient.log) logs..."), buffer_length_);230 // block.copyFrom(err.getBuffer(), err.getBufferLength());231 // } catch (NRPEPacket::NRPEPacketException e) {232 // NSC_LOG_ERROR_STD(_T("NRPESocketException (again): ") + e.getMessage());233 // client->close();234 // return;235 // }236 // }237 // int maxWait = socketTimeout_*10;238 // for (i=0;i<maxWait;i++) {239 // bool lastReadHasMore = false;240 // try {241 // if (client->canWrite())242 // lastReadHasMore = client->sendAll(block);243 // } catch (simpleSocket::SocketException e) {244 // NSC_LOG_MESSAGE(_T("Could not send NRPE packet from socket :") + e.getMessage());245 // client->close();246 // return;247 // }248 // if (!lastReadHasMore) {249 // client->close();250 // return;251 // }252 // Sleep(100);253 // }254 // if (i >= maxWait) {255 // NSC_LOG_ERROR_STD(_T("Timeout reading NRPE-packet (increase socket_timeout)"));256 // client->close();257 // return;258 // }259 // } else {260 // NSC_LOG_ERROR_STD(_T("We got more then we wanted ") + strEx::itos(NRPEPacket::getBufferLength(buffer_length_)) + _T(", we only got: ") + strEx::itos(block.getLength()));261 // client->close();262 // return;263 // }264 // } catch (simpleSocket::SocketException e) {265 // NSC_LOG_ERROR_STD(_T("SocketException: ") + e.getMessage());266 // } catch (NRPEException e) {267 // NSC_LOG_ERROR_STD(_T("NRPEException: ") + e.getMessage());268 // } catch (...) {269 // NSC_LOG_ERROR_STD(_T("Unhandled Exception in NRPE listner..."));270 // }271 // client->close();272 // }273 //274 // NRPEPacket NRPEListener::handlePacket(NRPEPacket p) {275 // if (p.getType() != NRPEPacket::queryPacket) {276 // NSC_LOG_ERROR(_T("Request is not a query."));277 // throw NRPEException(_T("Invalid query type: ") + strEx::itos(p.getType()));278 // }279 // if (p.getVersion() != NRPEPacket::version2) {280 // NSC_LOG_ERROR(_T("Request had unsupported version."));281 // throw NRPEException(_T("Invalid version"));282 // }283 // if (!p.verifyCRC()) {284 // NSC_LOG_ERROR(_T("Request had invalid checksum."));285 // throw NRPEException(_T("Invalid checksum"));286 // }287 // strEx::token cmd = strEx::getToken(p.getPayload(), '!');288 // if (cmd.first == _T("_NRPE_CHECK")) {289 // return NRPEPacket(NRPEPacket::responsePacket, NRPEPacket::version2, NSCAPI::returnOK, _T("I (") + NSCModuleHelper::getApplicationVersionString() + _T(") seem to be doing fine..."), buffer_length_);290 // }291 // std::wstring msg, perf;292 //293 // if (allowArgs_) {294 // if (!cmd.second.empty()) {295 // NSC_LOG_ERROR(_T("Request contained arguments (not currently allowed, check the allow_arguments option)."));296 // throw NRPEException(_T("Request contained arguments (not currently allowed, check the allow_arguments option)."));297 // }298 // }299 // if (allowNasty_) {300 // if (cmd.first.find_first_of(NASTY_METACHARS) != std::wstring::npos) {301 // NSC_LOG_ERROR(_T("Request command contained illegal metachars!"));302 // throw NRPEException(_T("Request command contained illegal metachars!"));303 // }304 // if (cmd.second.find_first_of(NASTY_METACHARS) != std::wstring::npos) {305 // NSC_LOG_ERROR(_T("Request arguments contained illegal metachars!"));306 // throw NRPEException(_T("Request command contained illegal metachars!"));307 // }308 // }309 // //TODO REMOVE THIS310 // //return NRPEPacket(NRPEPacket::responsePacket, NRPEPacket::version2, NSCAPI::returnUNKNOWN, _T("TEST TEST TEST"), buffer_length_);311 //312 // NSCAPI::nagiosReturn ret = -3;313 // try {314 // ret = NSCModuleHelper::InjectSplitAndCommand(cmd.first, cmd.second, '!', msg, perf);315 // } catch (...) {316 // return NRPEPacket(NRPEPacket::responsePacket, NRPEPacket::version2, NSCAPI::returnUNKNOWN, _T("UNKNOWN: Internal exception"), buffer_length_);317 // }318 // switch (ret) {319 // case NSCAPI::returnInvalidBufferLen:320 // msg = _T("UNKNOWN: Return buffer to small to handle this command.");321 // ret = NSCAPI::returnUNKNOWN;322 // break;323 // case NSCAPI::returnIgnored:324 // msg = _T("UNKNOWN: No handler for that command");325 // ret = NSCAPI::returnUNKNOWN;326 // break;327 // case NSCAPI::returnOK:328 // case NSCAPI::returnWARN:329 // case NSCAPI::returnCRIT:330 // case NSCAPI::returnUNKNOWN:331 // break;332 // default:333 // msg = _T("UNKNOWN: Internal error.");334 // ret = NSCAPI::returnUNKNOWN;335 // }336 // if (msg.length() >= buffer_length_-1) {337 // NSC_LOG_ERROR(_T("Truncating returndata as it is bigger then NRPE allowes :("));338 // msg = msg.substr(0,buffer_length_-2);339 // }340 // if (perf.empty()||noPerfData_) {341 // return NRPEPacket(NRPEPacket::responsePacket, NRPEPacket::version2, ret, msg, buffer_length_);342 // } else {343 // return NRPEPacket(NRPEPacket::responsePacket, NRPEPacket::version2, ret, msg + _T("|") + perf, buffer_length_);344 // }345 // }346 347 184 NSC_WRAP_DLL(); 348 NSC_WRAPPERS_MAIN_DEF( gNRPEListener);185 NSC_WRAPPERS_MAIN_DEF(NRPEListener); 349 186 NSC_WRAPPERS_IGNORE_MSG_DEF(); 350 187 NSC_WRAPPERS_IGNORE_CMD_DEF(); -
modules/NRPEServer/NRPEServer.h
rb9498ef r81e420c 48 48 49 49 50 st d::wstring getModuleName() {50 static std::wstring getModuleName() { 51 51 #ifdef USE_SSL 52 52 return _T("NRPE server"); … … 55 55 #endif 56 56 } 57 nscapi::plugin_wrapper::module_version getModuleVersion() {57 static nscapi::plugin_wrapper::module_version getModuleVersion() { 58 58 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 59 59 return version; 60 60 } 61 st d::wstring getModuleDescription() {61 static std::wstring getModuleDescription() { 62 62 return _T("A simple server that listens for incoming NRPE connection and handles them.\nNRPE is preferred over NSClient as it is more flexible. You can of cource use both NSClient and NRPE."); 63 63 } -
modules/NSCAAgent/NSCAAgent.cpp
r4b1e6fe r81e420c 30 30 31 31 #include <settings/client/settings_client.hpp> 32 33 NSCAAgent gNSCAAgent;34 32 35 33 namespace sh = nscapi::settings_helper; … … 176 174 177 175 NSC_WRAP_DLL(); 178 NSC_WRAPPERS_MAIN_DEF( gNSCAAgent);176 NSC_WRAPPERS_MAIN_DEF(NSCAAgent); 179 177 NSC_WRAPPERS_IGNORE_MSG_DEF(); 180 178 NSC_WRAPPERS_IGNORE_CMD_DEF(); 181 NSC_WRAPPERS_HANDLE_NOTIFICATION_DEF( gNSCAAgent);179 NSC_WRAPPERS_HANDLE_NOTIFICATION_DEF(); -
modules/NSCAAgent/NSCAAgent.h
rc760fc9 r81e420c 50 50 * @return The module name 51 51 */ 52 st d::wstring getModuleName() {52 static std::wstring getModuleName() { 53 53 #ifdef HAVE_LIBCRYPTOPP 54 54 return _T("NSCAAgent (w/ encryption)"); … … 61 61 * @return module version 62 62 */ 63 nscapi::plugin_wrapper::module_version getModuleVersion() {63 static nscapi::plugin_wrapper::module_version getModuleVersion() { 64 64 nscapi::plugin_wrapper::module_version version = {0, 3, 0 }; 65 65 return version; 66 66 } 67 st d::wstring getModuleDescription() {67 static std::wstring getModuleDescription() { 68 68 return std::wstring(_T("Passive check support (needs NSCA on nagios server).\nAvalible crypto are: ")) + getCryptos(); 69 69 } 70 70 bool hasNotificationHandler() { return true; } 71 71 72 st d::wstring getCryptos();72 static std::wstring getCryptos(); 73 73 74 74 NSCAPI::nagiosReturn handleSimpleNotification(const std::wstring channel, const std::wstring command, NSCAPI::nagiosReturn code, std::wstring msg, std::wstring perf); -
modules/NSCPClient/NSCPClient.cpp
r60e6c18 r81e420c 36 36 namespace sh = nscapi::settings_helper; 37 37 38 NSCPClient gNSCPClient;39 40 38 NSCPClient::NSCPClient() : buffer_length_(0) { 41 39 } … … 533 531 534 532 NSC_WRAP_DLL(); 535 NSC_WRAPPERS_MAIN_DEF( gNSCPClient);533 NSC_WRAPPERS_MAIN_DEF(NSCPClient); 536 534 NSC_WRAPPERS_IGNORE_MSG_DEF(); 537 NSC_WRAPPERS_HANDLE_CMD_DEF( gNSCPClient);538 NSC_WRAPPERS_CLI_DEF( gNSCPClient);539 535 NSC_WRAPPERS_HANDLE_CMD_DEF(); 536 NSC_WRAPPERS_CLI_DEF(); 537 -
modules/NSCPClient/NSCPClient.h
r60e6c18 r81e420c 80 80 81 81 82 st d::wstring getModuleName() {82 static std::wstring getModuleName() { 83 83 #ifdef USE_SSL 84 84 return _T("NSCP client (w/ SSL)"); … … 87 87 #endif 88 88 } 89 nscapi::plugin_wrapper::module_version getModuleVersion() {89 static nscapi::plugin_wrapper::module_version getModuleVersion() { 90 90 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 91 91 return version; 92 92 } 93 st d::wstring getModuleDescription() {93 static std::wstring getModuleDescription() { 94 94 return _T("A simple client for checking remote NSCP servers (think proxy).\n") 95 95 #ifndef USE_SSL -
modules/NSCPServer/NSCPServer.cpp
r438998b r81e420c 31 31 32 32 namespace sh = nscapi::settings_helper; 33 34 NSCPListener gNSCPListener;35 33 36 34 NSCPListener::NSCPListener() : info_(boost::shared_ptr<nscp::server::handler>(new handler_impl(1024))) { … … 160 158 161 159 NSC_WRAP_DLL(); 162 NSC_WRAPPERS_MAIN_DEF( gNSCPListener);160 NSC_WRAPPERS_MAIN_DEF(NSCPListener); 163 161 NSC_WRAPPERS_IGNORE_MSG_DEF(); 164 162 NSC_WRAPPERS_IGNORE_CMD_DEF(); -
modules/NSCPServer/NSCPServer.h
r438998b r81e420c 48 48 49 49 50 st d::wstring getModuleName() {50 static std::wstring getModuleName() { 51 51 #ifdef USE_SSL 52 52 return _T("NSCP server"); … … 55 55 #endif 56 56 } 57 nscapi::plugin_wrapper::module_version getModuleVersion() {57 static nscapi::plugin_wrapper::module_version getModuleVersion() { 58 58 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 59 59 return version; 60 60 } 61 st d::wstring getModuleDescription() {61 static std::wstring getModuleDescription() { 62 62 return _T("A simple server that listens for incoming NSCP connection and handles them."); 63 63 } -
modules/NSClientServer/NSClientServer.cpp
rb9498ef r81e420c 27 27 #include "settings.hpp" 28 28 #include <settings/client/settings_client.hpp> 29 30 NSClientListener gNSClientListener;31 32 33 29 34 30 namespace sh = nscapi::settings_helper; … … 172 168 } 173 169 174 // void NSClientListener::sendTheResponse(simpleSocket::Socket *client, std::string response) {175 // client->send(response.c_str(), static_cast<int>(response.length()), 0);176 // }177 //178 // void NSClientListener::retrivePacket(simpleSocket::Socket *client) {179 // simpleSocket::DataBuffer db;180 // unsigned int i;181 // unsigned int maxWait = socketTimeout_*10;182 // for (i=0;i<maxWait;i++) {183 // bool lastReadHasMore = false;184 // try {185 // lastReadHasMore = client->readAll(db);186 // } catch (simpleSocket::SocketException e) {187 // NSC_LOG_ERROR_STD(_T("Read on socket failed: ") + e.getMessage());188 // client->close();189 // return;190 // }191 // if (db.getLength() > 0) {192 // unsigned long long pos = db.find('\n');193 // if (pos==-1) {194 // std::string incoming(db.getBuffer(), db.getLength());195 // sendTheResponse(client, parseRequest(incoming));196 // break;197 // } else if (pos > 0) {198 // simpleSocket::DataBuffer buffer = db.unshift(static_cast<const unsigned int>(pos));199 // std::string bstr(buffer.getBuffer(), buffer.getLength());200 // db.nibble(1);201 // std::string rstr(db.getBuffer(), db.getLength());202 // std::string incoming(buffer.getBuffer(), buffer.getLength());203 // sendTheResponse(client, parseRequest(incoming) + "\n");204 // } else {205 // db.nibble(1);206 // NSC_LOG_ERROR_STD(_T("First char should (i think) not be a \\n :("));207 // }208 // } else if (!lastReadHasMore) {209 // client->close();210 // return;211 // } else {212 // Sleep(100);213 // }214 // }215 // if (i >= maxWait) {216 // NSC_LOG_ERROR_STD(_T("Timeout reading NS-client packet (increase socket_timeout)."));217 // client->close();218 // return;219 // }220 // }221 222 //223 // void NSClientListener::onAccept(simpleSocket::Socket *client) {224 // if (!allowedHosts.inAllowedHosts(client->getAddr())) {225 // NSC_LOG_ERROR(_T("Unauthorized access from: ") + client->getAddrString());226 // client->close();227 // return;228 // }229 // //client->setNonBlock();230 // retrivePacket(client);231 //232 //233 //234 // // client->readAll(db);235 // // if (db.getLength() > 0) {236 // // std::wstring incoming(db.getBuffer(), db.getLength());237 // // NSC_DEBUG_MSG_STD("Incoming data: " + incoming);238 // // std::wstring response = parseRequest(incoming);239 // // NSC_DEBUG_MSG("Outgoing data: " + response);240 // // client->send(response.c_str(), static_cast<int>(response.length()), 0);241 // // }242 // client->close();243 // }244 245 170 NSC_WRAP_DLL(); 246 NSC_WRAPPERS_MAIN_DEF( gNSClientListener);171 NSC_WRAPPERS_MAIN_DEF(NSClientListener); 247 172 NSC_WRAPPERS_IGNORE_MSG_DEF(); 248 173 NSC_WRAPPERS_IGNORE_CMD_DEF(); -
modules/NSClientServer/NSClientServer.h
rb9498ef r81e420c 40 40 41 41 42 st d::wstring getModuleName() {42 static std::wstring getModuleName() { 43 43 return _T("NSClient server"); 44 44 } 45 nscapi::plugin_wrapper::module_version getModuleVersion() {45 static nscapi::plugin_wrapper::module_version getModuleVersion() { 46 46 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 47 47 return version; 48 48 } 49 st d::wstring getModuleDescription() {49 static std::wstring getModuleDescription() { 50 50 return _T("A simple server that listens for incoming NSClient (check_nt) connection and handles them.\nAlthough NRPE is the preferred method NSClient is fully supported and can be used for simplicity or for compatibility."); 51 51 } -
modules/PythonScript/PythonScript.cpp
r4b1e6fe r81e420c 32 32 33 33 #include "script_wrapper.hpp" 34 35 PythonScript gPythonScript;36 34 37 35 PythonScript::PythonScript() { … … 99 97 ; 100 98 def("log", script_wrapper::log_msg); 101 def("get_alias", script_wrapper::get_alias); 99 // def("get_module_alias", script_wrapper::get_module_alias); 100 // def("get_script_alias", script_wrapper::get_script_alias); 102 101 } 103 102 … … 241 240 return true; 242 241 } 243 244 245 242 246 243 bool PythonScript::reload(std::wstring &message) { … … 324 321 325 322 NSC_WRAP_DLL(); 326 NSC_WRAPPERS_MAIN_DEF( gPythonScript);323 NSC_WRAPPERS_MAIN_DEF(PythonScript); 327 324 NSC_WRAPPERS_IGNORE_MSG_DEF(); 328 NSC_WRAPPERS_HANDLE_CMD_DEF( gPythonScript);329 NSC_WRAPPERS_CLI_DEF( gPythonScript);330 NSC_WRAPPERS_HANDLE_NOTIFICATION_DEF( gPythonScript);325 NSC_WRAPPERS_HANDLE_CMD_DEF(); 326 NSC_WRAPPERS_CLI_DEF(); 327 NSC_WRAPPERS_HANDLE_NOTIFICATION_DEF(); -
modules/PythonScript/PythonScript.h
r2c95d22 r81e420c 65 65 } 66 66 67 st d::wstring getModuleName() {67 static std::wstring getModuleName() { 68 68 return _T("PythonScript"); 69 69 } 70 st d::wstring getModuleDescription() {70 static std::wstring getModuleDescription() { 71 71 return _T("PythonScript..."); 72 72 } 73 nscapi::plugin_wrapper::module_version getModuleVersion() {73 static nscapi::plugin_wrapper::module_version getModuleVersion() { 74 74 nscapi::plugin_wrapper::module_version version = {0, 0, 1 }; 75 75 return version; -
modules/PythonScript/script_wrapper.cpp
rb9498ef r81e420c 9 9 boost::shared_ptr<script_wrapper::functions> script_wrapper::functions::instance; 10 10 11 extern PythonScript gPythonScript;11 //extern PythonScript gPythonScript; 12 12 13 13 … … 15 15 NSC_LOG_ERROR_STD(utf8::cvt<std::wstring>(x)); 16 16 } 17 /* 17 18 std::string script_wrapper::get_alias() { 18 19 return utf8::cvt<std::string>(gPythonScript.get_alias()); 19 20 } 21 */ 20 22 21 23 void script_wrapper::log_exception() { -
modules/PythonScript/script_wrapper.hpp
r2c95d22 r81e420c 16 16 void log_exception(); 17 17 void log_msg(std::wstring x); 18 std::string get_alias();18 //std::string get_alias(); 19 19 20 20 std::list<std::wstring> convert(boost::python::list lst); -
modules/Scheduler/Scheduler.cpp
r4b1e6fe r81e420c 27 27 28 28 #include <settings/client/settings_client.hpp> 29 30 Scheduler gInstance;31 29 32 30 namespace sh = nscapi::settings_helper; … … 179 177 180 178 NSC_WRAP_DLL(); 181 NSC_WRAPPERS_MAIN_DEF( gInstance);179 NSC_WRAPPERS_MAIN_DEF(Scheduler); 182 180 NSC_WRAPPERS_IGNORE_MSG_DEF(); 183 181 NSC_WRAPPERS_IGNORE_CMD_DEF(); -
modules/Scheduler/Scheduler.h
rc015acc r81e420c 45 45 void on_error(std::wstring error); 46 46 47 st d::wstring getModuleName() {47 static std::wstring getModuleName() { 48 48 return _T("Scheduler"); 49 49 } 50 nscapi::plugin_wrapper::module_version getModuleVersion() {50 static nscapi::plugin_wrapper::module_version getModuleVersion() { 51 51 nscapi::plugin_wrapper::module_version version = {0, 3, 0 }; 52 52 return version; 53 53 } 54 st d::wstring getModuleDescription() {54 static std::wstring getModuleDescription() { 55 55 return _T("A scheduler which schedules checks at regular intervals"); 56 56 } -
scripts/python/test.py
r4b1e6fe r81e420c 1 from NSCP import Settings, Registry, Core, log, status , get_alias1 from NSCP import Settings, Registry, Core, log, status 2 2 #import sys 3 3 #sys.path.append('D:/source/nscp/build/x64/scripts/python/include') … … 39 39 message = plugin_pb2.QueryRequestMessage() 40 40 41 message.header.type = plugin_pb2.Common.Header.QUERY_REQUEST42 41 message.header.version = plugin_pb2.Common.VERSION_1 43 42 … … 105 104 prefix = '%s_'%alias 106 105 107 log('Script: test.py with alias: %s from %s'%(alias, get_alias()))106 log('Script: test.py with alias: %s'%alias) 108 107 109 108 conf = Settings.get() -
service/CMakeLists.txt
r04ef932 r81e420c 38 38 cli_parser.hpp 39 39 40 plugin_list.hpp 40 41 commands.hpp 41 42 channels.hpp 43 routers.hpp 42 44 logger.hpp 43 45 service_manager.hpp -
service/NSCPlugin.cpp
r39c73cd r81e420c 42 42 ,fGetVersion(NULL) 43 43 ,fCommandLineExec(NULL) 44 ,fShowTray(NULL)45 ,fHideTray(NULL)46 44 ,fHasNotificationHandler(NULL) 47 45 ,fHandleNotification(NULL) 46 ,fHasRoutingHandler(NULL) 47 ,fRouteMessage(NULL) 48 48 ,loaded_(false) 49 49 ,lastIsMsgPlugin_(false) … … 54 54 55 55 } 56 /*57 NSCPlugin::NSCPlugin(NSCPlugin &other)58 :module_()59 ,fLoadModule(NULL)60 ,fGetName(NULL)61 ,fHasCommandHandler(NULL)62 ,fUnLoadModule(NULL)63 ,fHasMessageHandler(NULL)64 ,fHandleMessage(NULL)65 ,fGetDescription(NULL)66 ,fGetVersion(NULL)67 ,fCommandLineExec(NULL)68 ,fShowTray(NULL)69 ,fHideTray(NULL)70 ,bLoaded_(false)71 ,lastIsMsgPlugin_(false)72 ,broken_(false)73 {74 if (other.bLoaded_) {75 file_ = other.file_;76 hModule_ = LoadLibrary(file_.c_str());77 if (!hModule_)78 throw NSPluginException(file_, _T("Could not load library: ") + error::lookup::last_error());79 loadRemoteProcs_();80 if (!fLoadModule)81 throw NSPluginException(file_, _T("Critical error (fLoadModule)"));82 bLoaded_ = other.bLoaded_;83 }84 }85 */86 56 /** 87 57 * Default d-tor … … 144 114 if (!fLoadModule) 145 115 throw NSPluginException(module_, _T("Critical error (fLoadModule)")); 146 if (fLoadModule( alias_.c_str(), mode)) {116 if (fLoadModule(plugin_id_, alias_.c_str(), mode)) { 147 117 loaded_ = true; 148 118 return true; … … 189 159 throw NSPluginException(module_, _T("Module not loaded")); 190 160 try { 191 if (fHasCommandHandler( ))161 if (fHasCommandHandler(plugin_id_)) 192 162 return true; 193 163 return false; … … 205 175 throw NSPluginException(module_, _T("Module not loaded")); 206 176 try { 207 if (fHasMessageHandler( )) {177 if (fHasMessageHandler(plugin_id_)) { 208 178 lastIsMsgPlugin_ = true; 209 179 return true; … … 220 190 return false; 221 191 try { 222 if (fHasNotificationHandler()) { 192 if (fHasNotificationHandler(plugin_id_)) { 193 return true; 194 } 195 return false; 196 } catch (...) { 197 throw NSPluginException(module_, _T("Unhandled exception in hasMessageHandler.")); 198 } 199 } 200 bool NSCPlugin::has_routing_handler() { 201 if (!isLoaded()) 202 throw NSPluginException(module_, _T("Module not loaded")); 203 if (!fHasRoutingHandler) 204 return false; 205 try { 206 if (fHasRoutingHandler(plugin_id_)) { 223 207 return true; 224 208 } … … 247 231 throw NSPluginException(module_, _T("Library is not loaded")); 248 232 try { 249 return fHandleCommand( command, dataBuffer, dataBuffer_len, returnBuffer, returnBuffer_len);233 return fHandleCommand(plugin_id_, command, dataBuffer, dataBuffer_len, returnBuffer, returnBuffer_len); 250 234 } catch (...) { 251 235 throw NSPluginException(module_, _T("Unhandled exception in handleCommand.")); … … 253 237 } 254 238 255 bool NSCPlugin::handleNotification(const wchar_t *channel, const wchar_t* command, NSCAPI::nagiosReturn code,char* result, unsigned int result_len) {239 bool NSCPlugin::handleNotification(const wchar_t *channel, const wchar_t* command, const char* result, unsigned int result_len) { 256 240 if (!isLoaded() || fHandleNotification == NULL) 257 241 throw NSPluginException(module_, _T("Library is not loaded")); 258 242 try { 259 return fHandleNotification(channel, command, code, result, result_len); 260 } catch (...) { 261 throw NSPluginException(module_, _T("Unhandled exception in handleCommand.")); 262 } 263 } 264 243 return fHandleNotification(plugin_id_, channel, command, result, result_len); 244 } catch (...) { 245 throw NSPluginException(module_, _T("Unhandled exception in handleNotification.")); 246 } 247 } 248 249 bool NSCPlugin::route_message(const wchar_t *channel, const wchar_t *command, const char* buffer, unsigned int buffer_len, wchar_t **new_channel_buffer, char **new_buffer, unsigned int *new_buffer_len) { 250 if (!isLoaded() || fRouteMessage == NULL) 251 throw NSPluginException(module_, _T("Library is not loaded")); 252 try { 253 return fRouteMessage(plugin_id_, channel, command, buffer, buffer_len, new_channel_buffer, new_buffer, new_buffer_len); 254 } catch (...) { 255 throw NSPluginException(module_, _T("Unhandled exception in route_message.")); 256 } 257 } 265 258 266 259 … … 294 287 * @throws NSPluginException if the module is not loaded. 295 288 */ 296 void NSCPlugin::handleMessage(const char* data ) {289 void NSCPlugin::handleMessage(const char* data, unsigned int len) { 297 290 if (!fHandleMessage) 298 291 throw NSPluginException(module_, _T("Library is not loaded")); 299 292 try { 300 fHandleMessage( data);293 fHandleMessage(plugin_id_, data, len); 301 294 } catch (...) { 302 295 throw NSPluginException(module_, _T("Unhandled exception in handleMessage.")); … … 314 307 throw NSPluginException(module_, _T("Critical error (fUnLoadModule)")); 315 308 try { 316 fUnLoadModule( );309 fUnLoadModule(plugin_id_); 317 310 } catch (...) { 318 311 throw NSPluginException(module_, _T("Unhandled exception in fUnLoadModule.")); … … 336 329 } catch (...) { 337 330 throw NSPluginException(module_, _T("Unhandled exception in getDescription.")); 338 }339 }340 341 void NSCPlugin::showTray() {342 if (fShowTray == NULL)343 throw NSPluginException(module_, _T("Critical error (ShowTray)"));344 try {345 fShowTray();346 } catch (...) {347 throw NSPluginException(module_, _T("Unhandled exception in ShowTray."));348 }349 }350 void NSCPlugin::hideTray() {351 if (fHideTray == NULL)352 throw NSPluginException(module_, _T("Critical error (HideTray)"));353 try {354 fHideTray();355 } catch (...) {356 throw NSPluginException(module_, _T("Unhandled exception in HideTray."));357 331 } 358 332 } … … 420 394 fHandleNotification = (nscapi::plugin_api::lpHandleNotification)module_.load_proc("NSHandleNotification"); 421 395 fHasNotificationHandler = (nscapi::plugin_api::lpHasNotificationHandler)module_.load_proc("NSHasNotificationHandler"); 422 423 f ShowTray = (nscapi::plugin_api::lpShowTray)module_.load_proc("ShowIcon");424 f HideTray = (nscapi::plugin_api::lpHideTray)module_.load_proc("HideIcon");425 396 397 fHasRoutingHandler = (nscapi::plugin_api::lpHasRoutingHandler)module_.load_proc("NSHasRoutingHandler"); 398 fRouteMessage = (nscapi::plugin_api::lpRouteMessage)module_.load_proc("NSRouteMessage"); 399 426 400 } catch (NSPluginException &e) { 427 401 throw e; … … 454 428 throw NSPluginException(module_, _T("Library is not loaded or modules does not support command line")); 455 429 try { 456 return fCommandLineExec( command, request, request_len, reply, reply_len);430 return fCommandLineExec(plugin_id_, command, request, request_len, reply, reply_len); 457 431 } catch (...) { 458 432 throw NSPluginException(module_, _T("Unhandled exception in handleCommand.")); -
service/NSCPlugin.h
r39c73cd r81e420c 118 118 nscapi::plugin_api::lpUnLoadModule fUnLoadModule; 119 119 nscapi::plugin_api::lpCommandLineExec fCommandLineExec; 120 nscapi::plugin_api::lpShowTray fShowTray;121 nscapi::plugin_api::lpHideTray fHideTray;122 120 nscapi::plugin_api::lpHasNotificationHandler fHasNotificationHandler; 123 121 nscapi::plugin_api::lpHandleNotification fHandleNotification; 122 nscapi::plugin_api::lpHasRoutingHandler fHasRoutingHandler; 123 nscapi::plugin_api::lpRouteMessage fRouteMessage; 124 124 125 125 public: 126 126 NSCPlugin(const unsigned int id, const boost::filesystem::wpath file, std::wstring alias); 127 //NSCPlugin(NSCPlugin &other);128 127 virtual ~NSCPlugin(void); 129 128 … … 140 139 NSCAPI::nagiosReturn handleCommand(const wchar_t *command, const char* dataBuffer, const unsigned int dataBuffer_len, char** returnBuffer, unsigned int *returnBuffer_len); 141 140 NSCAPI::nagiosReturn handleCommand(const wchar_t* command, std::string &request, std::string &reply); 142 bool handleNotification(const wchar_t *channel, const wchar_t* command, NSCAPI::nagiosReturn code,char* result, unsigned int result_len);141 bool handleNotification(const wchar_t *channel, const wchar_t* command, const char* result, unsigned int result_len); 143 142 void deleteBuffer(char**buffer); 144 void handleMessage(const char* data );143 void handleMessage(const char* data, unsigned int len); 145 144 void unload(void); 146 145 std::wstring getCongifurationMeta(); … … 148 147 int commandLineExec(const wchar_t* command, const char* request, const unsigned int request_len, char** reply, unsigned int *reply_len); 149 148 bool has_command_line_exec(); 150 void showTray();151 void hideTray();152 149 bool is_duplicate( boost::filesystem::wpath file, std::wstring alias ); 150 151 152 bool has_routing_handler(); 153 154 155 bool route_message(const wchar_t *channel, const wchar_t *command, const char* buffer, unsigned int buffer_len, wchar_t **new_channel_buffer, char **new_buffer, unsigned int *new_buffer_len); 153 156 154 157 std::wstring get_alias() { -
service/NSClient++.cpp
r8840f09 r81e420c 955 955 if (plugin->hasMessageHandler()) 956 956 logger_master_.add_plugin(plugin); 957 if (plugin->has_routing_handler()) 958 routers_.add_plugin(plugin); 957 959 //settings_manager::get_core()->register_key(_T("/modules"), plugin->getModule(), settings::settings_core::key_string, plugin->getName(), plugin->getDescription(), _T(""), false); 958 960 // TODO add comments elsewhere to the settings store for all loaded modules... … … 1160 1162 1161 1163 Plugin::ExecuteResponseMessage response_message; 1162 nscapi::functions::create_simple_header(response_message.mutable_header() , Plugin::Common_Header_Type_EXEC_RESPONSE);1164 nscapi::functions::create_simple_header(response_message.mutable_header()); 1163 1165 1164 1166 BOOST_FOREACH(std::string r, responses) { … … 1177 1179 1178 1180 1179 1180 NSCAPI::errorReturn NSClientT::send_notification(const wchar_t* channel, const wchar_t* command, NSCAPI::nagiosReturn code, char* result, unsigned int result_len) { 1181 NSCAPI::errorReturn NSClientT::reroute(std::wstring &channel, const wchar_t* command, std::string &buffer) { 1182 BOOST_FOREACH(nsclient::plugin_type p, routers_.get(channel)) { 1183 wchar_t *new_channel_buffer; 1184 char *new_buffer; 1185 unsigned int new_buffer_len; 1186 int status = p->route_message(channel.c_str(), command, buffer.c_str(), buffer.size(), &new_channel_buffer, &new_buffer, &new_buffer_len); 1187 if (status&NSCAPI::message_modified == NSCAPI::message_modified) { 1188 buffer = std::string(new_buffer, new_buffer_len); 1189 p->deleteBuffer(&new_buffer); 1190 } 1191 if (status&NSCAPI::message_routed == NSCAPI::message_routed) { 1192 channel = new_channel_buffer; 1193 //p->deleteBuffer(new_channel_buffer); 1194 return NSCAPI::message_routed; 1195 } 1196 if (status&NSCAPI::message_ignored == NSCAPI::message_ignored) 1197 return NSCAPI::message_ignored; 1198 if (status&NSCAPI::message_digested == NSCAPI::message_digested) 1199 return NSCAPI::message_ignored; 1200 } 1201 return NSCAPI::isfalse; 1202 } 1203 1204 NSCAPI::errorReturn NSClientT::send_notification(const wchar_t* channel, const wchar_t* command, char* buffer, unsigned int buffer_len) { 1181 1205 boost::shared_lock<boost::shared_mutex> readLock(m_mutexRW, boost::get_system_time() + boost::posix_time::milliseconds(5000)); 1182 1206 if (!readLock.owns_lock()) { … … 1184 1208 return NSCAPI::hasFailed; 1185 1209 } 1210 1211 std::wstring schannel = channel; 1212 std::string sbuffer = std::string(buffer, buffer_len); 1213 try { 1214 int count = 0; 1215 while (reroute(schannel, command, sbuffer)==NSCAPI::message_routed && count++ <= 10) { 1216 LOG_DEBUG_CORE_STD(_T("Re-routing message to: ") + schannel); 1217 } 1218 if (count >= 10) { 1219 LOG_ERROR_CORE(_T("More then 10 routes, discarding message...")); 1220 return NSCAPI::hasFailed; 1221 } 1222 } catch (nsclient::plugins_list_exception &e) { 1223 LOG_ERROR_CORE(_T("Erroro routing channel: ") + std::wstring(channel) + _T(": ") + to_wstring(e.what())); 1224 return NSCAPI::hasFailed; 1225 } catch (...) { 1226 LOG_ERROR_CORE(_T("Error routing channel: ") + std::wstring(channel)); 1227 return NSCAPI::hasFailed; 1228 } 1229 1186 1230 try { 1187 1231 //LOG_ERROR_CORE_STD(_T("Notifying: ") + strEx::strip_hex(to_wstring(std::string(result,result_len)))); 1188 1232 bool found = false; 1189 BOOST_FOREACH(nsclient:: channels::plugin_type p, channels_.get(channel)) {1190 p->handleNotification( channel, command, code, result, result_len);1233 BOOST_FOREACH(nsclient::plugin_type p, channels_.get(schannel)) { 1234 p->handleNotification(schannel.c_str(), command, sbuffer.c_str(), sbuffer.length()); 1191 1235 found = true; 1192 1236 } 1193 1237 if (!found) { 1194 LOG_ERROR_CORE_STD(_T("Noone listens for events from: ") + std::wstring(channel)); 1238 LOG_ERROR_CORE_STD(_T("No one listens for events from: ") + schannel + _T(" (") + std::wstring(channel) + _T(")")); 1239 return NSCAPI::hasFailed; 1195 1240 } 1196 1241 return NSCAPI::isSuccess; 1197 } catch (nsclient:: channels::channel_exception &e) {1242 } catch (nsclient::plugins_list_exception &e) { 1198 1243 LOG_ERROR_CORE(_T("No handler for channel: ") + std::wstring(channel) + _T(": ") + to_wstring(e.what())); 1199 1244 return NSCAPI::hasFailed; -
service/NSClient++.h
rb38e845 r81e420c 32 32 #include "commands.hpp" 33 33 #include "channels.hpp" 34 #include "routers.hpp" 34 35 #include "logger.hpp" 35 36 … … 110 111 nsclient::commands commands_; 111 112 nsclient::channels channels_; 113 nsclient::routers routers_; 112 114 unsigned int next_plugin_id_; 113 115 std::wstring service_name_; … … 117 119 typedef std::multimap<std::wstring,std::wstring> plugin_alias_list_type; 118 120 // c-tor, d-tor 119 NSClientT(void) : debug_(log_state_unknown), enable_shared_session_(false), commands_(this), channels_(this), next_plugin_id_(0), service_name_(DEFAULT_SERVICE_NAME) {121 NSClientT(void) : debug_(log_state_unknown), enable_shared_session_(false), commands_(this), channels_(this), routers_(this), next_plugin_id_(0), service_name_(DEFAULT_SERVICE_NAME) { 120 122 logger_master_.start_slave(); 121 123 } … … 160 162 // Member functions 161 163 boost::filesystem::wpath getBasePath(void); 162 NSCAPI::errorReturn send_notification(const wchar_t* channel, const wchar_t* command, NSCAPI::nagiosReturn code, char* result, unsigned int result_len); 164 165 NSCAPI::errorReturn reroute(std::wstring &channel, const wchar_t* command, std::string &buffer); 166 NSCAPI::errorReturn send_notification(const wchar_t* channel, const wchar_t* command, char* buffer, unsigned int buffer_len); 163 167 NSCAPI::nagiosReturn injectRAW(const wchar_t* command, std::string &request, std::string &response); 164 168 NSCAPI::nagiosReturn inject(std::wstring command, std::wstring arguments, std::wstring &msg, std::wstring & perf); -
service/channels.hpp
r1ecd26f r81e420c 1 1 #pragma once 2 2 3 #include <set>4 5 #include <boost/shared_ptr.hpp>6 #include <boost/foreach.hpp>7 8 3 #include "NSCPlugin.h" 9 #include " logger.hpp"4 #include "plugin_list.hpp" 10 5 11 6 using namespace nscp::helpers; 12 7 13 8 namespace nsclient { 14 class channels : boost::noncopyable { 15 public: 16 class channel_exception : public std::exception { 17 std::string what_; 18 public: 19 channel_exception(std::wstring error) throw() : what_(to_string(error).c_str()) {} 20 channel_exception(std::string error) throw() : what_(error.c_str()) {} 21 virtual ~channel_exception() throw() {}; 9 struct channels : public plugins_list_with_listener { 22 10 23 virtual const char* what() const throw() { 24 return what_.c_str(); 25 } 26 27 }; 28 29 typedef boost::shared_ptr<NSCPlugin> plugin_type; 30 typedef std::map<unsigned long,plugin_type> plugin_list_type; 31 typedef std::set<unsigned long> plugin_id_type; 32 typedef std::map<std::wstring,plugin_id_type > channel_list_type; 33 34 35 private: 36 nsclient::logger *logger_; 37 plugin_list_type plugins_; 38 channel_list_type channels_; 39 boost::shared_mutex mutex_; 40 41 public: 42 43 channels(nsclient::logger *logger) : logger_(logger) {} 11 channels(nsclient::logger *logger) : plugins_list_with_listener(logger) {} 44 12 45 13 void add_plugin(plugin_type plugin) { 46 14 if (!plugin || !plugin->hasNotificationHandler()) 47 15 return; 48 plugins_[plugin->get_id()] = plugin; 49 16 plugins_list_with_listener::add_plugin(plugin); 50 17 } 51 18 52 void remove_all() {53 boost::unique_lock<boost::shared_mutex> writeLock(mutex_, boost::get_system_time() + boost::posix_time::seconds(30));54 if (!writeLock.owns_lock()) {55 log_error(__FILE__, __LINE__, _T("Failed to get mutex: channels::remove_all"));56 return;57 }58 channels_.clear();59 plugins_.clear();60 }61 62 void remove_plugin(unsigned long id) {63 boost::unique_lock<boost::shared_mutex> writeLock(mutex_, boost::get_system_time() + boost::posix_time::seconds(10));64 if (!writeLock.owns_lock()) {65 log_error(__FILE__, __LINE__, _T("Failed to get mutex in remove_plugin for plugin id: ") + ::to_wstring(id));66 return;67 }68 channel_list_type::iterator it = channels_.begin();69 while (it != channels_.end()) {70 if ((*it).second.count(id) > 0) {71 channel_list_type::iterator toerase = it;72 ++it;73 channels_.erase(toerase);74 } else75 ++it;76 }77 plugin_list_type::iterator pit = plugins_.find(id);78 if (pit != plugins_.end())79 plugins_.erase(pit);80 }81 82 void register_listener(unsigned long plugin_id, std::wstring channel) {83 boost::unique_lock<boost::shared_mutex> writeLock(mutex_, boost::get_system_time() + boost::posix_time::seconds(10));84 if (!writeLock.owns_lock()) {85 log_error(__FILE__, __LINE__, _T("Failed to get mutex: ") + channel);86 return;87 }88 std::wstring lc = make_key(channel);89 if (!have_plugin(plugin_id))90 throw channel_exception("Failed to find plugin: " + ::to_string(plugin_id));91 channels_[lc].insert(plugin_id);92 }93 94 std::list<std::wstring> list() {95 std::list<std::wstring> lst;96 boost::shared_lock<boost::shared_mutex> readLock(mutex_, boost::get_system_time() + boost::posix_time::seconds(5));97 if (!readLock.owns_lock()) {98 log_error(__FILE__, __LINE__, _T("Failed to get mutex"));99 return lst;100 }101 102 BOOST_FOREACH(channel_list_type::value_type i, channels_) {103 lst.push_back(i.first);104 }105 return lst;106 }107 108 std::list<plugin_type> get(std::wstring channel) {109 boost::shared_lock<boost::shared_mutex> readLock(mutex_, boost::get_system_time() + boost::posix_time::seconds(5));110 if (!readLock.owns_lock()) {111 log_error(__FILE__, __LINE__, _T("Failed to get mutex: ") + channel);112 throw channel_exception("Failed to get mutex (channel::get)");113 }114 std::wstring lc = make_key(channel);115 channel_list_type::iterator cit = channels_.find(lc);116 if (cit == channels_.end()) {117 throw channel_exception("Channel not found: " + to_string(channel));118 }119 std::list<plugin_type> ret;120 BOOST_FOREACH(unsigned long id, cit->second) {121 ret.push_back(plugins_[id]);122 }123 return ret;124 }125 126 std::wstring to_wstring() {127 std::wstring ret;128 BOOST_FOREACH(std::wstring str, list()) {129 if (!ret.empty()) ret += _T(", ");130 ret += str;131 }132 return ret;133 }134 135 inline std::wstring make_key(std::wstring key) {136 return boost::algorithm::to_lower_copy(key);137 }138 void log_error(std::string file, int line, std::wstring error) {139 if (logger_ != NULL)140 logger_->nsclient_log_error(file, line, error);141 }142 143 inline bool have_plugin(unsigned long plugin_id) {144 return !(plugins_.find(plugin_id) == plugins_.end());145 }146 19 }; 147 20 } -
service/core_api.cpp
r2c95d22 r81e420c 483 483 } 484 484 485 NSCAPI::errorReturn NSAPINotify(const wchar_t* channel, const wchar_t* command, NSCAPI::nagiosReturn code,char* result, unsigned int result_len) {486 return mainClient.send_notification(channel, command, code,result, result_len);485 NSCAPI::errorReturn NSAPINotify(const wchar_t* channel, const wchar_t* command, char* result, unsigned int result_len) { 486 return mainClient.send_notification(channel, command, result, result_len); 487 487 } 488 488 -
service/core_api.h
r2c95d22 r81e420c 60 60 NSCAPI::errorReturn NSAPIReleasePluginList(int,NSCAPI::plugin_info*[]); 61 61 NSCAPI::errorReturn NSAPISettingsSave(void); 62 NSCAPI::errorReturn NSAPINotify(const wchar_t*, const wchar_t*, NSCAPI::nagiosReturn,char*, unsigned int);62 NSCAPI::errorReturn NSAPINotify(const wchar_t*, const wchar_t*, char*, unsigned int); 63 63 void NSAPIDestroyBuffer(char**); 64 64 NSCAPI::errorReturn NSAPIExpandPath(const wchar_t*,wchar_t*,unsigned int); -
service/logger.hpp
rb38e845 r81e420c 214 214 const char* cache_buf = s.c_str(); 215 215 BOOST_FOREACH(plugin_type p, plugins_) { 216 p->handleMessage(cache_buf );216 p->handleMessage(cache_buf, s.length()); 217 217 } 218 218 } … … 220 220 } 221 221 const char* buf = buffer.c_str(); 222 unsigned int len = buffer.length(); 222 223 BOOST_FOREACH(plugin_type p, plugins_) { 223 p->handleMessage(buf );224 p->handleMessage(buf, len); 224 225 } 225 226 }
Note: See TracChangeset
for help on using the changeset viewer.








