| 1 | #pragma once
|
|---|
| 2 |
|
|---|
| 3 | #include <nscp/packet.hpp>
|
|---|
| 4 | #include <nscp/handler.hpp>
|
|---|
| 5 |
|
|---|
| 6 | class handler_impl : public nscp::server::handler, private boost::noncopyable {
|
|---|
| 7 | bool allowArgs_;
|
|---|
| 8 | bool allowNasty_;
|
|---|
| 9 | bool noPerfData_;
|
|---|
| 10 | public:
|
|---|
| 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 | };
|
|---|