'" . db_fetch_cell("select name from snmp_query_graph where id=" . $_GET["id"]) . "'?", $_SERVER["HTTP_REFERER"], "snmp.php?action=item_remove&id=" . $_GET["id"] . "&snmp_query_id=" . $_GET["snmp_query_id"]); include("./include/bottom_footer.php"); exit; } if ((read_config_option("remove_verification") == "") || (isset($_GET["confirm"]))) { db_execute("delete from snmp_query_graph where id=" . $_GET["id"]); db_execute("delete from snmp_query_graph_rrd where snmp_query_graph_id=" . $_GET["id"]); db_execute("delete from snmp_query_graph_rrd_sv where snmp_query_graph_id=" . $_GET["id"]); db_execute("delete from snmp_query_graph_sv where snmp_query_graph_id=" . $_GET["id"]); } } function snmp_item_edit() { global $colors, $paths, $fields_data_query_item_edit; if (!empty($_GET["id"])) { $snmp_query_item = db_fetch_row("select * from snmp_query_graph where id=" . $_GET["id"]); } $snmp_query = db_fetch_row("select name,xml_path from snmp_query where id=" . $_GET["snmp_query_id"]); $header_label = "[edit: " . $snmp_query["name"] . "]"; start_box("Associated Graph/Data Templates $header_label", "98%", $colors["header"], "3", "center", ""); draw_edit_form(array( "config" => array(), "fields" => inject_form_variables($fields_data_query_item_edit, (isset($snmp_query_item) ? $snmp_query_item : array()), $_GET) )); end_box(); if (!empty($snmp_query_item["id"])) { start_box("Associated Data Templates", "98%", $colors["header"], "3", "center", ""); $data_templates = db_fetch_assoc("select data_template.id, data_template.name from data_template, data_template_rrd, graph_templates_item where graph_templates_item.task_item_id=data_template_rrd.id and data_template_rrd.data_template_id=data_template.id and data_template_rrd.local_data_id=0 and graph_templates_item.local_graph_id=0 and graph_templates_item.graph_template_id=" . $snmp_query_item["graph_template_id"] . " group by data_template.id order by data_template.name"); $i = 0; if (sizeof($data_templates) > 0) { foreach ($data_templates as $data_template) { print " Data Template - " . $data_template["name"] . " "; $data_template_rrds = db_fetch_assoc("select data_template_rrd.id, data_template_rrd.data_source_name, snmp_query_graph_rrd.snmp_field_name, snmp_query_graph_rrd.snmp_query_graph_id from data_template_rrd left join snmp_query_graph_rrd on (snmp_query_graph_rrd.data_template_rrd_id=data_template_rrd.id and snmp_query_graph_rrd.snmp_query_graph_id=" . $_GET["id"] . " and snmp_query_graph_rrd.data_template_id=" . $data_template["id"] . ") where data_template_rrd.data_template_id=" . $data_template["id"] . " and data_template_rrd.local_data_id=0 order by data_template_rrd.data_source_name"); $i = 0; if (sizeof($data_template_rrds) > 0) { foreach ($data_template_rrds as $data_template_rrd) { if (empty($data_template_rrd["snmp_query_graph_id"])) { $old_value = ""; }else{ $old_value = "on"; } form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++; ?>
Data Source: ";?>
Suggested Values", "98%", $colors["header"], "3", "center", ""); reset($data_templates); /* suggested values for data templates */ if (sizeof($data_templates) > 0) { foreach ($data_templates as $data_template) { $suggested_values = db_fetch_assoc("select text, field_name, id from snmp_query_graph_rrd_sv where snmp_query_graph_id=" . $_GET["id"] . " and data_template_id=" . $data_template["id"] . " order by field_name,sequence"); print " Data Template - " . $data_template["name"] . " "; $i = 0; if (sizeof($suggested_values) > 0) { foreach ($suggested_values as $suggested_value) { form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++; ?>
&id=&snmp_query_id=&data_template_id=&field_name=">Move Down &id=&snmp_query_id=&data_template_id=&field_name=">Move Up &id=&snmp_query_id=&data_template_id=">Delete 
_text" size="30">  Field Name: _field" size="15">  " alt="Add" align="absmiddle">
Graph Template - " . db_fetch_cell("select name from graph_templates where id=" . $snmp_query_item["graph_template_id"]) . " "; $i = 0; if (sizeof($suggested_values) > 0) { foreach ($suggested_values as $suggested_value) { form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++; ?>
&id=&snmp_query_id=&field_name=">Move Down &id=&snmp_query_id=&field_name=">Move Up &id=&snmp_query_id=">Delete 
 Field Name:  
'" . db_fetch_cell("select name from snmp_query where id=" . $_GET["id"]) . "'?", $_SERVER["HTTP_REFERER"], "snmp.php?action=remove&id=" . $_GET["id"]); include("./include/bottom_footer.php"); exit; } if ((read_config_option("remove_verification") == "") || (isset($_GET["confirm"]))) { $snmp_query_graph = db_fetch_assoc("select id from snmp_query_graph where snmp_query_id=" . $_GET["id"]); if (sizeof($snmp_query_graph) > 0) { foreach ($snmp_query_graph as $item) { db_execute("delete from snmp_query_graph_rrd where snmp_query_graph_id=" . $item["id"]); } } db_execute("delete from snmp_query where id=" . $_GET["id"]); db_execute("delete from snmp_query_field where snmp_query_id=" . $_GET["id"]); db_execute("delete from snmp_query_graph where snmp_query_id=" . $_GET["id"]); db_execute("delete from host_template_snmp_query where snmp_query_id=" . $_GET["id"]); db_execute("delete from host_snmp_query where snmp_query_id=" . $_GET["id"]); db_execute("delete from host_snmp_cache where snmp_query_id=" . $_GET["id"]); } } function snmp_edit() { global $colors, $snmp_query_field_actions, $paths, $fields_data_query_edit, $config; if (!empty($_GET["id"])) { $snmp_query = db_fetch_row("select * from snmp_query where id=" . $_GET["id"]); $header_label = "[edit: " . $snmp_query["name"] . "]"; }else{ $header_label = "[new]"; } start_box("Data Queries $header_label", "98%", $colors["header"], "3", "center", ""); draw_edit_form(array( "config" => array(), "fields" => inject_form_variables($fields_data_query_edit, (isset($snmp_query) ? $snmp_query : array())) )); end_box(); if (!empty($snmp_query["id"])) { $xml_filename = str_replace("", $config["base_path"], $snmp_query["xml_path"]); if ((file_exists($xml_filename)) && (is_file($xml_filename))) { $text = "Successfully located XML file"; $xml_file_exists = true; }else{ $text = "Could not locate XML file."; $xml_file_exists = false; } start_box("", "98%", "aaaaaa", "3", "center", ""); print "$text"; end_box(); start_box("Data Input Method [" . db_fetch_cell("select name from data_input where id=" . $snmp_query["data_input_id"]) . "]", "98%", $colors["header"], "3", "center", ""); print " Data Input Field -> Data Query Field Action Mappings "; $fields = db_fetch_assoc("select data_input_fields.id, data_input_fields.name, snmp_query_field.action_id, snmp_query_field.snmp_query_id from data_input_fields left join snmp_query_field on (snmp_query_field.data_input_field_id=data_input_fields.id and snmp_query_field.snmp_query_id=" . $_GET["id"] . ") where data_input_fields.data_input_id=" . $snmp_query["data_input_id"] . " order by data_input_fields.name"); $i = 0; if (sizeof($fields) > 0) { foreach ($fields as $field) { if (empty($field["snmp_query_id"])) { $old_value = ""; }else{ $old_value = "on"; } form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++; ?>
Data Input Field: ";?>
Associated Graph Templates", "98%", $colors["header"], "3", "center", "snmp.php?action=item_edit&snmp_query_id=" . $snmp_query["id"]); print " Name Graph Template Name "; $snmp_query_graphs = db_fetch_assoc("select snmp_query_graph.id, graph_templates.name as graph_template_name, snmp_query_graph.name from snmp_query_graph left join graph_templates on snmp_query_graph.graph_template_id=graph_templates.id where snmp_query_graph.snmp_query_id=" . $snmp_query["id"] . " order by snmp_query_graph.name"); $i = 0; if (sizeof($snmp_query_graphs) > 0) { foreach ($snmp_query_graphs as $snmp_query_graph) { form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++; ?> &snmp_query_id="> &snmp_query_id=">Delete  No Graph Templates Defined."; } end_box(); } } form_save_button("snmp.php"); } function snmp() { global $colors; start_box("Data Queries", "98%", $colors["header"], "3", "center", "snmp.php?action=edit"); print ""; DrawMatrixHeaderItem("Name",$colors["header_text"],1); DrawMatrixHeaderItem(" ",$colors["header_text"],1); print ""; $snmp_queries = db_fetch_assoc("select id,name from snmp_query order by name"); $i = 0; if (sizeof($snmp_queries) > 0) { foreach ($snmp_queries as $snmp_query) { form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++; ?> "> ">Delete