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; }
function api_data_query_execute($host_id, $data_query_id) { require_once(CACTI_BASE_PATH . "/include/data_query/data_query_constants.php"); require_once(CACTI_BASE_PATH . "/lib/data_query/data_query_info.php"); require_once(CACTI_BASE_PATH . "/lib/data_query/data_query_update.php"); require_once(CACTI_BASE_PATH . "/lib/poller.php"); /* get information about the data query */ $data_query = api_data_query_get($data_query_id); debug_log_insert("data_query", "Running data query [$data_query_id]."); if ($data_query["input_type"] == DATA_QUERY_INPUT_TYPE_SNMP_QUERY) { debug_log_insert("data_query", _("Found type = '1' [snmp query].")); $result = api_data_query_snmp_execute($host_id, $data_query_id); }elseif ($data_query["input_type"] == DATA_QUERY_INPUT_TYPE_SCRIPT_QUERY) { debug_log_insert("data_query", _("Found type = '2 '[script query].")); $result = api_data_query_script_execute($host_id, $data_query_id); }elseif ($data_query["input_type"] == DATA_QUERY_INPUT_TYPE_PHP_SCRIPT_SERVER_QUERY) { debug_log_insert("data_query", _("Found type = '3 '[php script server query].")); $result = api_data_query_script_execute($host_id, $data_query_id); }else{ debug_log_insert("data_query", sprintf(_("Unknown type = '%i'"), $data_query["input_type"])); } /* update the sort cache */ update_data_query_sort_cache($host_id, $data_query_id); /* update the auto reindex cache */ update_reindex_cache($host_id, $data_query_id); /* update the poller cache */ update_poller_cache_from_query($host_id, $data_query_id); return (isset($result) ? $result : true); }
/** * 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); }
function run_data_query($host_id, $snmp_query_id) { global $config; 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 ($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); /* update the poller cache */ update_poller_cache_from_query($host_id, $snmp_query_id); return (isset($result) ? $result : true); }