예제 #1
0
파일: sldpop.c 프로젝트: SURFnet/eemo
/* Plugin initialisation */
eemo_rv eemo_sldpop_init(eemo_export_fn_table_ptr eemo_fn, const char* conf_base_path)
{
	/* Initialise logging for the plugin */
	eemo_init_plugin_log(eemo_fn->log);

	INFO_MSG("Initialising sldpop plugin");

	/* Retrieve configuration */
	if (((eemo_fn->conf_get_int)(conf_base_path, "dump_interval", &dump_interval, 300) != ERV_OK) || (dump_interval <= 0))
	{
		ERROR_MSG("Failed to retrieve the dump interval from the configuration");

		return ERV_CONFIG_ERROR;
	}

	if (((eemo_fn->conf_get_string)(conf_base_path, "stats_file", &stats_file, NULL) != ERV_OK) || (stats_file == NULL))
	{
		ERROR_MSG("Failed to retrieve output file name from the configuration");

		return ERV_CONFIG_ERROR;
	}

	if (((eemo_fn->conf_get_string)(conf_base_path, "sld_to_monitor", &sld_to_monitor, NULL) != ERV_OK) || (sld_to_monitor == NULL))
	{
		ERROR_MSG("Failed to retrieve SLD to monitor from the configuration");

		return ERV_CONFIG_ERROR;
	}

	INFO_MSG("Dumping counts every %d seconds", dump_interval);
	INFO_MSG("Writing statistics to %s", stats_file);
	INFO_MSG("Counting queries for %s", sld_to_monitor);

	/* Register DNS handler */
	if ((eemo_fn->reg_dns_handler)(&eemo_sldpop_dns_handler, PARSE_QUERY | PARSE_CANONICALIZE_NAME, &dns_handler_handle) != ERV_OK)
	{
		ERROR_MSG("Failed to register sldpop DNS handler");

		(eemo_fn->unreg_dns_handler)(dns_handler_handle);

		return ERV_GENERAL_ERROR;
	}

	INFO_MSG("sldpop plugin initialisation complete");

	return ERV_OK;
}
예제 #2
0
/* Plugin initialisation */
eemo_rv eemo_dnszabbix_init(eemo_export_fn_table_ptr eemo_fn, const char* conf_base_path)
{
	char** 	ips 		= NULL;
	int 	ipcount 	= 0;
	char*	file		= NULL;
	char*	zabbix_host	= NULL;
	eemo_rv rv		= ERV_OK;

	/* Initialise logging for the plugin */
	eemo_init_plugin_log(eemo_fn->log);

	/* Retrieve configuration */
	if (((eemo_fn->conf_get_string)(conf_base_path, "stats_file", &file, NULL) != ERV_OK) ||
	    (file == NULL))
	{
		return ERV_CONFIG_ERROR;
	}

	if ((eemo_fn->conf_get_string_array)(conf_base_path, "listen_ips", &ips, &ipcount) != ERV_OK)
	{
		free(file);

		return ERV_CONFIG_ERROR;
	}

	if (((eemo_fn->conf_get_string)(conf_base_path, "zabbix_host", &zabbix_host, NULL) != ERV_OK) ||
	    (zabbix_host == NULL))
	{
		return ERV_CONFIG_ERROR;
	}

	/* Initialise the DNS statistics counter */
	eemo_dnszabbix_stats_init(ips, ipcount, file, zabbix_host);

	/* Register DNS query handler */
	rv = (eemo_fn->reg_dns_handler)(&eemo_dnszabbix_stats_handleqr, PARSE_QUERY | PARSE_RESPONSE, &stats_dns_handler_handle);

	if (rv != ERV_OK)
	{
		ERROR_MSG("Failed to register DNS query handler");

		return rv;
	}

	return ERV_OK;
}
예제 #3
0
/* Plugin initialisation */
eemo_rv eemo_icmpfragmon_init(eemo_export_fn_table_ptr eemo_fn, const char* conf_base_path)
{
	char*	server		= NULL;
	int	port		= 0;
	int	max_packet_size	= 0;
	int	sensor_id	= 0;
	eemo_rv rv		= ERV_OK;

	/* Initialise logging for the plugin */
	eemo_init_plugin_log(eemo_fn->log);

	/* Retrieve configuration */
	if (((eemo_fn->conf_get_string)(conf_base_path, "server", &server, NULL) != ERV_OK) ||
	    (server == NULL))
	{
		return ERV_CONFIG_ERROR;
	}

	if (((eemo_fn->conf_get_int)(conf_base_path, "port", &port, 0) != ERV_OK) ||
	    (port == 0))
	{
		return ERV_CONFIG_ERROR;
	}

	if (((eemo_fn->conf_get_int)(conf_base_path, "max_packet_size", &max_packet_size, IFM_UDP_MAXSIZE) != ERV_OK) ||
	    (max_packet_size < 100))
	{
		if (max_packet_size < 100)
		{
			ERROR_MSG("Specified packet size (%d bytes) is too small, minimum packet size must be 100 bytes");
		}

		return ERV_CONFIG_ERROR;
	}

	if ((eemo_fn->conf_get_int)(conf_base_path, "sensor", &sensor_id, 0) != ERV_OK)
	{
		free(server);

		return ERV_CONFIG_ERROR;
	}

	/* Initialise the plugin */
	eemo_icmpfragmon_aggr_init(server, port, max_packet_size, sensor_id);

	/* Register ICMP handlers */
	rv = (eemo_fn->reg_icmp_handler)(ICMPv4_TYPE_TIME_EXCEEDED, ICMPv4_CODE_REASSEMBLY_FAIL, IP_TYPE_V4, &eemo_icmpfragmon_handle_icmp, &icmp_ip4_handler_handle);

	if (rv != ERV_OK)
	{
		ERROR_MSG("Failed to register ICMPv4 handler for fragment reassembly time-out");

		return rv;
	}

	rv = (eemo_fn->reg_icmp_handler)(ICMPv6_TYPE_TIME_EXCEEDED, ICMPv6_CODE_REASSEMBLY_FAIL, IP_TYPE_V6, &eemo_icmpfragmon_handle_icmp, &icmp_ip6_handler_handle);

	if (rv != ERV_OK)
	{
		ERROR_MSG("Failed to register ICMPv6 handler for fragment reassembly time-out");

		return rv;
	}

	return ERV_OK;
}