source: nscp/modules/DistributedServer/handler_impl.hpp @ a629015

0.4.00.4.10.4.2
Last change on this file since a629015 was a629015, checked in by Michael Medin <michael@…>, 20 months ago
  • Started on NSCA unit-tests in python
  • Refactored channel API a bit to better suite NSCA (and how it actually works)
  • Changed how headers are created (nothice this might have broken NSCP stuff, havent checked)
  • Created helper lib for Python Unittests
  • Renamed NSCAAgent to NSCAClient (to be consistant)
  • Created a NSCAServer module (again for consistancy) This will be the defenition of the new "channels" so keep a lookout in the next few weeks
  • Property mode set to 100644
File size: 1.9 KB
Line 
1#pragma once
2
3#include <nscp/packet.hpp>
4#include <nscp/handler.hpp>
5
6class handler_impl : public nscp::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        NSCAPI::nagiosReturn handle_query_request(const std::string &request, Plugin::QueryRequestMessage &msg, std::string &reply);
14        NSCAPI::nagiosReturn handle_submission_request(const std::string &request, Plugin::SubmitRequestMessage &msg, std::string &reply);
15        NSCAPI::nagiosReturn handle_exec_request(const std::string &request, Plugin::ExecuteRequestMessage &msg, std::string &reply);
16
17        NSCAPI::nagiosReturn process_single_query_request_payload(std::wstring &command, const Plugin::Common::Header &hdr, const Plugin::QueryRequestMessage_Request &payload, Plugin::QueryResponseMessage &response);
18        NSCAPI::nagiosReturn process_single_submit_request_payload(std::wstring &channel, const Plugin::Common::Header &hdr, const Plugin::QueryResponseMessage_Response &payload, Plugin::SubmitResponseMessage &response);
19        NSCAPI::nagiosReturn process_single_exec_request_payload(std::wstring &command, const Plugin::Common::Header &hdr, const Plugin::ExecuteRequestMessage_Request &payload, Plugin::ExecuteResponseMessage &response);
20
21        nscp::packet create_error(std::wstring msg) {
22                return nscp::factory::create_error(msg);
23        }
24
25        virtual void set_allow_arguments(bool v)  {
26                allowArgs_ = v;
27        }
28        virtual void set_allow_nasty_arguments(bool v) {
29                allowNasty_ = v;
30        }
31        virtual void set_perf_data(bool v) {
32                noPerfData_ = !v;
33                if (noPerfData_)
34                        log_debug(__FILE__, __LINE__, _T("Performance data disabled!"));
35        }
36
37        void log_debug(std::string file, int line, std::wstring msg) {
38                GET_CORE()->Message(NSCAPI::debug, file, line, msg);
39        }
40        void log_error(std::string file, int line, std::wstring msg) {
41                GET_CORE()->Message(NSCAPI::error, file, line, msg);
42        }
43};
Note: See TracBrowser for help on using the repository browser.