", $config["base_path"], $xml_file_path); if (!file_exists($xml_file_path)) { debug_log_insert("data_query", "Could not find data query XML file at '$xml_file_path'"); return false; } debug_log_insert("data_query", "Found data query XML file at '$xml_file_path'"); $data = implode("",file($xml_file_path)); return xml2array($data); } function query_script_host($host_id, $snmp_query_id) { $script_queries = get_data_query_array($snmp_query_id); if ($script_queries == false) { debug_log_insert("data_query", "Error parsing XML file into an array."); return false; } debug_log_insert("data_query", "XML file parsed ok."); /* get a complete path for out target script */ $script_path = substitute_data_query_path($script_queries["script_path"]); /* get any extra arguments that need to be passed to the script */ if (!empty($script_queries["arg_prepend"])) { $extra_arguments = substitute_host_data($script_queries["arg_prepend"], "|", "|", $host_id); }else{ $extra_arguments = ""; } /* fetch specified index at specified OID */ $script_index_array = exec_into_array("$script_path $extra_arguments " . $script_queries["arg_index"]); debug_log_insert("data_query", "Executing script for list of indexes '$script_path $extra_arguments " . $script_queries["arg_index"] . "'"); db_execute("delete from host_snmp_cache where host_id=$host_id and snmp_query_id=$snmp_query_id"); while (list($field_name, $field_array) = each($script_queries["fields"])) { if ($field_array["direction"] == "input") { $script_data_array = exec_into_array("$script_path $extra_arguments " . $script_queries["arg_query"] . " " . $field_array["query_name"]); debug_log_insert("data_query", "Executing script query '$script_path $extra_arguments " . $script_queries["arg_query"] . " " . $field_array["query_name"] . "'"); for ($i=0;($i ifIndex [index_value] => 3 [output_type] => 13 ) */ function data_query_field_list($data_template_data_id) { $field = db_fetch_assoc("select data_input_fields.type_code, data_input_data.value from data_input_fields,data_input_data where data_input_fields.id=data_input_data.data_input_field_id and data_input_data.data_template_data_id=$data_template_data_id and (data_input_fields.type_code='index_type' or data_input_fields.type_code='index_value' or data_input_fields.type_code='output_type')"); $field = array_rekey($field, "type_code", "value"); if ((!isset($field["index_type"])) || (!isset($field["index_value"])) || (!isset($field["output_type"]))) { return 0; }else{ return $field; } } ?>