Exemplo n.º 1
0
		bool metrics(client::destination_container sender, client::destination_container target, const Plugin::MetricsMessage &request_message) {

			collectd::collectd_builder builder;
			set_metrics(builder, request_message);

			boost::posix_time::ptime const time_epoch(boost::gregorian::date(1970, 1, 1));

			unsigned long long ms = (boost::posix_time::microsec_clock::universal_time() - time_epoch).total_seconds();
			unsigned long long int_ms = 5;
			builder.set_time(ms << 30, int_ms << 30);
			builder.set_host(sender.get_host());

			builder.add_variable("diskid", "system.metrics.pdh.disk_queue_length.disk_queue_length_(.*)$");
			builder.add_variable("core", "system.cpu.core (.*).user");

			builder.add_metric("memory-/memory-available", "gauge:system.mem.physical.avail");
			//builder.add_variable("memory-/memory-pool_nonpaged", "gauge:0");
			//builder.add_variable("memory-/memory-pool_paged", "gauge:0");
			//builder.add_variable("memory-/memory-system_cache", "gauge:0");
			//builder.add_variable("memory-/memory-system_code", "gauge:0"); // 0?
			//builder.add_variable("memory-/memory-system_driver", "gauge:0");

			//builder.add_variable("interface-${nic}/if_octets-", "derive:0,0");
			//builder.add_variable("interface-${nic}/if_packets-", "derive:0,0");

			//builder.add_variable("disk-${diskid}/disk_octets", "derive:0,0");
			//builder.add_variable("disk-${diskid}/disk_ops", "derive:0,0");
			builder.add_metric("disk-${diskid}/queue_length", "gauge:system.metrics.pdh.disk_queue_length.disk_queue_length_${diskid}");

			builder.add_metric("processes-/ps_count", "gauge:system.metrics.procs.procs,system.metrics.procs.threads");


			builder.add_metric("memory-pagefile/memory-used", "gauge:system.mem.commited.used");
			builder.add_metric("memory-pagefile/memory-free", "gauge:system.mem.commited.free");

			//builder.add_variable("df-${drive}/df_complex-free", "gauge:0");
			//builder.add_variable("df-${drive}/df_complex-reserved", "gauge:0");
			//builder.add_variable("df-${drive}/df_complex-used", "gauge:0");

			//builder.add_variable("memory-/working_set-available", "gauge:0");
			//builder.add_variable("memory-/working_set-pool_nonpaged", "gauge:0");
			//builder.add_variable("memory-/working_set-pool_paged", "gauge:0");

			builder.add_metric("cpu-${core}/cpu-user", "derive:system.cpu.core ${core}.user");
			builder.add_metric("cpu-${core}/cpu-system", "derive:system.cpu.core ${core}.kernel");
			//builder.add_metric("cpu-${core}/cpu-interrupt", "derive:0");
			builder.add_metric("cpu-${core}/cpu-idle", "derive:system.cpu.core ${core}.idle");

			builder.add_metric("cpu-total/cpu-user", "derive:system.cpu.total.user");
			builder.add_metric("cpu-total/cpu-system", "derive:system.cpu.total.kernel");
			//builder.add_metric("cpu-total/cpu-interrupt", "derive:0");
			builder.add_metric("cpu-total/cpu-idle", "derive:system.cpu.total.idle");

			//NSC_DEBUG_MSG("--->" + builder.to_string());
			collectd::collectd_builder::packet_list packets;

			builder.render(packets);
			connection_data con(target, sender);
			send(con, packets);
			return true;
		}
Exemplo n.º 2
0
bool test(client::destination_container &source, client::destination_container &destination) {
	if (source.has_data("log"))
		gLog = source.get_string_data("log");
	return true;
}
Exemplo n.º 3
0
		connection_data(client::destination_container arguments, client::destination_container sender) {
			address = arguments.address.host;
			port_ = arguments.address.get_port_string("5667");
			ssl.enabled = arguments.get_bool_data("ssl");
			ssl.certificate = arguments.get_string_data("certificate");
			ssl.certificate_key = arguments.get_string_data("certificate key");
			ssl.certificate_key_format = arguments.get_string_data("certificate format");
			ssl.ca_path = arguments.get_string_data("ca");
			ssl.allowed_ciphers = arguments.get_string_data("allowed ciphers");
			ssl.dh_key = arguments.get_string_data("dh");
			ssl.verify_mode = arguments.get_string_data("verify mode");
			timeout = arguments.get_int_data("timeout", 30);
			retry = arguments.get_int_data("retries", 3);
			buffer_length = arguments.get_int_data("payload length", 512);
			password = arguments.get_string_data("password");
			encoding = arguments.get_string_data("encoding");
			std::string tmp = arguments.get_string_data("time offset");
			if (!tmp.empty())
				time_delta = strEx::stol_as_time_sec(arguments.get_string_data("time offset"));
			else
				time_delta = 0;
			sender_hostname = sender.address.host;
			if (sender.has_data("host"))
				sender_hostname = sender.get_string_data("host");
		}