bool NRPEClient::commandLineExec(const Plugin::ExecuteRequestMessage::Request &request, Plugin::ExecuteResponseMessage::Response *response, const Plugin::ExecuteRequestMessage &request_message) { client::configuration config(nrpe_client::command_prefix, boost::shared_ptr<nrpe_client::clp_handler_impl>(new nrpe_client::clp_handler_impl(boost::shared_ptr<socket_helpers::client::client_handler>(new client_handler()))), boost::shared_ptr<nrpe_client::target_handler>(new nrpe_client::target_handler(targets))); nrpe_client::setup(config, request_message.header()); return commands.parse_exec(nrpe_client::command_prefix, nrpe_client::default_command, request.command(), config, request, *response, request_message); }
int DistributedClient::clp_handler_impl::exec(client::configuration::data_type data, const Plugin::ExecuteRequestMessage &request_message, std::string &reply) { const ::Plugin::Common_Header& request_header = request_message.header(); int ret = NSCAPI::returnOK; connection_data con = parse_header(request_header, data); Plugin::ExecuteResponseMessage response_message; nscapi::functions::make_return_header(response_message.mutable_header(), request_header); std::list<nscp::packet> chunks; chunks.push_back(nscp::factory::create_envelope_request(1)); chunks.push_back(nscp::factory::create_payload(nscp::data::exec_request, request_message.SerializeAsString(), 0)); chunks = instance->send(con, chunks); BOOST_FOREACH(nscp::packet &chunk, chunks) { if (nscp::checks::is_exec_response(chunk)) { nscapi::functions::append_response_payloads(response_message, chunk.payload); } else if (nscp::checks::is_error(chunk)) { std::string error = gather_and_log_errors(chunk.payload); nscapi::functions::append_simple_exec_response_payload(response_message.add_payload(), "", NSCAPI::returnUNKNOWN, error); ret = NSCAPI::returnUNKNOWN; } else { NSC_LOG_ERROR_STD(_T("Unsupported message type: ") + strEx::itos(chunk.signature.payload_type)); nscapi::functions::append_simple_exec_response_payload(response_message.add_payload(), "", NSCAPI::returnUNKNOWN, "Unsupported response type"); ret = NSCAPI::returnUNKNOWN; } } response_message.SerializeToString(&reply); return ret; }
int NSCPClient::clp_handler_impl::exec(client::configuration::data_type data, const Plugin::ExecuteRequestMessage &request_message, Plugin::ExecuteResponseMessage &response_message) { const ::Plugin::Common_Header& request_header = request_message.header(); connection_data con = parse_header(request_header, data); std::string tmp; int ret = send(con, NSCPIPC::Common_MessageTypes_EXEC_REQUEST, request_message.SerializeAsString(), tmp); response_message.ParseFromString(tmp); return ret; }
NSCAPI::nagiosReturn SyslogClient::commandRAWLineExec(const wchar_t* char_command, const std::string &request, std::string &result) { std::wstring cmd = client::command_line_parser::parse_command(char_command, command_prefix); Plugin::ExecuteRequestMessage message; message.ParseFromString(request); client::configuration config; setup(config, message.header()); return commands.process_exec(cmd, config, message, result); }
int NRDPClient::clp_handler_impl::exec(client::configuration::data_type data, const Plugin::ExecuteRequestMessage &request_message, Plugin::ExecuteResponseMessage &response_message) { const ::Plugin::Common_Header& request_header = request_message.header(); connection_data con = parse_header(request_header, data); nscapi::protobuf::functions::make_return_header(response_message.mutable_header(), request_header); nrdp::data nrdp_data; for (int i=0;i < request_message.payload_size(); ++i) { nscapi::protobuf::functions::decoded_simple_command_data data = nscapi::protobuf::functions::parse_simple_exec_request_payload(request_message.payload(i)); //nrdp_data.add_command(data.command, data.args); } boost::tuple<int,std::string> ret = send(con, nrdp_data); nscapi::protobuf::functions::append_simple_exec_response_payload(response_message.add_payload(), "TODO", ret.get<0>(), ret.get<1>()); return NSCAPI::isSuccess; }
bool CheckMKClient::commandLineExec(const Plugin::ExecuteRequestMessage::Request &request, Plugin::ExecuteResponseMessage::Response *response, const Plugin::ExecuteRequestMessage &request_message) { client::configuration config(command_prefix, boost::shared_ptr<clp_handler_impl>(new clp_handler_impl(this)), boost::shared_ptr<target_handler>(new target_handler(targets))); setup(config, request_message.header()); return commands.parse_exec(command_prefix, default_command, request.command(), config, request, *response, request_message); }
bool SMTPClient::commandLineExec(const Plugin::ExecuteRequestMessage::Request &request, Plugin::ExecuteResponseMessage::Response *response, const Plugin::ExecuteRequestMessage &request_message) { client::configuration config(command_prefix); setup(config, request_message.header()); return commands.parse_exec(command_prefix, default_command, request.command(), config, request, *response, request_message); }