bool submit(client::destination_container sender, client::destination_container target, const Plugin::SubmitRequestMessage &request_message, Plugin::SubmitResponseMessage &response_message) {
			const ::Plugin::Common_Header& request_header = request_message.header();
			nscapi::protobuf::functions::make_return_header(response_message.mutable_header(), request_header);
			connection_data con(target, sender);

			std::list<collectd::packet> list;
			for (int i = 0; i < request_message.payload_size(); ++i) {
				collectd::packet packet;
				//packet.add_string(0, "Hello WOrld");
				list.push_back(packet);
			}

			send(response_message.add_payload(), con, list);
			return true;
		}
Esempio n. 2
0
int NRDPClient::clp_handler_impl::submit(client::configuration::data_type data, const Plugin::SubmitRequestMessage &request_message, Plugin::SubmitResponseMessage &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) {
		std::string alias, msg, perf;
		NSCAPI::nagiosReturn result = nscapi::protobuf::functions::parse_simple_submit_request_payload(request_message.payload(i), alias, msg, perf);
		if (alias == "host_check")
			nrdp_data.add_host(con.sender_hostname, result, msg, perf);
		else
			nrdp_data.add_service(con.sender_hostname, alias, result, msg, perf);
	}

	boost::tuple<int,std::string> ret = send(con, nrdp_data);
	nscapi::protobuf::functions::append_simple_submit_response_payload(response_message.add_payload(), "TODO", ret.get<0>(), ret.get<1>());
	return NSCAPI::isSuccess;
}
Esempio n. 3
0
int SMTPClient::clp_handler_impl::submit(client::configuration::data_type data, const Plugin::SubmitRequestMessage &request_message, Plugin::SubmitResponseMessage &response_message) {
	const ::Plugin::Common_Header& request_header = request_message.header();
	connection_data con = parse_header(request_header, data);
	std::wstring channel = utf8::cvt<std::wstring>(request_message.channel());

	nscapi::protobuf::functions::make_return_header(response_message.mutable_header(), request_header);

	for (int i=0;i < request_message.payload_size(); ++i) {
		const ::Plugin::QueryResponseMessage::Response& payload = request_message.payload(i);
		boost::asio::io_service io_service;
		boost::shared_ptr<smtp::client::smtp_client> client(new smtp::client::smtp_client(io_service));
		std::list<std::string> recipients;
		std::string message = con.template_string;
		strEx::replace(message, "%message%", payload.message());
		recipients.push_back(con.recipient_str);
		client->send_mail(con.sender, recipients, "Hello world\n");
		io_service.run();
		nscapi::protobuf::functions::append_simple_submit_response_payload(response_message.add_payload(), "TODO", NSCAPI::returnOK, "Message send successfully");
	}
	return NSCAPI::isSuccess;

}