, 2003-2005 // Raul Mateos , 2004-2005 // Cargamos variables globales require("include/config.php"); if (give_acl($id_user, 0, "LW")==1) { // Variable init $view_alert=1; $alert_add = 0; $alert_update=0; $alert_submit=0; $id_as = ""; $id_alert = ""; $nombre_alerta = ""; $alert_type = ""; $agent = ""; $description = ""; $oid = ""; $custom_oid = ""; $time_threshold = ""; $al_field1 = ""; $al_field2 = ""; $al_field3 = ""; $last_fired = ""; $max_alerts = ""; $min_alerts = ""; // Alert Delete // ============= if (isset($_GET["delete_alert"])){ // Delete alert $alert_delete = $_GET["delete_alert"]; $sql1='DELETE FROM talert_snmp WHERE id_as = '.$alert_delete; $result=mysql_query($sql1); } // Alert submit (for insert or update) if (isset($_GET["submit"])){ $alert_submit=1; $create = entrada_limpia($_POST["create"]); $update = entrada_limpia($_POST["create"]); $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)"; } 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); } // 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"]."

"; echo ''; 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["max_alerts"]; echo ''; echo '
'.$lang_label["min_alerts"]; echo ''; echo '
'.$lang_label["time_threshold"]; 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 '

'.$lang_label["snmp_assigned_alerts"]."

"; if (mysql_num_rows($result)){ if ($alert_submit !=0) { echo '

'.$lang_label["update_alert_ok"]."

"; } echo ''; echo '"; echo "
'.$lang_label["alert"]; echo ''.$lang_label["alert_type"]; echo ''.$lang_label["SNMP_agent"]; echo ''.$lang_label["OID"]; echo ''.$lang_label["customvalue"]; echo ''.$lang_label["description"]; echo ''.$lang_label["times_fired"]; echo ''.$lang_label["last_fired"]; echo ''.$lang_label["action"]; ; while ($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"]; $times_fired = $row["times_fired"]; $max_alerts = $row["max_alerts"]; $min_alerts = $row["min_alerts"]; echo "
"; 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 != "2005-01-01 00:00:00") echo $last_fired; else echo "N/A"; 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"); } ?>