".__('There was a problem deleting alert').""; else echo "

".__('Alert successfully deleted')."

"; } // Alert submit (for insert or update) if (isset ($_GET["submit"])){ $alert_submit=1; $create = entrada_limpia($_POST["create"]); $update = entrada_limpia($_POST["update"]); $id_as = entrada_limpia($_POST["id_as"]); $max = entrada_limpia($_POST["max"]); $min = entrada_limpia($_POST["min"]); $time = entrada_limpia($_POST["time"]); $description = entrada_limpia($_POST["description"]); $oid = entrada_limpia($_POST["oid"]); $agent = entrada_limpia($_POST["agent"]); $custom = entrada_limpia($_POST["custom"]); $alert_id = entrada_limpia($_POST["alert_id"]); $alert_type = entrada_limpia($_POST["alert_type"]); $field1 = entrada_limpia($_POST["field1"]); $field2 = entrada_limpia($_POST["field2"]); $field3 = entrada_limpia($_POST["field3"]); $priority = get_parameter ("priority",0); if ($create == 1){ $sql = "INSERT INTO talert_snmp (id_alert,al_field1,al_field2,al_field3,description,alert_type,agent,custom_oid,oid,time_threshold,max_alerts,min_alerts, priority) VALUES ($alert_id,'$field1','$field2','$field3','$description', $alert_type, '$agent', '$custom', '$oid', $time, $max, $min, $priority)"; $result=mysql_query($sql); if (!$result) echo "

".__('There was a problem creating alert')."

"; else echo "

".__('Alert successfully created')."

"; } else { $sql = "UPDATE talert_snmp set priority = $priority, id_alert= $alert_id, al_field1 = '$field1', al_field2 = '$field2', al_field3 = '$field3', description = '$description', alert_type = $alert_type, agent = '$agent', custom_oid = '$custom', oid = '$oid', time_threshold = $time, max_alerts = '$max', min_alerts = '$min' WHERE id_as = $id_as"; $result=mysql_query($sql); if (!$result) echo "

".__('There was a problem updating alert')."

"; else echo "

".__('Alert successfully created')."

"; } } // Alert update: (first, load data used in form), later use insert/add form // ============ if (isset ($_GET["update_alert"])){ $alert_update = $_GET["update_alert"]; $sql1='SELECT * FROM talert_snmp WHERE id_as = '.$alert_update; $result=mysql_query($sql1); if ($row=mysql_fetch_array($result)){ $id_as = $row["id_as"]; $id_alert = $row["id_alert"]; $nombre_alerta = dame_nombre_alerta($id_alert); $alert_type = $row["alert_type"]; $agent = $row["agent"]; $description = $row["description"]; $oid = $row["oid"]; $custom_oid = $row["custom_oid"]; $time_threshold = $row["time_threshold"]; $al_field1 = $row["al_field1"]; $al_field2 = $row["al_field2"]; $al_field3 = $row["al_field3"]; $last_fired = $row["last_fired"]; $max_alerts = $row["max_alerts"]; $min_alerts = $row["min_alerts"]; $priority = $row["priority"]; } } if (isset($_POST["add_alert"])){ $alert_add = 1; } echo "

Pandora SNMP > "; // Add alert form if (($alert_update != 0) || ($alert_add == 1)) { if ($alert_update != 0) { echo __('Update alert')."

"; } else { echo __('Create alert').""; } echo '
'; echo ''; // if known, if add will be undetermined (0). echo ''; // Alert echo ''; // Description echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; // Time Threshold echo ''; echo '
'.__('Alert').'"; // Alert type echo '
'.__('Alert type'); echo '
'.__('Description').''; // OID echo '
'.__('OID').''; // OID Custom echo '
'.__('Custom value').''; // SNMP Agent echo '
'.__('SNMP Agent').' IP'; // Alert fields echo '
'.__('Field #1 (Alias, name)').'
'.__('Field #2 (Single Line)').'
'.__('Field #3 (Full Text)'); echo ''; // Max / Min alerts echo '
'.__('Min. number of alerts').'
'.__('Max. number of alerts').'
'.__('Time threshold').''; echo ''; // Priority echo '
'.__('Priority'); echo ''; echo print_select (get_priorities (), "alert_priority", $priority, '', '', ''); echo '
'; echo '
'; // Update or Add button if ($alert_update != 0) { echo ''; echo ""; echo ""; } else { echo ''; echo ""; echo ""; } // Endtable echo "
"; $view_alert =0; // Do not show alert list } if ($view_alert == 1) { // View alerts defined on SNMP traps $sql1='SELECT * FROM talert_snmp'; $result=mysql_query($sql1); echo __('SNMP alerts').""; if (mysql_num_rows($result)){ echo ''; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; $color=1; while ($row=mysql_fetch_array($result)){ if ($color == 1){ $tdcolor = "datos"; $color = 0; } else { $tdcolor = "datos2"; $color = 1; } $id_as = $row["id_as"]; $id_alert = $row["id_alert"]; $nombre_alerta = dame_nombre_alerta($id_alert); $alert_type = $row["alert_type"]; $agent = $row["agent"]; $description = $row["description"]; $oid = $row["oid"]; $custom_oid = $row["custom_oid"]; $time_threshold = $row["time_threshold"]; $al_field1 = $row["al_field1"]; $al_field2 = $row["al_field2"]; $al_field3 = $row["al_field3"]; $last_fired = $row["last_fired"]; $times_fired = $row["times_fired"]; $max_alerts = $row["max_alerts"]; $min_alerts = $row["min_alerts"]; echo ""; } echo "
'.__('Alert')."'.__('Alert type')."'.__('SNMP Agent')."'.__('OID')."'.__('Custom value')."'.__('Description')."'.__('Times Fired')."'.__('Last fired')."'.__('Action')."
"; echo $nombre_alerta; echo ""; if ($alert_type == 0) { $tipo_alerta = __('OID'); } elseif ($alert_type == 1) { $tipo_alerta = __('Custom value'); } elseif ($alert_type == 2) { $tipo_alerta = __('SNMP Agent'); } else { $tipo_alerta = "N/A"; } echo $tipo_alerta; echo ""; if ($alert_type == 2) { echo $agent; } else { echo "N/A"; } echo ""; if ($alert_type == 0) { echo $oid; } else { echo "N/A"; } echo ""; if ($alert_type == 1) { echo $custom_oid; } else { echo "N/A"; } echo ""; echo $description; echo ""; echo $times_fired; echo ""; if ($last_fired != "0000-00-00 00:00:00") echo $last_fired; else echo __('Never'); echo ""; echo " ".__(   "; echo " ".__(
"; echo ""; echo "
"; echo ''; echo ''; echo ""; echo "
"; } else { echo "
".__('There are no SNMP alerts')."
"; echo "
"; echo '
'; echo ''; echo "
"; } // End of view snmp alert } ?>