source: nscp/modules/DistributedServer/handler_impl.hpp

Last change on this file was 465866c, checked in by Michael Medin <michael@…>, 12 months ago

2012-06-05 MickeM

  • Tweaked all servers to use the new internals and added first testcase for NSCP socket

2012-05-24 MickeM

  • Reworked real time event log support to be a lot more flexible You can now specify all options on a "filter" level.
  • WARNING* Old syntax NOT supported (and will not upgrade) but hopefully not to many will be affected.
  • Added support for ipv6 allowed hosts validation

2012-05-21 MickeM

  • Sofia Born (My second daughter)
  • Property mode set to 100644
File size: 2.1 KB
Line 
1#pragma once
2
3#include <nscp/packet.hpp>
4#include <nscp/handler.hpp>
5
6class handler_impl : public nscp::server::handler, private boost::noncopyable {
7        bool allowArgs_;
8        bool allowNasty_;
9        bool noPerfData_;
10public:
11        handler_impl() : noPerfData_(false), allowNasty_(false), allowArgs_(false) {}
12
13        nscp::packet process(const nscp::packet &packet);
14
15        NSCAPI::nagiosReturn handle_query_request(const std::string &request, Plugin::QueryRequestMessage &msg, std::string &reply);
16        NSCAPI::nagiosReturn handle_submission_request(const std::string &request, Plugin::SubmitRequestMessage &msg, std::string &reply);
17        NSCAPI::nagiosReturn handle_exec_request(const std::string &request, Plugin::ExecuteRequestMessage &msg, std::string &reply);
18
19        NSCAPI::nagiosReturn process_single_query_request_payload(std::wstring &command, const Plugin::Common::Header &hdr, const Plugin::QueryRequestMessage_Request &payload, Plugin::QueryResponseMessage &response);
20        NSCAPI::nagiosReturn process_single_submit_request_payload(std::wstring &channel, const Plugin::Common::Header &hdr, const Plugin::QueryResponseMessage_Response &payload, Plugin::SubmitResponseMessage &response);
21        NSCAPI::nagiosReturn process_single_exec_request_payload(std::wstring &command, const Plugin::Common::Header &hdr, const Plugin::ExecuteRequestMessage_Request &payload, Plugin::ExecuteResponseMessage &response);
22
23        nscp::packet create_error(std::wstring msg) {
24                return nscp::factory::create_error(msg);
25        }
26
27        virtual void set_allow_arguments(bool v)  {
28                allowArgs_ = v;
29        }
30        virtual void set_allow_nasty_arguments(bool v) {
31                allowNasty_ = v;
32        }
33        virtual void set_perf_data(bool v) {
34                noPerfData_ = !v;
35                if (noPerfData_)
36                        log_debug(__FILE__, __LINE__, _T("Performance data disabled!"));
37        }
38
39        void log_debug(std::string file, int line, std::wstring msg) {
40                if (GET_CORE()->should_log(NSCAPI::log_level::debug)) {
41                        GET_CORE()->log(NSCAPI::log_level::debug, file, line, msg);
42                }
43        }
44        void log_error(std::string file, int line, std::wstring msg) {
45                if (GET_CORE()->should_log(NSCAPI::log_level::error)) {
46                        GET_CORE()->log(NSCAPI::log_level::error, file, line, msg);
47                }
48        }
49};
Note: See TracBrowser for help on using the repository browser.