__('None'), SNMP_TRAP_TYPE_COLD_START => __('Cold start (0)'), SNMP_TRAP_TYPE_WARM_START => __('Warm start (1)'), SNMP_TRAP_TYPE_LINK_DOWN => __('Link down (2)'), SNMP_TRAP_TYPE_LINK_UP => __('Link up (3)'), SNMP_TRAP_TYPE_AUTHENTICATION_FAILURE => __('Authentication failure (4)'), SNMP_TRAP_TYPE_OTHER => __('Other')); // Form submitted // ============= $update_alert = (bool)get_parameter('update_alert', false); $create_alert = (bool)get_parameter('create_alert', false); $save_alert = (bool)get_parameter('save_alert', false); $modify_alert = (bool)get_parameter('modify_alert', false); $delete_alert = (bool)get_parameter('delete_alert', false); $multiple_delete = (bool)get_parameter('multiple_delete', false); if ($update_alert || $modify_alert) { ui_print_page_header(__('SNMP Console')." » ".__('Update alert'), "images/op_snmp.png", false, "snmp_alert", false); } else if ($create_alert || $save_alert) { ui_print_page_header(__('SNMP Console')." » ".__('Create alert'), "images/op_snmp.png", false, "snmp_alert", false); } else { ui_print_page_header(__('SNMP Console')." » ".__('Alert overview'), "images/op_snmp.png", false, "snmp_alert", false); } if ($save_alert || $modify_alert) { $id_as = (int) get_parameter("id_alert_snmp", -1); $source_ip = (string) get_parameter_post ("source_ip"); $alert_type = (int) get_parameter_post ("alert_type"); //Event, e-mail $description = (string) get_parameter_post ("description"); $oid = (string) get_parameter_post ("oid"); $custom_value = (string) get_parameter_post ("custom_value"); $time_threshold = (int) get_parameter_post ("time_threshold", SECONDS_5MINUTES); $time_other = (int) get_parameter_post ("time_other", -1); $al_field1 = (string) get_parameter_post ("field1_value"); $al_field2 = (string) get_parameter_post ("field2_value"); $al_field3 = (string) get_parameter_post ("field3_value"); $al_field4 = (string) get_parameter_post ("field4_value"); $al_field5 = (string) get_parameter_post ("field5_value"); $al_field6 = (string) get_parameter_post ("field6_value"); $al_field7 = (string) get_parameter_post ("field7_value"); $al_field8 = (string) get_parameter_post ("field8_value"); $al_field9 = (string) get_parameter_post ("field9_value"); $al_field10 = (string) get_parameter_post ("al_field10"); $max_alerts = (int) get_parameter_post ("max_alerts", 1); $min_alerts = (int) get_parameter_post ("min_alerts", 0); $priority = (int) get_parameter_post ("priority", 0); $custom_oid_data_1 = (string) get_parameter ("custom_oid_data_1"); $custom_oid_data_2 = (string) get_parameter ("custom_oid_data_2"); $custom_oid_data_3 = (string) get_parameter ("custom_oid_data_3"); $custom_oid_data_4 = (string) get_parameter ("custom_oid_data_4"); $custom_oid_data_5 = (string) get_parameter ("custom_oid_data_5"); $custom_oid_data_6 = (string) get_parameter ("custom_oid_data_6"); $custom_oid_data_7 = (string) get_parameter ("custom_oid_data_7"); $custom_oid_data_8 = (string) get_parameter ("custom_oid_data_8"); $custom_oid_data_9 = (string) get_parameter ("custom_oid_data_9"); $custom_oid_data_10 = (string) get_parameter ("custom_oid_data_10"); $trap_type = (int) get_parameter ("trap_type", -1); $single_value = (string) get_parameter ("single_value"); $position = (int) get_parameter ("position"); if ($time_threshold == -1) { $time_threshold = $time_other; } if ($save_alert) { $values = array( 'id_alert' => $alert_type, 'al_field1' => $al_field1, 'al_field2' => $al_field2, 'al_field3' => $al_field3, 'al_field4' => $al_field4, 'al_field5' => $al_field5, 'al_field6' => $al_field6, 'al_field7' => $al_field7, 'al_field8' => $al_field8, 'al_field9' => $al_field9, 'al_field10' => $al_field10, 'description' => $description, 'agent' => $source_ip, 'custom_oid' => $custom_value, 'oid' => $oid, 'time_threshold' => $time_threshold, 'max_alerts' => $max_alerts, 'min_alerts' => $min_alerts, 'priority' => $priority, '_snmp_f1_' => $custom_oid_data_1, '_snmp_f2_' => $custom_oid_data_2, '_snmp_f3_' => $custom_oid_data_3, '_snmp_f4_' => $custom_oid_data_4, '_snmp_f5_' => $custom_oid_data_5, '_snmp_f6_' => $custom_oid_data_6, '_snmp_f7_' => $custom_oid_data_7, '_snmp_f8_' => $custom_oid_data_8, '_snmp_f9_' => $custom_oid_data_9, '_snmp_f10_' => $custom_oid_data_10, 'trap_type' => $trap_type, 'single_value' => $single_value, 'position' => $position); $result = db_process_sql_insert('talert_snmp', $values); if (!$result) { db_pandora_audit("SNMP management", "Fail try to create snmp alert"); ui_print_error_message(__('There was a problem creating the alert')); } else { db_pandora_audit("SNMP management", "Create snmp alert #$result"); ui_print_success_message(__('Successfully created')); } } else { $sql = sprintf ("UPDATE talert_snmp SET priority = %d, id_alert = %d, al_field1 = '%s', al_field2 = '%s', al_field3 = '%s', al_field4 = '%s', al_field5 = '%s', al_field6 = '%s',al_field7 = '%s', al_field8 = '%s', al_field9 = '%s',al_field10 = '%s', description = '%s', agent = '%s', custom_oid = '%s', oid = '%s', time_threshold = %d, max_alerts = %d, min_alerts = %d, _snmp_f1_ = '%s', _snmp_f2_ = '%s', _snmp_f3_ = '%s', _snmp_f4_ = '%s', _snmp_f5_ = '%s', _snmp_f6_ = '%s', _snmp_f7_ = '%s', _snmp_f8_ = '%s', _snmp_f9_ = '%s', _snmp_f10_ = '%s', trap_type = %d, single_value = '%s', position = '%s' WHERE id_as = %d", $priority, $alert_type, $al_field1, $al_field2, $al_field3, $al_field4, $al_field5, $al_field6, $al_field7, $al_field8, $al_field9, $al_field10, $description, $source_ip, $custom_value, $oid, $time_threshold, $max_alerts, $min_alerts, $custom_oid_data_1, $custom_oid_data_2, $custom_oid_data_3, $custom_oid_data_4, $custom_oid_data_5, $custom_oid_data_6, $custom_oid_data_7, $custom_oid_data_8, $custom_oid_data_9, $custom_oid_data_10, $trap_type, $single_value, $position, $id_as); $result = db_process_sql ($sql); if (!$result) { db_pandora_audit("SNMP management", "Fail try to update snmp alert #$id_as"); ui_print_error_message(__('There was a problem updating the alert')); } else { db_pandora_audit("SNMP management", "Update snmp alert #$id_as"); ui_print_success_message(__('Successfully updated')); } } } // From variable init // ================== if ($update_alert) { $id_as = (int) get_parameter("id_alert_snmp", -1); $alert = db_get_row ("talert_snmp", "id_as", $id_as); $id_as = $alert["id_as"]; $source_ip = $alert["agent"]; $alert_type = $alert["id_alert"]; $description = $alert["description"]; $oid = $alert["oid"]; $custom_value = $alert["custom_oid"]; $time_threshold = $alert["time_threshold"]; $al_field1 = $alert["al_field1"]; $al_field2 = $alert["al_field2"]; $al_field3 = $alert["al_field3"]; $al_field4 = $alert["al_field4"]; $al_field5 = $alert["al_field5"]; $al_field6 = $alert["al_field6"]; $al_field7 = $alert["al_field7"]; $al_field8 = $alert["al_field8"]; $al_field9 = $alert["al_field9"]; $al_field10 = $alert["al_field10"]; $max_alerts = $alert["max_alerts"]; $min_alerts = $alert["min_alerts"]; $priority = $alert["priority"]; $custom_oid_data_1 = $alert["_snmp_f1_"]; $custom_oid_data_2 = $alert["_snmp_f2_"]; $custom_oid_data_3 = $alert["_snmp_f3_"]; $custom_oid_data_4 = $alert["_snmp_f4_"]; $custom_oid_data_5 = $alert["_snmp_f5_"]; $custom_oid_data_6 = $alert["_snmp_f6_"]; $custom_oid_data_7 = $alert["_snmp_f7_"]; $custom_oid_data_8 = $alert["_snmp_f8_"]; $custom_oid_data_9 = $alert["_snmp_f9_"]; $custom_oid_data_10 = $alert["_snmp_f10_"]; $trap_type = $alert["trap_type"]; $single_value = $alert["single_value"]; $position = $alert["position"]; } elseif ($create_alert) { // Variable init $id_as = -1; $source_ip = ""; $alert_type = 1; //Event, e-mail $description = ""; $oid = ""; $custom_value = ""; $time_threshold = SECONDS_5MINUTES; $al_field1 = ""; $al_field2 = ""; $al_field3 = ""; $al_field4 = ""; $al_field5 = ""; $al_field6 = ""; $al_field7 = ""; $al_field8 = ""; $al_field9 = ""; $al_field10 = ""; $max_alerts = 1; $min_alerts = 0; $priority = 0; $custom_oid_data_1 = ''; $custom_oid_data_2 = ''; $custom_oid_data_3 = ''; $custom_oid_data_4 = ''; $custom_oid_data_5 = ''; $custom_oid_data_6 = ''; $custom_oid_data_7 = ''; $custom_oid_data_8 = ''; $custom_oid_data_9 = ''; $custom_oid_data_10 = ''; $trap_type = -1; $single_value = ''; $position = 0; } // Header // Alert Delete // ============= if ($delete_alert) { // Delete alert $alert_delete = (int) get_parameter_get ("delete_alert", 0); $result = db_process_sql_delete('talert_snmp', array('id_as' => $alert_delete)); if ($result === false) { db_pandora_audit("SNMP management", "Fail try to delete snmp alert #$alert_delete"); ui_print_error_message(__('There was a problem deleting the alert')); } else { db_pandora_audit("SNMP management", "Delete snmp alert #$alert_delete"); ui_print_success_message(__('Successfully deleted')); } } if ($multiple_delete) { $delete_ids = get_parameter('delete_ids', array()); $total = count($delete_ids); $count = 0; foreach ($delete_ids as $alert_delete) { $result = db_process_sql_delete('talert_snmp', array('id_as' => $alert_delete)); if ($result !== false) { db_pandora_audit("SNMP management", "Delete snmp alert #$alert_delete"); $count++; } else { db_pandora_audit("SNMP management", "Fail try to delete snmp alert #$alert_delete"); } } if ($count == $total) { ui_print_success_message(__('Successfully deleted alerts (%s / %s)', $count, $total)); } else { ui_print_error_message(__('Unsuccessfully deleted alerts (%s / %s)', $count, $total)); } } // Alert form if ($create_alert || $update_alert) { //if (isset ($_GET["update_alert"])) { //the update_alert means the form should be displayed. If update_alert > 1 then an existing alert is updated echo '
"; } else { require_once ('include/functions_alerts.php'); $free_search = (string)get_parameter('free_search', ''); $trap_type_filter = (int)get_parameter('trap_type_filter', SNMP_TRAP_TYPE_NONE); $priority_filter = (int)get_parameter('priority_filter', -1); $filter_param = (bool)get_parameter('filter', false); $offset = (int) get_parameter ('offset'); $table_filter = new stdClass(); $table_filter->width = "98%"; $table_filter->data = array(); $table_filter->data[0][0] = __('Free search') . ui_print_help_tip( __('Search by these fields description, OID, Custom Value, SNMP Agent (IP), Single value, each Custom OIDs/Datas.'), true); $table_filter->data[0][1] = html_print_input_text('free_search', $free_search, '', 30, 100, true); $table_filter->data[0][2] = __('Trap type'); $table_filter->data[0][3] = html_print_select ($trap_types, 'trap_type_filter', $trap_type_filter, '', '', '', true, false, false); $table_filter->data[0][4] = __('Priority'); $table_filter->data[0][5] = html_print_select (get_priorities(), "priority_filter", $priority_filter, '', __('None'), '-1', true, false, false);; $form_filter = ''; echo "