'" . db_fetch_cell("select name from snmp_query_graph where id=" . $_GET["id"]) . "'?", "data_queries.php?action=edit&id=" . $_GET["snmp_query_id"], "data_queries.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 data_query_item_edit() {
global $colors, $fields_data_query_item_edit;
/* ================= input validation ================= */
input_validate_input_number(get_request_var("id"));
input_validate_input_number(get_request_var("snmp_query_id"));
/* ==================================================== */
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"] . "]";
html_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)
));
html_end_box();
if (!empty($snmp_query_item["id"])) {
html_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++;
?>
|
Suggested Values", "98%", $colors["header"], "0", "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) {
print "\n";
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=">
&id=&snmp_query_id=&data_template_id=&field_name=">
|
&id=&snmp_query_id=&data_template_id=">
|
\n";
}
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
?>
|
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) {
print "\n";
foreach ($suggested_values as $suggested_value) {
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); $i++;
?>
|
|
|
&id=&snmp_query_id=&field_name=">
&id=&snmp_query_id=&field_name=">
|
&id=&snmp_query_id=">
|
\n";
}
form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i);
?>
|
'" . db_fetch_cell("select name from snmp_query where id=" . $_GET["id"]) . "'?", "data_queries.php", "data_queries.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_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 data_query_edit() {
global $colors, $fields_data_query_edit, $config;
/* ================= input validation ================= */
input_validate_input_number(get_request_var("id"));
/* ==================================================== */
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]";
}
html_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()))
));
html_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;
}
html_start_box("", "98%", "aaaaaa", "3", "center", "");
print "| $text | ";
html_end_box();
if ($xml_file_exists == true) {
html_start_box("Associated Graph Templates", "98%", $colors["header"], "3", "center", "data_queries.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=">
|
No Graph Templates Defined. | ";
}
html_end_box();
}
}
form_save_button("data_queries.php");
}
function data_query() {
global $colors;
/* clean up sort_column */
if (isset($_REQUEST["sort_column"])) {
$_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column"));
}
/* clean up search string */
if (isset($_REQUEST["sort_direction"])) {
$_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction"));
}
/* remember these search fields in session vars so we don't have to keep passing them around */
load_current_session_value("sort_column", "sess_data_queries_sort_column", "description");
load_current_session_value("sort_direction", "sess_data_queries_sort_direction", "ASC");
html_start_box("Data Queries", "98%", $colors["header"], "3", "center", "data_queries.php?action=edit");
$display_text = array(
"name" => array("Name", "ASC"),
"data_input_method" => array("Data Input Method", "ASC"));
html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"], 3);
$snmp_queries = db_fetch_assoc("SELECT
snmp_query.id,
snmp_query.name,
data_input.name AS data_input_method
FROM snmp_query INNER JOIN data_input ON (snmp_query.data_input_id = data_input.id)
ORDER BY " . $_REQUEST['sort_column'] . " " . $_REQUEST['sort_direction']);
$i = 0;
if (sizeof($snmp_queries) > 0) {
foreach ($snmp_queries as $snmp_query) {
form_alternate_row_color($colors["alternate"],$colors["light"],$i); $i++;
?>
">
|
|
">
|
| |