Example #1
0
function run_data_query($host_id, $snmp_query_id)
{
    global $config, $input_types;
    include_once $config["library_path"] . "/poller.php";
    include_once $config["library_path"] . "/utility.php";
    debug_log_insert("data_query", "Running data query [{$snmp_query_id}].");
    $type_id = db_fetch_cell("select data_input.type_id from (snmp_query,data_input) where snmp_query.data_input_id=data_input.id and snmp_query.id={$snmp_query_id}");
    if (isset($input_types[$type_id])) {
        debug_log_insert("data_query", "Found type = '" . $type_id . "' [" . $input_types[$type_id] . "].");
    }
    if ($type_id == DATA_INPUT_TYPE_SNMP_QUERY) {
        $result = query_snmp_host($host_id, $snmp_query_id);
    } elseif ($type_id == DATA_INPUT_TYPE_SCRIPT_QUERY) {
        $result = query_script_host($host_id, $snmp_query_id);
    } elseif ($type_id == DATA_INPUT_TYPE_QUERY_SCRIPT_SERVER) {
        $result = query_script_host($host_id, $snmp_query_id);
    } else {
        debug_log_insert("data_query", "Unknown type = '{$type_id}'");
    }
    /* update the sort cache */
    update_data_query_sort_cache($host_id, $snmp_query_id);
    /* update the auto reindex cache */
    update_reindex_cache($host_id, $snmp_query_id);
    /* update the the "local" data query cache */
    update_data_query_cache($host_id, $snmp_query_id);
    /* update the poller cache */
    update_poller_cache_from_query($host_id, $snmp_query_id);
    api_plugin_hook_function('run_data_query', array("host_id" => $host_id, "snmp_query_id" => $snmp_query_id));
    return isset($result) ? $result : true;
}
Example #2
0
function run_data_query($host_id, $snmp_query_id) {
	global $config;

	include_once($config["library_path"] . "/poller.php");

	debug_log_insert("data_query", "Running data query [$snmp_query_id].");
	$type_id = db_fetch_cell("select data_input.type_id from snmp_query,data_input where snmp_query.data_input_id=data_input.id and snmp_query.id=$snmp_query_id");

	if ($type_id == DATA_INPUT_TYPE_SNMP_QUERY) {
		debug_log_insert("data_query", "Found type = '3' [snmp query].");
		$result = query_snmp_host($host_id, $snmp_query_id);
	}elseif ($type_id == DATA_INPUT_TYPE_SCRIPT_QUERY) {
		debug_log_insert("data_query", "Found type = '4 '[script query].");
		$result = query_script_host($host_id, $snmp_query_id);
	}elseif ($type_id == DATA_INPUT_TYPE_QUERY_SCRIPT_SERVER) {
		debug_log_insert("data_query", "Found type = '6 '[script query].");
		$result = query_script_host($host_id, $snmp_query_id);
	}else{
		debug_log_insert("data_query", "Unknown type = '$type_id'");
	}

	/* update the sort cache */
	update_data_query_sort_cache($host_id, $snmp_query_id);

	/* update the auto reindex cache */
	update_reindex_cache($host_id, $snmp_query_id);

	/* update the the "local" data query cache */
	update_data_query_cache($host_id, $snmp_query_id);

	return (isset($result) ? $result : true);
}
Example #3
0
/**
 * run the data query
 * @param int $device_id
 * @param int $snmp_query_id
 */
function run_data_query($device_id, $snmp_query_id) {
	global $config;

	require_once(CACTI_BASE_PATH . "/include/data_input/data_input_constants.php");
	include_once(CACTI_BASE_PATH . "/lib/poller.php");
	include_once(CACTI_BASE_PATH . "/lib/utility.php");

	debug_log_insert("data_query", __("Running data query") . " [$snmp_query_id].");
	$type_id = db_fetch_cell("select data_input.type_id from (snmp_query,data_input) where snmp_query.data_input_id=data_input.id and snmp_query.id=$snmp_query_id");

	if ($type_id == DATA_INPUT_TYPE_SNMP_QUERY) {
		debug_log_insert("data_query", __("Found type") . " = '3' [snmp query].");
		$result = query_snmp_device($device_id, $snmp_query_id);
	}elseif ($type_id == DATA_INPUT_TYPE_SCRIPT_QUERY) {
		debug_log_insert("data_query", __("Found type") . " = '4 '[script query].");
		$result = query_script_device($device_id, $snmp_query_id);
	}elseif ($type_id == DATA_INPUT_TYPE_QUERY_SCRIPT_SERVER) {
		debug_log_insert("data_query", __("Found type") . " = '6 '[script query].");
		$result = query_script_device($device_id, $snmp_query_id);
	}else{
		debug_log_insert("data_query", __("Unknown type") . " = '$type_id'");
	}

	/* update the sort cache */
	update_data_query_sort_cache($device_id, $snmp_query_id);

	/* update the auto reindex cache */
	update_reindex_cache($device_id, $snmp_query_id);

	/* update the the "local" data query cache */
	update_data_query_cache($device_id, $snmp_query_id);

	/* update the poller cache */
	update_poller_cache_from_query($device_id, $snmp_query_id);

	api_plugin_hook_function('run_data_query', array("device_id" => $device_id, "snmp_query_id" => $snmp_query_id));

	return (isset($result) ? $result : true);
}