diff --git a/cmd.php b/cmd.php index 35c1fcf8a..3ec41e8dc 100644 --- a/cmd.php +++ b/cmd.php @@ -220,15 +220,15 @@ if ((sizeof($polling_items) > 0) && (read_config_option("poller_enabled") == "on /* assert the result with the expected value in the db; recache if the assert fails */ if (($index_item["op"] == "=") && ($index_item["assert_value"] != trim($output))) { cacti_log("ASSERT: '" . $index_item["assert_value"] . "=" . trim($output) . "' failed. Recaching host '" . $item["hostname"] . "', data query #" . $index_item["data_query_id"], $print_data_to_stdout); - db_execute("insert into poller_command (poller_id,time,action,command) values (0,NOW()," . POLLER_COMMAND_REINDEX . ",'" . $item["host_id"] . ":" . $index_item["data_query_id"] . "')"); + db_execute("insert into poller_command (poller_id, time, action, command) values (0, NOW(), " . POLLER_COMMAND_REINDEX . ", '" . $item["host_id"] . ":" . $index_item["data_query_id"] . "')"); $assert_fail = true; }else if (($index_item["op"] == ">") && ($index_item["assert_value"] < trim($output))) { cacti_log("ASSERT: '" . $index_item["assert_value"] . ">" . trim($output) . "' failed. Recaching host '" . $item["hostname"] . "', data query #" . $index_item["data_query_id"], $print_data_to_stdout); - db_execute("insert into poller_command (poller_id,time,action,command) values (0,NOW()," . POLLER_COMMAND_REINDEX . ",'" . $item["host_id"] . ":" . $index_item["data_query_id"] . "')"); + db_execute("insert into poller_command (poller_id, time, action, command) values (0, NOW(), " . POLLER_COMMAND_REINDEX . ", '" . $item["host_id"] . ":" . $index_item["data_query_id"] . "')"); $assert_fail = true; }else if (($index_item["op"] == "<") && ($index_item["assert_value"] > trim($output))) { cacti_log("ASSERT: '" . $index_item["assert_value"] . "<" . trim($output) . "' failed. Recaching host '" . $item["hostname"] . "', data query #" . $index_item["data_query_id"], $print_data_to_stdout); - db_execute("insert into poller_command (poller_id,time,action,command) values (0,NOW()," . POLLER_COMMAND_REINDEX . ",'" . $item["host_id"] . ":" . $index_item["data_query_id"] . "')"); + db_execute("insert into poller_command (poller_id, time, action, command) values (0, NOW(), " . POLLER_COMMAND_REINDEX . ", '" . $item["host_id"] . ":" . $index_item["data_query_id"] . "')"); $assert_fail = true; } @@ -348,7 +348,7 @@ if ((sizeof($polling_items) > 0) && (read_config_option("poller_enabled") == "on db_execute("insert into poller_output (local_data_id,rrd_name,time,output) values (" . $item["local_data_id"] . ",'" . $item["rrd_name"] . "','$host_update_time','" . addslashes("U") . "')"); /* otherwise, just insert the value received from the poller */ }else{ - db_execute("insert into poller_output (local_data_id,rrd_name,time,output) values (" . $item["local_data_id"] . ",'" . $item["rrd_name"] . "','$host_update_time','" . addslashes($output) . "')"); + db_execute("insert into poller_output (local_data_id, rrd_name, time, output) values (" . $item["local_data_id"] . ", '" . $item["rrd_name"] . "', '$host_update_time', '" . addslashes($output) . "')"); } } } /* Next Cache Item */ @@ -383,4 +383,4 @@ if ((sizeof($polling_items) > 0) && (read_config_option("poller_enabled") == "on /* Let the poller server know about cmd.php being finished */ db_execute("insert into poller_time (poller_id, start_time, end_time) values (0, NOW(), NOW())"); -?> \ No newline at end of file +?> diff --git a/lib/poller.php b/lib/poller.php index a70972e26..1d01c476b 100644 --- a/lib/poller.php +++ b/lib/poller.php @@ -142,8 +142,8 @@ function update_reindex_cache($host_id, $data_query_id) { /* will be used to keep track of sql statements to execute later on */ $recache_stack = array(); - $host = db_fetch_row("select hostname,snmp_community,snmp_version,snmp_username,snmp_password,snmp_port,snmp_timeout from host where id=$host_id"); - $data_query = db_fetch_row("select reindex_method,sort_field from host_snmp_query where host_id=$host_id and snmp_query_id=$data_query_id"); + $host = db_fetch_row("select hostname, snmp_community, snmp_version, snmp_username, snmp_password, snmp_port, snmp_timeout from host where id=$host_id"); + $data_query = db_fetch_row("select reindex_method, sort_field from host_snmp_query where host_id=$host_id and snmp_query_id=$data_query_id"); $data_query_type = db_fetch_cell("select data_input.type_id from (data_input,snmp_query) where data_input.id=snmp_query.data_input_id and snmp_query.id=$data_query_id"); $data_query_xml = get_data_query_array($data_query_id); @@ -175,11 +175,11 @@ function update_reindex_cache($host_id, $data_query_id) { if ($data_query_type == DATA_INPUT_TYPE_SNMP_QUERY) { if (isset($data_query_xml["oid_num_indexes"])) { - array_push($recache_stack, "insert into poller_reindex (host_id,data_query_id,action,op,assert_value,arg1) values ($host_id,$data_query_id,0,'=','$assert_value','" . $data_query_xml["oid_num_indexes"] . "')"); + array_push($recache_stack, "insert into poller_reindex (host_id, data_query_id, action, op, assert_value, arg1) values ($host_id, $data_query_id, 0, '=', '$assert_value', '" . $data_query_xml["oid_num_indexes"] . "')"); } }else if ($data_query_type == DATA_INPUT_TYPE_SCRIPT_QUERY) { if (isset($data_query_xml["arg_num_indexes"])) { - array_push($recache_stack, "insert into poller_reindex (host_id,data_query_id,action,op,assert_value,arg1) values ($host_id,$data_query_id,1,'=','$assert_value','" . get_script_query_path((isset($data_query_xml["arg_prepend"]) ? $data_query_xml["arg_prepend"] . " ": "") . $data_query_xml["arg_num_indexes"], $data_query_xml["script_path"], $host_id) . "')"); + array_push($recache_stack, "insert into poller_reindex (host_id, data_query_id, action, op, assert_value, arg1) values ($host_id, $data_query_id, 1, '=', '$assert_value', '" . get_script_query_path((isset($data_query_xml["arg_prepend"]) ? $data_query_xml["arg_prepend"] . " ": "") . $data_query_xml["arg_num_indexes"], $data_query_xml["script_path"], $host_id) . "')"); } } @@ -192,9 +192,9 @@ function update_reindex_cache($host_id, $data_query_id) { $assert_value = $index["field_value"]; if ($data_query_type == DATA_INPUT_TYPE_SNMP_QUERY) { - array_push($recache_stack, "insert into poller_reindex (host_id,data_query_id,action,op,assert_value,arg1) values ($host_id,$data_query_id,0,'=','$assert_value','" . $data_query_xml["fields"]{$data_query["sort_field"]}["oid"] . "." . $index["snmp_index"] . "')"); + array_push($recache_stack, "insert into poller_reindex (host_id, data_query_id, action, op, assert_value, arg1) values ($host_id, $data_query_id, 0, '=', '$assert_value', '" . $data_query_xml["fields"]{$data_query["sort_field"]}["oid"] . "." . $index["snmp_index"] . "')"); }else if ($data_query_type == DATA_INPUT_TYPE_SCRIPT_QUERY) { - array_push($recache_stack, "insert into poller_reindex (host_id,data_query_id,action,op,assert_value,arg1) values ($host_id,$data_query_id,1,'=','$assert_value','" . get_script_query_path((isset($data_query_xml["arg_prepend"]) ? $data_query_xml["arg_prepend"] . " ": "") . $data_query_xml["arg_get"] . " " . $data_query_xml["fields"]{$data_query["sort_field"]}["query_name"] . " " . $index["snmp_index"], $data_query_xml["script_path"], $host_id) . "')"); + array_push($recache_stack, "insert into poller_reindex (host_id, data_query_id, action, op, assert_value, arg1) values ($host_id, $data_query_id, 1, '=', '$assert_value', '" . get_script_query_path((isset($data_query_xml["arg_prepend"]) ? $data_query_xml["arg_prepend"] . " ": "") . $data_query_xml["arg_get"] . " " . $data_query_xml["fields"]{$data_query["sort_field"]}["query_name"] . " " . $index["snmp_index"], $data_query_xml["script_path"], $host_id) . "')"); } } } @@ -295,4 +295,4 @@ function process_poller_output($rrdtool_pipe) { return $rrds_processed; } -?> \ No newline at end of file +?>