".$lang_label["delete_alert_no"].""; else echo "

".$lang_label["delete_alert_ok"]."

"; } // 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"]); 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) VALUES ($alert_id,'$field1','$field2','$field3','$description', $alert_type, '$agent', '$custom', '$oid', $time, $max, $min)"; $result=mysql_query($sql); if (!$result) echo "

".$lang_label["create_alert_no"]."

"; else echo "

".$lang_label["create_alert_ok"]."

"; } else { $sql = "UPDATE talert_snmp set 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 "

".$lang_label["update_alert_no"]."

"; else echo "

".$lang_label["create_alert_ok"]."

"; } } // 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"]; } } if (isset($_POST["add_alert"])){ $alert_add = 1; } echo "

Pandora SNMP

"; // Add alert form if (($alert_update != 0) || ($alert_add == 1)) { echo '
'; echo ''; // if known, if add will be undetermined (0). echo '

'.$lang_label["create_alert"]." ".$lang_label["help"]."

"; echo ''; echo ''; // Update or Add button if ($alert_update != 0) { echo '
'; // Alert echo '
'.$lang_label["alert"].'"; // Alert type echo '
'.$lang_label["alert_type"]; echo ''; } elseif ($alert_type == 1) { echo '
'.$lang_label["description"]; echo ''; // OID echo '
'.$lang_label["OID"]; echo ''; // OID Custom echo '
'.$lang_label["customvalue"]; echo ''; // SNMP Agent echo '
'.$lang_label["SNMP_agent"]." IP"; echo ''; // Alert fields echo '
'.$lang_label["field1"]; echo ''; echo '
'.$lang_label["field2"]; echo ''; echo '
'.$lang_label["field3"]; echo ''; // max & min alerts, time threshold echo '
'.$lang_label["min_alerts"]; echo ''; echo '
'.$lang_label["max_alerts"]; echo ''; echo '
'.$lang_label["time_threshold"]; echo ''; 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 '

'.$lang_label["snmp_assigned_alerts"]." ".$lang_label["help"]."

"; 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 "
'.$lang_label["alert"]."'.$lang_label["alert_type"]."'.$lang_label["SNMP_agent"]."'.$lang_label["OID"]."'.$lang_label["customvalue"]."'.$lang_label["description"]."'.$lang_label["times_fired"]."'.$lang_label["last_fired"]."'.$lang_label["action"]."
"; echo $nombre_alerta; echo ""; if ($alert_type == 0) { $tipo_alerta = $lang_label["OID"]; } elseif ($alert_type == 1) { $tipo_alerta = $lang_label["customvalue"]; } elseif ($alert_type == 2) { $tipo_alerta = $lang_label["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 $lang_label["never"]; echo ""; echo "".$lang_label["delete"]."   "; echo "".$lang_label["update"].""; } echo "
"; echo ''; echo ''; echo ""; echo "
"; } else { echo "
".$lang_label["no_snmp_alert"]."
"; echo "

"; echo '
'; echo ''; echo "
"; } // End of view snmp alert } } else { audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access SNMP Alert Management"); require ("general/noaccess.php"); } ?>