' . print_image("images/normalscreen.png", true, array("title" => __('Normal screen'))) . ''; } else { // Fullscreen $link = '' . print_image("images/fullscreen.png", true, array("title" => __('Full screen'))) . ''; } // Header ui_print_page_header (__("SNMP Console"), "images/computer_error.png", false, "", false, $link); // OPERATIONS // Delete SNMP Trap entry Event (only incident management access). if (isset ($_GET["delete"])){ $id_trap = (int) get_parameter_get ("delete", 0); if ($id_trap > 0 && check_acl ($config['id_user'], 0, "IM")) { $result = db_process_sql_delete('ttrap', array('id_trap' => $id_trap)); ui_print_result_message ($result, __('Successfully deleted'), __('Could not be deleted')); } else { db_pandora_audit("ACL Violation", "Trying to delete SNMP event ID #".$id_trap); } } // Check Event (only incident write access). if (isset ($_GET["check"])) { $id_trap = (int) get_parameter_get ("check", 0); if ($id_trap > 1 && check_acl ($config['id_user'], 0, "IW")) { $values = array( 'status' => 1, 'id_usuario' => $config["id_user"]); $result = db_process_sql_update('ttrap', $values, array('id_trap' => $id_trap)); ui_print_result_message ($result, __('Successfully updated'), __('Could not be updated')); } else { db_pandora_audit("ACL Violation", "Trying to checkout SNMP Trap ID".$id_trap); } } // Mass-process DELETE if (isset ($_POST["deletebt"])) { $trap_ids = get_parameter_post ("snmptrapid", array ()); if (is_array ($trap_ids) && check_acl ($config['id_user'], 0, "IW")) { foreach ($trap_ids as $id_trap) { db_process_sql_delete('ttrap', array('id_trap' => $id_trap)); } } else { db_pandora_audit("ACL Violation", "Trying to mass-delete SNMP Trap ID"); } } // Mass-process UPDATE if (isset ($_POST["updatebt"])) { $trap_ids = get_parameter_post ("snmptrapid", array ()); if (is_array ($trap_ids) && check_acl ($config['id_user'], 0, "IW")) { foreach ($trap_ids as $id_trap) { $sql = sprintf ("UPDATE ttrap SET status = 1, id_usuario = '%s' WHERE id_trap = %d", $config["id_user"], $id_trap); db_process_sql ($sql); } } else { db_pandora_audit("ACL Violation", "Trying to mass-delete SNMP Trap ID"); } } switch ($config["dbtype"]) { case "mysql": $sql = sprintf ("SELECT * FROM ttrap ORDER BY timestamp DESC LIMIT %d,%d",$offset,$pagination); break; case "postgresql": $sql = sprintf ("SELECT * FROM ttrap ORDER BY timestamp DESC LIMIT %d OFFSET %d", $pagination, $offset); break; case "oracle": $set = array(); $set['limit'] = $pagination; $set['offset'] = $offset; $sql = sprintf ("SELECT * FROM ttrap ORDER BY timestamp DESC"); $sql = oracle_recode_query ($sql, $set); break; } $traps = db_get_all_rows_sql ($sql); if (($config['dbtype'] == 'oracle') && ($traps !== false)) { for ($i=0; $i < count($traps); $i++) { unset($traps[$i]['rnum']); } } // No traps if (empty ($traps)) { echo '
'.__('There are no SNMP traps in database').'
'; return; } // Toggle filters echo ''.__('Toggle filter(s)').' ' . print_image("images/down.png", true) . ''; echo '
'; $table->width = '90%'; $table->size = array (); $table->size[0] = '120px'; $table->data = array (); // Set filters $agents = array (); $oids = array (); $severities = get_priorities (); $alerted = array (__('Not fired'), __('Fired')); foreach ($traps as $trap) { $agent = get_agent_with_ip ($trap['source']); $agents[$trap["source"]] = $agent !== false ? $agent["nombre"] : $trap["source"]; $oid = enterprise_hook ('get_oid', array ($trap)); if ($oid === ENTERPRISE_NOT_HOOK) { $oid = $trap["oid"]; } $oids[$oid] = $oid; } //Make query to extract traps of DB. switch ($config["dbtype"]) { case "mysql": $sql = "SELECT * FROM ttrap %s ORDER BY timestamp DESC LIMIT %d,%d"; break; case "postgresql": $sql = "SELECT * FROM ttrap %s ORDER BY timestamp DESC LIMIT %d OFFSET %d"; break; case "oracle": $sql = "SELECT * FROM ttrap %s ORDER BY timestamp DESC"; break; } $whereSubquery = 'WHERE 1=1'; if ($filter_agent != '') { switch ($config["dbtype"]) { case "mysql": $whereSubquery .= ' AND source LIKE "' . $filter_agent . '"'; break; case "postgresql": case "oracle": $whereSubquery .= ' AND source LIKE \'' . $filter_agent . '\''; break; } } if ($filter_oid != '') { //Test if install the enterprise to search oid in text or oid field in ttrap. if ($config['enterprise_installed']) { switch ($config["dbtype"]) { case "mysql": $whereSubquery .= ' AND (text LIKE "' . $filter_oid . '" OR oid LIKE "' . $filter_oid . '")'; break; case "postgresql": case "oracle": $whereSubquery .= ' AND (text LIKE \'' . $filter_oid . '\' OR oid LIKE \'' . $filter_oid . '\')'; break; } } else { switch ($config["dbtype"]) { case "mysql": $whereSubquery .= ' AND oid LIKE "' . $filter_oid . '"'; break; case "postgresql": case "oracle": $whereSubquery .= ' AND oid LIKE \'' . $filter_oid . '\''; break; } } } if ($filter_fired != -1) $whereSubquery .= ' AND alerted = ' . $filter_fired; if ($search_string != '') { switch ($config["dbtype"]) { case "mysql": $whereSubquery .= ' AND value LIKE "%' . $search_string . '%"'; break; case "postgresql": case "oracle": $whereSubquery .= ' AND value LIKE \'%' . $search_string . '%\''; break; } } if ($filter_severity != -1) { //Test if install the enterprise to search oid in text or oid field in ttrap. if ($config['enterprise_installed']) $whereSubquery .= ' AND ( (alerted = 0 AND severity = ' . $filter_severity . ') OR (alerted = 1 AND priority = ' . $filter_severity . '))'; else $whereSubquery .= ' AND ( (alerted = 0 AND 1 = ' . $filter_severity . ') OR (alerted = 1 AND priority = ' . $filter_severity . '))'; } if ($filter_status != -1) $whereSubquery .= ' AND status = ' . $filter_status; switch ($config["dbtype"]) { case "mysql": $sql = sprintf($sql, $whereSubquery, $offset, $pagination); break; case "postgresql": $sql = sprintf($sql, $whereSubquery, $pagination, $offset); break; case "oracle": $set = array(); $set['limit'] = $pagination; $set['offset'] = $offset; $sql = oracle_recode_query ($sql, $set); break; } $traps = db_get_all_rows_sql($sql); if (($config['dbtype'] == 'oracle') && ($traps !== false)) { for ($i=0; $i < count($traps); $i++) { unset($traps[$i]['rnum']); } } if ($config["pure"] == 1) { echo '