From ad93a46f0f8f2c00a59519278a84cecfb75e1250 Mon Sep 17 00:00:00 2001 From: slerena Date: Fri, 13 Jun 2008 16:59:54 +0000 Subject: [PATCH] 2008-06-13 Sancho Lerena * index.php: Added pure (Fullscreen). HTML code cleanup and user session. * pandoradb.sql: talert_snmp: Added priority field. * pandoradb_data.sql: Changes default values in talerta. tconfig_os, tgrupo and some links. * header.php: Fixed some user session management. * logon_ok.php: New design for welcome screen, odometer is over. * menu.php, godmode/menu.php: Some ACL improvements. * agent_disk_conf_editor.php: Minor fix in view link. * configurar_agente.php, agent_manager.php: Added parent combo and better ACL checks. New remote configuration control for get timestamp info of config file. * modify_alert.php: Changes to use new internal Mail alert. * config.php: Some items moved to config_process. (font, attachment and default style). * functions.php: Added form_agent_combo(), form_event_type_combo(), form_priority() and return_priority() functions. * functions_db.php: Added smal_event_table() to render a variable table with latest events (filtered). * pandora.css. Added pure and priority colors. * estado_alertas.php: Fixed ACL problems. * stado_generalagente.php: Graph of modules now represents modules that has generated events. Old graph is not used anymore. Also display parent. * estado_grupo.php: Border of boxes is now thicker. * tactical.php: New screen, almost all code changed. Odometer is not used anymore, added some new items, like module LAG meter, module sanity, and other general metrics. * ver_agente.php: Now renders also event for each agent view. Alert manual validation generate a new event. * events.php: New event system. 90% new code. A LOT of new features, including full screen, coloured (by priority) and filters by six fields. * snmp_alert.php: Added support for alert priority. * operation/users/user.php: No longer a user with UM privileges could see any other user. * render_view.php: Added fullscreen support for visual maps. * fgraph.php: Added support for session checking in graphs (at least!). New graphics for events (some changed it's function like events by group), and feature added to progress GD implementation. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@860 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 70 +++- pandora_console/general/header.php | 4 +- pandora_console/general/logon_ok.php | 67 ++- .../agentes/agent_disk_conf_editor.php | 2 +- .../godmode/agentes/agent_manager.php | 84 ++-- .../godmode/agentes/alert_manager_editor.php | 18 +- .../godmode/agentes/configurar_agente.php | 12 +- .../godmode/alerts/modify_alert.php | 12 +- pandora_console/godmode/menu.php | 26 +- pandora_console/include/config.php | 12 +- pandora_console/include/config_process.php | 12 + pandora_console/include/functions.php | 126 +++++- pandora_console/include/functions_db.php | 120 +++++- pandora_console/include/styles/pandora.css | 40 ++ .../include/styles/pandora_red.css | 40 ++ pandora_console/index.php | 97 +++-- .../operation/agentes/estado_agente.php | 2 +- .../operation/agentes/estado_alertas.php | 292 +++++++------ .../agentes/estado_generalagente.php | 60 +-- .../operation/agentes/estado_grupo.php | 10 +- .../operation/agentes/status_monitor.php | 4 +- .../operation/agentes/tactical.php | 137 ++++--- .../operation/agentes/ver_agente.php | 13 +- pandora_console/operation/events/events.php | 360 +++++++++++------ .../operation/events/events_rss.php | 2 +- pandora_console/operation/menu.php | 16 +- .../operation/servers/view_server.php | 12 +- .../operation/snmpconsole/snmp_alert.php | 40 +- .../operation/snmpconsole/snmp_view.php | 13 +- pandora_console/operation/users/user.php | 8 +- .../operation/visual_console/render_view.php | 39 +- pandora_console/pandoradb.sql | 13 +- pandora_console/pandoradb_data.sql | 29 +- pandora_console/reporting/fgraph.php | 382 ++++++++++-------- 34 files changed, 1445 insertions(+), 729 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index caa86f1ded..87060c90ba 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,10 +1,72 @@ +2008-06-13 Sancho Lerena + + * index.php: Added pure (Fullscreen). HTML code cleanup and user session. + + * pandoradb.sql: talert_snmp: Added priority field. + + * pandoradb_data.sql: Changes default values in talerta. tconfig_os, tgrupo + and some links. + + * header.php: Fixed some user session management. + + * logon_ok.php: New design for welcome screen, odometer is over. + + * menu.php, godmode/menu.php: Some ACL improvements. + + * agent_disk_conf_editor.php: Minor fix in view link. + + * configurar_agente.php, agent_manager.php: Added parent combo and better + ACL checks. New remote configuration control for get timestamp info of + config file. + + * modify_alert.php: Changes to use new internal Mail alert. + + * config.php: Some items moved to config_process. (font, attachment and + default style). + + * functions.php: Added form_agent_combo(), form_event_type_combo(), + form_priority() and return_priority() functions. + + * functions_db.php: Added smal_event_table() to render a variable table + with latest events (filtered). + + * pandora.css. Added pure and priority colors. + + * estado_alertas.php: Fixed ACL problems. + + * stado_generalagente.php: Graph of modules now represents modules that + has generated events. Old graph is not used anymore. Also display parent. + + * estado_grupo.php: Border of boxes is now thicker. + + * tactical.php: New screen, almost all code changed. Odometer is not used + anymore, added some new items, like module LAG meter, module sanity, and + other general metrics. + + * ver_agente.php: Now renders also event for each agent view. Alert manual + validation generate a new event. + + * events.php: New event system. 90% new code. A LOT of new features, + including full screen, coloured (by priority) and filters by six fields. + + * snmp_alert.php: Added support for alert priority. + + * operation/users/user.php: No longer a user with UM privileges could + see any other user. + + * render_view.php: Added fullscreen support for visual maps. + + * fgraph.php: Added support for session checking in graphs (at least!). + New graphics for events (some changed it's function like events by group), + and feature added to progress GD implementation. + 2008-06-09 Sancho Lerena - * operation/agentes/status_monitor.php, - operation/agentes/estado_agente.php: Data was presented for users with - access to specific groups (fixed also in 1.3.1 branch). + * operation/agentes/status_monitor.php, + operation/agentes/estado_agente.php: Data was presented for users with + access to specific groups (fixed also in 1.3.1 branch). - * godmode/users/configure_user.php: Better management of password. + * godmode/users/configure_user.php: Better management of password. 2008-06-09 Ramon Novoa diff --git a/pandora_console/general/header.php b/pandora_console/general/header.php index 80690b4362..cb7f0d4482 100644 --- a/pandora_console/general/header.php +++ b/pandora_console/general/header.php @@ -29,16 +29,14 @@ echo "
"; echo ""; if (isset ($_SESSION["id_usuario"])){ - // Fist column echo "'; echo '"; } + + +echo ' - - -"; +echo ''; +echo ''; +echo '
"; - $id_usuario = entrada_limpia ($_SESSION["id_usuario"]); if (dame_admin($_SESSION["id_usuario"])==1) echo " "; else echo " "; echo "".$lang_label["has_connected"]. ' - ['. $id_usuario. ']'; + ['. $_SESSION["id_usuario"]. ']'; // Second column echo ""; diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php index c45473bacf..3e456a05e5 100644 --- a/pandora_console/general/logon_ok.php +++ b/pandora_console/general/logon_ok.php @@ -1,9 +1,9 @@ 0){ + $monitor_health = format_numeric ( 100- (($monitor_bad + $monitor_unknown) / ($monitor_checks/100)) , 1); + } else + $monitor_health = 100; + if ($data_checks > 0){ + $data_health = format_numeric ( (($data_checks -($data_unknown + $data_alert)) / $data_checks ) * 100,1);; + } else + $data_health = 100; + if (($data_checks != 0) OR ($data_checks != 0)){ + $global_health = format_numeric ((($data_health * $data_checks) + ($monitor_health * $monitor_checks)) / $total_checks); + } else + $global_health = 100; - if ($monitor_checks > 0){ - $monitor_health = format_numeric ((($monitor_ok - $monitor_alert - $monitor_unknown)/ $monitor_checks) * 100,1); - } else - $monitor_health = 100; - if ($data_checks > 0){ - $data_health = format_numeric ( (($data_checks -($data_unknown + $data_alert)) / $data_checks ) * 100,1);; - } else - $data_health = 100; - if (($data_checks != 0) OR ($data_checks != 0)){ - $global_health = format_numeric( ((($monitor_ok -$monitor_alert - $monitor_unknown )+($data_checks -($data_unknown + $data_alert))) / ($data_checks + $monitor_checks) ) * 100, 1); - } else - $global_health = 100; - echo "

".$lang_label["tactical_indicator"]."

"; - echo ""; +echo ""; + + //echo "

".$lang_label["tactical_indicator"]."

"; + //echo ""; + + echo "
".lang_string("Monitor health").""; + echo "
"; - echo "
"; + echo "
".lang_string("Data health").""; + echo "
"; + + echo "
".lang_string("Global health").""; + echo "
"; + + echo "
".lang_string("Module sanity").""; + echo "
"; + + + echo "
".lang_string("Alert level").""; + echo "
"; + + echo "
"; $query1 = "SELECT COUNT(id_usuario) FROM tusuario"; $result = mysql_query ($query1); diff --git a/pandora_console/godmode/agentes/agent_disk_conf_editor.php b/pandora_console/godmode/agentes/agent_disk_conf_editor.php index 4a31884897..5c4b2d8241 100644 --- a/pandora_console/godmode/agentes/agent_disk_conf_editor.php +++ b/pandora_console/godmode/agentes/agent_disk_conf_editor.php @@ -37,7 +37,7 @@ function display_config () { echo '
' . $lang_label["agent_name"] . ''; echo ''; - echo ''; + echo ''; echo ''; echo ''; echo ''; diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index ace7a7ab79..f39229b3b2 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -77,7 +77,7 @@ if (file_exists($config["remote_config"] . "/" . $agent_md5 . ".md5")) { echo '
'; echo ''.$lang_label["ip_address"].''; echo ''; -echo ''; +echo ''; if ($create_agent != 1){ echo "    "; @@ -96,34 +96,39 @@ if ($create_agent != 1){ echo "
'.lang_string ("Parent").''; +echo ''; +if ($create_agent != 1){ + form_agent_combo ($id_parent, "id_parent"); +} +else + form_agent_combo (0, "id_parent"); + + echo '
'.$lang_label["group"].''; echo ' -
-
-
"; +echo "".lang_string("interval")."'; + +echo '
'.lang_string("os").''; +echo ''; } -?> -
- -'; - echo $lang_label["active"].' - '; - } else { - echo $lang_label["disabled"].' - '; - echo $lang_label["active"].' - '; - } + +// Status (Disabled / Enabled) +echo '
'.lang_string("status").''; +echo ''; +if ($disabled == "1"){ + echo $lang_label["disabled"].' + '; + echo $lang_label["active"].' + '; +} else { + echo $lang_label["disabled"].' + '; + echo $lang_label["active"].' + '; +} + +// Remote configuration +echo '
'.lang_string("Remote configuration").''; +echo ''; +$filename = $config["remote_config"] . "/" . $agent_md5 . ".md5"; +if (file_exists($filename)){ + echo date("F d Y H:i:s.", fileatime($filename)); +} else { + echo ''.lang_string("Not available").''; +} echo '
'; if ($create_agent == 1){ diff --git a/pandora_console/godmode/agentes/alert_manager_editor.php b/pandora_console/godmode/agentes/alert_manager_editor.php index 5b049e0878..f8e7dc3108 100644 --- a/pandora_console/godmode/agentes/alert_manager_editor.php +++ b/pandora_console/godmode/agentes/alert_manager_editor.php @@ -4,6 +4,8 @@ // Pandora FMS - the Free Monitoring System // ======================================== // Copyright (c) 2008 Artica Soluciones Tecnológicas, http://www.artica.es +// Copyright (c) 2008 Sancho Lerena + // Please see http://pandora.sourceforge.net for full contribution list // This program is free software; you can redistribute it and/or @@ -68,16 +70,12 @@ if ($form_alerttype != "combined"){ } echo ''; echo lang_string ("Priority"); -echo ''; + if (isset($alert_priority)){ - echo ""; -} else { - $alert_priority = 0; -} -for ($i=0; $i<5; $i++){ - if ($i != $alert_priority) - echo ""; + $alert_priority = 3; // Warning by default } +echo form_priority ($alert_priority, "alert_priority"); // Alert type echo '
'; @@ -195,7 +193,7 @@ echo 'Macros:
_agent_
_timestamp_
_data_
'; //Field3 echo '
'.lang_string ("field3"); echo ''; -echo 'Macros:
_agent_
'; echo '_timestamp_
_data_
'; @@ -213,6 +211,7 @@ for ($a=0; $a < 48; $a++){ echo "'>"; echo render_time ($a); } +echo "
".$lang_label["time_to"]; @@ -227,6 +226,7 @@ for ($a=0; $a < 48; $a++){ echo "'>"; echo render_time ($a); } +echo "
"; diff --git a/pandora_console/godmode/alerts/modify_alert.php b/pandora_console/godmode/alerts/modify_alert.php index 4a3ed4272c..b86198bfc1 100644 --- a/pandora_console/godmode/alerts/modify_alert.php +++ b/pandora_console/godmode/alerts/modify_alert.php @@ -11,6 +11,10 @@ require("include/config.php"); if ( (give_acl($id_user, 0, "LM")==1)){ if (isset($_POST["update_alerta"])){ // if modified any parameter $id_alerta = entrada_limpia($_POST["id_alerta"]); + if ($id_alerta < 4){ + audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Alert Management"); + require ("general/noaccess.php"); + } $nombre = entrada_limpia($_POST["nombre"]); $comando = entrada_limpia($_POST["comando"]); $descripcion= entrada_limpia($_POST["descripcion"]); @@ -37,6 +41,10 @@ if ( (give_acl($id_user, 0, "LM")==1)){ if (isset($_GET["borrar_alerta"])){ // if delete alert $id_alerta = entrada_limpia($_GET["borrar_alerta"]); + if ($id_alerta < 4){ + audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Alert Management"); + require ("general/noaccess.php"); + } $sql_delete= "DELETE FROM talerta WHERE id_alerta = ".$id_alerta; $result=mysql_query($sql_delete); if (! $result) @@ -55,7 +63,7 @@ if ( (give_acl($id_user, 0, "LM")==1)){ echo "".$lang_label["description"].""; echo "".$lang_label["delete"].""; $color=1; - $sql1='SELECT * FROM talerta ORDER BY nombre'; + $sql1='SELECT * FROM talerta'; $result=mysql_query($sql1); while ($row=mysql_fetch_array($result)){ if ($color == 1){ @@ -66,7 +74,7 @@ if ( (give_acl($id_user, 0, "LM")==1)){ $tdcolor = "datos2"; $color = 1; } - if ($row[0] > 3){ + if ($row[0] > 4){ echo "".$row["nombre"].""; echo "".$row["descripcion"].""; echo ""; diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 374d86389d..b4a7d71a91 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -2,7 +2,7 @@ // Pandora FMS - the Free monitoring system // ======================================== -// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com +// Copyright (c) 2004-2008 Sancho Lerena, slerena@gmail.com // Main PHP/SQL code development and project architecture and management // Copyright (c) 2004-2007 Raul Mateos Martin, raulofpandora@gmail.com // CSS and some PHP additions @@ -46,16 +46,20 @@ if (comprueba_login() == 0){ else echo ""; - if (isset($_GET["sec2"]) && ($_GET["sec2"] == "godmode/groups/group_list" || $_GET["sec2"] == "godmode/groups/configure_group")){ - echo "
"; - } - else - echo ""; - } - } - if ((give_acl($id_user, 0, "AW")==1)){ + // Manage groups + if ((give_acl($id_user, 0, "PM")==1)){ + if (isset($_GET["sec2"]) && ($_GET["sec2"] == "godmode/groups/group_list" || $_GET["sec2"] == "godmode/groups/configure_group")){ + echo "
"; + } + else + echo ""; + } + } + } + + if ((give_acl($id_user, 0, "PM")==1)){ if (isset($_GET["sec"]) && ($_GET["sec"] == "gmodules")) echo '
'; else @@ -113,7 +117,7 @@ if (comprueba_login() == 0){ } // Reporting // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if ((give_acl($id_user, 0, "AW")==1)){ + if ((give_acl($id_user, 0, "PM")==1)){ echo '
'; diff --git a/pandora_console/include/config.php b/pandora_console/include/config.php index 576b88f17f..7d6e962565 100644 --- a/pandora_console/include/config.php +++ b/pandora_console/include/config.php @@ -2,7 +2,7 @@ // Begin of automatic config file $config["dbname"]="pandora"; // MySQL DataBase name $config["dbuser"]="pandora"; // DB User -$config["dbpass"]="swfvnldt"; // DB Password +$config["dbpass"]="pandora"; // DB Password $config["dbhost"]="localhost"; // DB Host $config["homedir"]="/var/www/pandora_console/"; // Config homedir $config["homeurl"]="http://localhost/pandora_console"; // Base URL @@ -42,17 +42,7 @@ $config["homeurl"]="http://localhost/pandora_console"; // Base URL // Display ALL errors error_reporting(E_ALL); -// This is directory where placed "/attachment" directory, to upload files stores. -// This MUST be writtable by http server user, and should be in pandora root. -// By default, Pandora adds /attachment to this, so by default is the pandora console home dir -$config["attachment_store"]=$config["homedir"]; - -// Default font used for graphics (a Free TrueType font included with Pandora FMS) -$config["fontpath"] = $config["homedir"]."/reporting/FreeSans.ttf"; - -// Style (pandora by default) -$config["style"] = "pandora"; include ("config_process.php"); ?> diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 045678f755..ce1895aa40 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,6 +22,18 @@ if (!isset($build_version)) if (!isset($pandora_version)) $pandora_version="v2.0-dev"; +// This is directory where placed "/attachment" directory, to upload files stores. +// This MUST be writtable by http server user, and should be in pandora root. +// By default, Pandora adds /attachment to this, so by default is the pandora console home dir + +$config["attachment_store"]=$config["homedir"]; + +// Default font used for graphics (a Free TrueType font included with Pandora FMS) +$config["fontpath"] = $config["homedir"]."/reporting/FreeSans.ttf"; + +// Style (pandora by default) +$config["style"] = "pandora"; + // Read remaining config tokens from DB if (! mysql_connect($config["dbhost"],$config["dbuser"],$config["dbpass"])){ diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index d77745546d..a2fa849a85 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -600,23 +600,23 @@ function get_parameter_post ( $name, $default = "" ){ return $default; } -function get_alert_priority ( $prio ){ - $priority = "NORMAL"; +function get_alert_priority ( $prio = 0){ + global $config; switch ($prio){ case 0: - $priority = "NORMAL"; + $priority = lang_string("Maintenance"); break; case 1: - $priority = "WARNING"; + $priority = lang_string("Informational"); break; case 2: - $priority = "MINOR"; + $priority = lang_string("Normal"); break; case 3: - $priority = "MAJOR"; + $priority = lang_string("Warning"); break; case 4: - $priority = "CRITICAL"; + $priority = lang_string("Critical"); break; } return $priority; @@ -903,4 +903,116 @@ function form_render_check ($name_form, $value_form = 1){ } +function form_event_type_combo ($name_form, $value_form = ""){ + echo ""; +} + + +function form_priority ($priority = 0, $form_name = "priority", $show_all = 0){ + global $config; + + echo '"; +} + + +function return_priority ($priority){ + global $config; + + switch ($priority) { + case 0: + return lang_string("Maintenance"); + case 1: + return lang_string("Informational"); + case 2: + return lang_string("Normal"); + case 3: + return lang_string("Warning"); + case 4: + return lang_string("Critical"); + case -1: + return lang_string("All"); + } +} + +// Show combo with agents +function form_agent_combo ($id_agent = 0, $form_name = "id_agent"){ + global $config; + echo '"; +} ?> diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 451aafb209..1423c4b2f2 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -756,15 +756,16 @@ function existe($id){ } // --------------------------------------------------------------- -// event_insert - Insert event in eventable, using Id_grupo, Id_agente and Evento +// event_insert - Insert generic event in eventable // --------------------------------------------------------------- -function event_insert($evento, $id_grupo, $id_agente, $status=0, $id_usuario=''){ +function event_insert($evento, $id_grupo, $id_agente, $status=0, $id_usuario='', $event_type = "unknown", $priority = 0, $id_agent_module, $id_aam){ require("config.php"); $today=date('Y-m-d H:i:s'); $utimestamp = time(); - - $sql1='INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, estado, utimestamp, id_usuario) VALUES ('.$id_agente.','.$id_grupo.',"'.$evento.'","'.$today.'",'.$status.', '.$utimestamp.', "'.$id_usuario.'")'; + + $sql1='INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, estado, utimestamp, id_usuario, event_type, criticity, id_agentmodule, id_alert_am) VALUES ('.$id_agente.','.$id_grupo.',"'.$evento.'","'.$today.'",'.$status.', '.$utimestamp.', "'.$id_usuario.'", "'.$event_type.'", '.$priority.', '.$id_agent_module.', '.$id_aam.')'; + $result=mysql_query($sql1); } @@ -1453,4 +1454,115 @@ function show_alert_row_mini ($id_combined_alert){ } echo ""; } +function smal_event_table ($filter = "", $limit = 10, $width=440){ + global $config; + global $lang_label; + + $sql2 = "SELECT * FROM tevento $filter ORDER BY timestamp DESC LIMIT $limit"; + echo ""; + echo ""; + echo ""; + echo "
".lang_string("Latest events"); + echo "
".lang_string ("St").""; + echo "".lang_string ("Type").""; + echo "".$lang_label["event_name"].""; + echo "".$lang_label["agent_name"].""; + echo "".$lang_label["id_user"].""; + echo "".$lang_label["timestamp"].""; + $result2=mysql_query($sql2); + while ($row2=mysql_fetch_array($result2)){ + $id_grupo = $row2["id_grupo"]; + if (give_acl($config["id_user"], $id_grupo, "AR") == 1){ // Only incident read access to view data ! + switch ($row2["criticity"]) { + case 0: + $tdclass = "datos_blue"; + break; + case 1: + $tdclass = "datos_grey"; + break; + case 2: + $tdclass = "datos_green"; + break; + case 3: + $tdclass = "datos_yellow"; + break; + case 4: + $tdclass = "datos_red"; + break; + default: + $tdclass = "datos_grey"; + } + $criticity_label = return_priority ($row2["criticity"]); + // Colored box + echo "
"; + if ($row2["estado"] == 0) + echo ""; + else + echo ""; + + // Event type + echo ""; + switch ($row2["event_type"]){ + case "unknown": + echo ""; + break; + case "alert_recovered": + echo ""; + break; + case "alert_manual_validation": + echo ""; + break; + case "monitor_up": + echo ""; + break; + case "monitor_down": + echo ""; + break; + case "alert_fired": + echo ""; + break; + case "system"; + echo ""; + break; + case "recon_host_detected"; + echo ""; + break; + } + + // Event description + echo ""; + echo substr($row2["evento"],0,45); + if (strlen($row2["evento"]) > 45) + echo ".."; + if ($row2["id_agente"] > 0){ + // Agent name + $agent_name = dame_nombre_agente($row2["id_agente"]); + echo ""; + echo substr($agent_name, 0, 14); + if (strlen($agent_name) > 14) + echo ".."; + echo ""; + + // for System or SNMP generated alerts + } else { + if ($row2["event_type"] == "system"){ + echo "".lang_string("System"); + } else { + echo "".$lang_label["alert"]."SNMP"; + } + } + + // User who validated event + echo ""; + if ($row2["estado"] <> 0) + echo "".substr($row2["id_usuario"],0,8)." ".dame_nombre_real($row2["id_usuario"]).""; + + // Timestamp + echo ""; + echo human_time_comparation($row2["timestamp"]); + + } + } + echo "
"; +} ?> diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index e673ed0cc8..9ca8d806b6 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -204,6 +204,7 @@ div#main { margin-left: 0px; margin-right: 0px; } + div#menu { width: 155px; float: left; @@ -646,3 +647,42 @@ span#logo_text2 { .bt0 { border-top: 0px; } + + +td.datos_green, td.datos_greenf9 { + background-color: #C7EAD5; + padding: 5px 5px 5px 5px; +} + +td.datos_red, td.datos_redf9 { + background-color: #FFC0B5; + padding: 5px 5px 5px 5px; +} + +td.datos_yellow, td.datos_yellowf9 { + background-color: #F4FFBF; + padding: 5px 5px 5px 5px; +} + +td.datos_blue, td.datos_bluef9 { + background-color: #CDE2EA; + padding: 5px 5px 5px 5px; +} + +td.datos_grey, td.datos_greyf9 { + background-color: #DCDCDC; + padding: 5px 5px 5px 5px; +} + +td.datos_greyf9, td.datos_bluef9, td.datos_greenf9, td.datos_redf9, td.datos_yellowf9 { + font-size: 6.5pt; +} + +div#main_pure { + background-color: #fefefe; + text-align: left; + margin-bottom: 25px; + margin-top: 10px; + margin-left: 10px; + margin-right: 10px; +} diff --git a/pandora_console/include/styles/pandora_red.css b/pandora_console/include/styles/pandora_red.css index f4ef4e8ede..d6fd37cd3c 100644 --- a/pandora_console/include/styles/pandora_red.css +++ b/pandora_console/include/styles/pandora_red.css @@ -581,3 +581,43 @@ span#logo_text2 { letter-spacing: -2px; color: #aaa; } + + + +td.datos_green, td.datos_greenf9 { + background-color: #C7EAD5; + padding: 5px 5px 5px 5px; +} + +td.datos_red, td.datos_redf9 { + background-color: #FFC0B5; + padding: 5px 5px 5px 5px; +} + +td.datos_yellow, td.datos_yellowf9 { + background-color: #F4FFBF; + padding: 5px 5px 5px 5px; +} + +td.datos_blue, td.datos_bluef9 { + background-color: #CDE2EA; + padding: 5px 5px 5px 5px; +} + +td.datos_grey, td.datos_greyf9 { + background-color: #DCDCDC; + padding: 5px 5px 5px 5px; +} + +td.datos_greyf9, td.datos_bluef9, td.datos_greenf9, td.datos_redf9, td.datos_yellowf9 { + font-size: 6.5pt; +} + +div#main_pure { + background-color: #fefefe; + text-align: left; + margin-bottom: 25px; + margin-top: 10px; + margin-left: 10px; + margin-right: 10px; +} diff --git a/pandora_console/index.php b/pandora_console/index.php index ad55a8a54a..77302b7b47 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -70,12 +70,11 @@ require "include/functions_db.php"; 0){ // Agent selection filters and refresh $query = 'http' . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == TRUE ? 's': '') . '://' . $_SERVER['SERVER_NAME']; @@ -94,7 +93,7 @@ if ( (isset ($_GET["refr"])) || (isset($_POST["refr"])) ){ } else echo ''; } -} + ?> Pandora FMS - <?php echo lang_string("header_title"); ?> @@ -117,7 +116,11 @@ if ( (isset ($_GET["refr"])) || (isset($_POST["refr"])) ){ '; + if ($config["pure"] == 0) + echo ''; + else + echo ''; + $REMOTE_ADDR = getenv ("REMOTE_ADDR"); // Login process @@ -176,6 +179,8 @@ if ( (isset ($_GET["refr"])) || (isset($_POST["refr"])) ){ } else { // There is session for id_usuario $config["id_user"] = $_SESSION["id_usuario"]; + //$id_usuario = entrada_limpia ($_SESSION["id_usuario"]); + //$id_user = entrada_limpia ($_SESSION["id_usuario"]); } // Log off @@ -202,35 +207,51 @@ if ( (isset ($_GET["refr"])) || (isset($_POST["refr"])) ){ // http://es2.php.net/manual/en/ref.session.php#64525 // Session locking concurrency speedup! session_write_close(); -?> -
- -
- -
- Sorry! I can't find the page!"; - } - } else - require ("general/logon_ok.php"); //default - ?> -
-
-
- -
+ // Header + if ($config["pure"] == 0){ + echo '
'; + echo ''; + echo '
'; + echo ' '; + } else { + echo '
'; + } + + // Main block of content + if ($config["pure"] == 0){ + echo '
'; + } - - + // Page loader / selector + if ($pagina != ""){ + if (file_exists ($pagina . ".php")) { + require ($pagina . ".php"); + } else { + echo "
".lang_string("Sorry! I can't find the page!").""; + } + } else + require ("general/logon_ok.php"); //default + + if ($config["pure"] == 0){ + echo '
'; // main + echo '
'; + echo '
'; // page + } else { + echo "
"; + } + + if ($config["pure"] == 0){ + echo ''; + echo '
'; + } + + echo ''; + +?> \ No newline at end of file diff --git a/pandora_console/operation/agentes/estado_agente.php b/pandora_console/operation/agentes/estado_agente.php index 4e7a178ab7..2f0eb78534 100644 --- a/pandora_console/operation/agentes/estado_agente.php +++ b/pandora_console/operation/agentes/estado_agente.php @@ -101,7 +101,7 @@ if (comprueba_login() == 0) { } else { // Is admin user ?? if (get_db_sql ("SELECT * FROM tusuario WHERE id_usuario ='$id_user'", "nivel") == 1){ - $sql="SELECT * FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo LIMIT $offset, $block_size"; + $sql="SELECT * FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo LIMIT $offset, ".$config["block_size"]; $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo"; // standard user diff --git a/pandora_console/operation/agentes/estado_alertas.php b/pandora_console/operation/agentes/estado_alertas.php index bd51b4a427..e5f255025a 100644 --- a/pandora_console/operation/agentes/estado_alertas.php +++ b/pandora_console/operation/agentes/estado_alertas.php @@ -1,6 +1,7 @@ ".$lang_label["no_alerts"]."
"; } +// Show alert for no defined agent } else { // ------------------------------- // SHOW ALL ALERTS (GENERAL PAGE) @@ -119,33 +120,26 @@ if (isset($_GET["id_agente"])){ echo "

".$lang_label["ag_title"]." > "; echo $lang_label["alert_listing"]."

"; $iduser_temp=$_SESSION['id_usuario']; - if (isset($_POST["ag_group"])) - $ag_group = $_POST["ag_group"]; - elseif (isset($_GET["group_id"])) - $ag_group = $_GET["group_id"]; - else - $ag_group = -1; - if (isset($_GET["ag_group_refresh"])){ - $ag_group = $_GET["ag_group_refresh"]; - } - if (isset($_POST["ag_group"])){ - $ag_group = $_POST["ag_group"]; - echo "
"; - } else { + $ag_group = get_parameter ("ag_group", -1); + + if ($ag_group != -1) + echo ""; + else echo ""; - } - echo ""; + + echo "
"; + echo ""; echo ""; echo ""; echo ""; - $string=$string.""; - if ($data["last_fired"] == "0000-00-00 00:00:00") { - $string=$string.""; - } else { - $string=$string.""; - - } - $string=$string.""; - } - } - else if($ag_group>1) { - unset($string); - } //end result - } //end disabled=0 - } //end while + $sql = "SELECT id_agente, nombre, disabled FROM tagente WHERE tagente.disabled = 0 "; + // Agent group selector + if ($ag_group > 1) + $sql .=" AND tagente.id_grupo = ".$ag_group; + else { + // User has explicit permission on group 1 ? + $all_group = get_db_sql ("SELECT COUNT(id_grupo) FROM tusuario_perfil WHERE id_usuario='".$config["id_user"]."' AND id_grupo = 1"); + if ($all_group == 0) + $sql .=" AND tagente.id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='".$config["id_user"]."')"; } + $color=1; $string = ''; + $result=mysql_query($sql); + if ($result) + while ($row=mysql_fetch_array($result)){ //while there are agents + $id_agente = $row['id_agente']; + $nombre_agente = strtoupper($row["nombre"]); + $query_gen='SELECT talerta_agente_modulo.id_alerta, + talerta_agente_modulo.descripcion, + talerta_agente_modulo.last_fired, + talerta_agente_modulo.times_fired, + talerta_agente_modulo.id_agente_modulo, + tagente_modulo.id_agente_modulo + FROM tagente_modulo, talerta_agente_modulo + WHERE tagente_modulo.id_agente = '.$id_agente.' + AND tagente_modulo.id_agente_modulo = talerta_agente_modulo.id_agente_modulo + AND talerta_agente_modulo.disable = 0 '; + $result_gen=mysql_query($query_gen); + while ($data=mysql_fetch_array($result_gen)){ + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + $string .= ""; + $string=$string.""; + if ($data["last_fired"] == "0000-00-00 00:00:00") { + $string=$string.""; + } else { + $string=$string.""; + } + $string=$string.""; + } + } //end while + // Display combined alerts // ======================= + $sql = "SELECT id_agente, nombre, disabled FROM tagente WHERE tagente.disabled = 0 "; + // Agent group selector if ($ag_group > 1) - $sql='SELECT id_agente, nombre, disabled FROM tagente WHERE id_grupo='.$ag_group.' ORDER BY nombre'; - else - $sql='SELECT id_agente, nombre, disabled FROM tagente ORDER BY id_grupo, nombre'; + $sql .=" AND tagente.id_grupo = ".$ag_group; + else { + // User has explicit permission on group 1 ? + $all_group = get_db_sql ("SELECT COUNT(id_grupo) FROM tusuario_perfil WHERE id_usuario='".$config["id_user"]."' AND id_grupo = 1"); + if ($all_group == 0) + $sql .=" AND tagente.id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='".$config["id_user"]."')"; + } + $result=mysql_query($sql); - - if (mysql_num_rows($result)){ - $color=1; - while ($row=mysql_fetch_array($result)){ //while there are agents - if ($row["disabled"] == 0) { - $id_agente = $row['id_agente']; - $nombre_agente = strtoupper($row["nombre"]); - $query_gen='SELECT talerta_agente_modulo.id_alerta, - talerta_agente_modulo.descripcion, - talerta_agente_modulo.last_fired, - talerta_agente_modulo.times_fired, - talerta_agente_modulo.id_agent - FROM talerta_agente_modulo - WHERE talerta_agente_modulo.id_agent = '.$id_agente.' AND talerta_agente_modulo.disable = 0 '; - $result_gen=mysql_query($query_gen); - if (mysql_num_rows ($result_gen)) { - while ($data=mysql_fetch_array($result_gen)){ - if ($color == 1){ - $tdcolor = "datos"; - $color = 0; - } - else { - $tdcolor = "datos2"; - $color = 1; - } - if (!isset($string)) { - $string=''; - } - $string = $string.""; - $string=$string.""; - if ($data["last_fired"] == "0000-00-00 00:00:00") { - $string=$string.""; - } else { - $string=$string.""; - - - } - $string=$string.""; - } + $color=1; + if ($result) + while ($row=mysql_fetch_array($result)){ //while there are agents + $id_agente = $row['id_agente']; + $nombre_agente = strtoupper($row["nombre"]); + $query_gen='SELECT talerta_agente_modulo.id_alerta, + talerta_agente_modulo.descripcion, + talerta_agente_modulo.last_fired, + talerta_agente_modulo.times_fired, + talerta_agente_modulo.id_agent + FROM talerta_agente_modulo + WHERE talerta_agente_modulo.id_agent = '.$id_agente.' AND talerta_agente_modulo.disable = 0 '; + $result_gen=mysql_query($query_gen); + if (mysql_num_rows ($result_gen)) { + while ($data=mysql_fetch_array($result_gen)){ + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; } - else if($ag_group>1) { - unset($string); - } //end result - } //end disabled=0 - } //end while - } // if rows.. + else { + $tdcolor = "datos2"; + $color = 1; + } + if (!isset($string)) { + $string=''; + } + $string = $string.""; + $string=$string.""; + if ($data["last_fired"] == "0000-00-00 00:00:00") { + $string=$string.""; + } else { + $string=$string.""; - if (isset($string)) { + + } + $string=$string.""; + } + } + } //end while + + if ($string != "") { echo ""; echo ""; - echo $string; //built table of alerts echo "
".$lang_label["group"].""; - echo ""; if ( $ag_group > 1 ){ echo ""; } echo ""; - list_group ($id_user); + list_group ($config["id_user"]); echo "
- - ".$nombre_agente.""; - $string .= ""; - if ($data["times_fired"] <> 0) - $string .= ""; - else - $string .= ""; - - $string = $string."" - .dame_nombre_alerta($data["id_alerta"])."". - $data["descripcion"]."". - $lang_label["never"]."". - human_time_comparation($data["last_fired"])."". - $data["times_fired"]."
+ + ".$nombre_agente.""; + $string .= ""; + if ($data["times_fired"] <> 0) + $string .= ""; + else + $string .= ""; + + $string = $string."" + .dame_nombre_alerta($data["id_alerta"])."". + $data["descripcion"]."". + $lang_label["never"]."". + human_time_comparation($data["last_fired"])."". + $data["times_fired"]."
- - ".$nombre_agente." (*)"; - $string .= ""; - if ($data["times_fired"] <> 0) - $string .= ""; - else - $string .= ""; - - $string = $string."" - .dame_nombre_alerta($data["id_alerta"])."". - $data["descripcion"]."". - $lang_label["never"]."". - human_time_comparation($data["last_fired"])."". - $data["times_fired"]."
+ + ".$nombre_agente." (*)"; + $string .= ""; + if ($data["times_fired"] <> 0) + $string .= ""; + else + $string .= ""; + + $string = $string."" + .dame_nombre_alerta($data["id_alerta"])."". + $data["descripcion"]."". + $lang_label["never"]."". + human_time_comparation($data["last_fired"])."". + $data["times_fired"].""; echo " ".$lang_label["fired"].""; @@ -309,7 +302,6 @@ if (isset($_GET["id_agente"])){ ".$lang_label["description"]." ".$lang_label["last_fired"]." ".$lang_label["times_fired"]."
"; } diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 93f2e6aacf..3bd099d7d3 100644 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -34,6 +34,7 @@ if (comprueba_login() == 0) { $comentarios = $row["comentarios"]; $id_grupo = $row["id_grupo"]; $id_os= $row["id_os"]; + $id_parent= $row["id_parent"]; $os_version = $row["os_version"]; $agent_version = $row["agent_version"]; $disabled= $row["disabled"]; @@ -42,7 +43,7 @@ if (comprueba_login() == 0) { echo "

".$lang_label["agent_error"]."

"; echo ""; echo "
"; exit; } @@ -102,28 +103,40 @@ if (comprueba_login() == 0) { }*/ echo ''; echo ''; - echo ' - '.$lang_label["interval"].' - '. human_time_description_raw($intervalo).''; - echo ''; - echo ' - '.$lang_label["description"].' - '.$comentarios.''; + + // Parent + echo ' + '.lang_string("Parent").' + '; + echo ""; + echo dame_nombre_agente($id_parent).''; + // Agent Interval + echo ' + '.$lang_label["interval"].' + '. human_time_description_raw($intervalo).''; + echo ''; + + // Comments + echo ' + '.$lang_label["description"].' + '.$comentarios.''; echo ''; + + // Group echo ' - '.$lang_label["group"].' - + '.$lang_label["group"].' +    '.dame_grupo($id_grupo).''; // Agent version - echo ''.lang_string ("agentversion"). ''; - echo ''.salida_limpia($agent_version). ''; + echo ''.lang_string ("agentversion"). ''; + echo ''.salida_limpia($agent_version). ''; // Total packets echo ' - '. lang_string ("total_packets"). ''; - echo ''; + '. lang_string ("total_packets"). ''; + echo ''; $total_paketes= 0; $sql_3='SELECT COUNT(*) FROM tagente_datos WHERE id_agente = '.$id_agente; $result_3=mysql_query($sql_3); @@ -134,10 +147,10 @@ if (comprueba_login() == 0) { // Last contact echo ' - + '.$lang_label["last_contact"]." / ".$lang_label["remote"].' - '; + '; if ($ultima_act == "0000-00-00 00:00:00"){ echo $lang_label["never"]; } else { @@ -150,17 +163,6 @@ if (comprueba_login() == 0) { echo $ultima_act_remota; } -/* - // Asigned/active server - echo ''.$lang_label["server_asigned"].' - '; - if ($server == ""){ - echo "N/A"; - } else { - echo give_server_name($server); - } -*/ - // Next contact $ultima = strtotime($ultima_act); @@ -196,8 +198,8 @@ if (comprueba_login() == 0) {
- ".$lang_label["agent_module_shareout"]."

- + ".lang_string("Events generated -by module-")."

+ diff --git a/pandora_console/operation/agentes/estado_grupo.php b/pandora_console/operation/agentes/estado_grupo.php index 62672b7127..cad328eb26 100644 --- a/pandora_console/operation/agentes/estado_grupo.php +++ b/pandora_console/operation/agentes/estado_grupo.php @@ -162,25 +162,25 @@ ".$lang_label["disabled"].""; // By default green border - $celda = ""; + $celda = ""; // Grey border if agent down if ($config["show_unknown"] > 0){ if ($grupo[$real_count]["down"] > 0) - $celda = ""; + $celda = ""; } // Yellow border if agents with alerts if ($grupo[$real_count]["alerts"] > 0) - $celda = ""; + $celda = ""; // Red border if agents bad if ($grupo[$real_count]["bad"] > 0) - $celda = ""; + $celda = ""; // Orange if alerts and down modules if (($grupo[$real_count]["bad"] > 0) && ($grupo[$real_count]["alerts"] > 0)) - $celda = ""; + $celda = ""; $celda .= ""; + +// Summary + + echo "".lang_string("Monitor health").""; + echo ""; + echo "".lang_string("Data health").""; + echo ""; + echo "".lang_string("Global health").""; + echo ""; + echo "".lang_string("Module sanity").""; + echo ""; + echo "".lang_string("Alert level").""; + echo ""; + + + echo ""; echo "".$lang_label["monitor_checks"].""; echo ""."Monitor checks".""; echo "".$monitor_checks.""; @@ -64,7 +101,7 @@ echo "-"; echo ""."Monitor Not Init".""; - echo ""; + echo ""; if ($monitor_not_init> 0) echo $monitor_not_init; else @@ -78,12 +115,12 @@ echo "-"; echo ""."Alerts Total".""; echo "".$monitor_alert_total; - echo ""; + // Data checks // ~~~~~~~~~~~~~~~ - echo ""; - echo ""; + + echo ""; echo ""; echo ""; @@ -93,7 +130,7 @@ else echo "-"; echo ""; - echo "
".$lang_label["data_checks"]."
".$lang_label["data_checks"]."
"."Data checks"."".$data_checks; echo "
"."Data Unknown"."
"."Data not init".""; + echo ""; if ($data_not_init > 0) echo $data_not_init; else @@ -106,55 +143,45 @@ echo "-"; echo "
"."Alerts Total"; echo "".$data_alert_total; - echo "
"; + // Summary // ~~~~~~~~~~~~~~~ - echo ""; - echo ""; + + echo ""; echo ""; echo ""; echo ""; + echo "
".$lang_label["summary"]."
".$lang_label["summary"]."
"."Total agents"."".$total_agents; echo "
"."Total checks"."".$total_checks; + + echo "
"."Server sanity".""; echo ""; - // Odometer Graph - // ~~~~~~~~~~~~~~~ - if ($monitor_checks > 0){ - $monitor_health = format_numeric ((($monitor_ok - $monitor_alert - $monitor_unknown)/ $monitor_checks) * 100,1); - } else - $monitor_health = 100; - if ($data_checks > 0){ - $data_health = format_numeric ( (($data_checks -($data_unknown + $data_alert)) / $data_checks ) * 100,1);; - } else - $data_health = 100; - if (($data_checks != 0) OR ($data_checks != 0)){ - $global_health = format_numeric( ((($monitor_ok -$monitor_alert - $monitor_unknown )+($data_checks -($data_unknown + $data_alert))) / ($data_checks + $monitor_checks) ) * 100, 1); - } else - $global_health = 100; - - echo "

".$lang_label["tactical_indicator"]."

"; - echo ""; - // Server information // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // Get total modules defined (network) - $total_modules_network = get_db_sql ("SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo > 4 AND id_tipo_modulo != 100"); - // Get total modules defined (data) - $total_modules_data = get_db_sql ("SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo < 5 OR id_tipo_modulo = 100"); - echo "

".$lang_label["tactical_server_information"]."

"; + // Get total modules defined (network) + $total_modules_network = get_db_sql ("SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo > 4 AND id_tipo_modulo < 19 AND id_tipo_modulo != 100"); + + // Get total modules defined (data) + $total_modules_data = get_db_sql ("SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo < 5 OR id_tipo_modulo = 100"); // Connect DataBase - $sql='SELECT * FROM tserver'; + $sql='SELECT * FROM tserver'; $result=mysql_query($sql); if (mysql_num_rows($result)){ - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo "
".$lang_label["name"]."".$lang_label['status']."".$lang_label['load']."".$lang_label['modules']."".$lang_label['lag']."
"; + echo "
"; + echo lang_string("tactical_server_information"); + echo "
".$lang_label["name"].""; + echo "".$lang_label['status'].""; + echo "".$lang_label['load'].""; + echo "".$lang_label['modules'].""; + echo "".$lang_label['lag'].""; $color=1; while ($row=mysql_fetch_array($result)){ if ($color == 1){ @@ -190,14 +217,15 @@ echo "$name"; echo ""; if ($status ==0){ - echo ""; + echo ""; } else { - echo ""; + echo ""; } echo ""; if (($network_server == 1) OR ($data_server == 1)){ // Progress bar calculations if ($network_server == 1){ + $total_modules_network_LAG = get_db_sql ("SELECT COUNT( tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo, tagente_estado WHERE id_network_server = $id_server AND tagente_modulo.id_agente = tagente.id_agente AND tagente.disabled = 0 AND tagente_modulo.id_tipo_modulo > 4 AND tagente_modulo.id_tipo_modulo < 19 AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND (((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP()) OR tagente_modulo.flag = 1 );"); if ($modules_server == 0) $percentil = 0; if ($modules_server > 0) @@ -206,6 +234,7 @@ $percentil = 0; $total_modules_temp = $total_modules_network; } else { + $total_modules_network_LAG = get_db_sql ("SELECT COUNT( tagente_modulo.id_agente_modulo) FROM tagente, tagente_modulo, tagente_estado WHERE tagente_estado.running_by = $id_server AND tagente_modulo.id_agente = tagente.id_agente AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND (((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP()) OR tagente_modulo.flag = 1 );"); if ($total_modules_data == 0) $percentil = 0; else @@ -245,6 +274,7 @@ echo $modules_server . " / ". $total_modules_temp; else echo "-"; + // LAG CHECK echo ""; @@ -252,7 +282,7 @@ // and calculate difference in seconds // Get total modules defined for this server if (($network_server == 1) OR ($data_server == 1)){ - if ($network_server == 1) + if ($network_server == 1) $sql1 = "SELECT MIN(last_execution_try),current_interval FROM tagente_estado WHERE last_execution_try > 0 AND running_by=$id_server GROUP BY current_interval ORDER BY 1"; if ($data_server == 1) // This only checks for agent with a last_execution_try of at @@ -265,12 +295,12 @@ while ($row1=mysql_fetch_array($result1)){ if (($row1[0] + $row1[1]) < $nowtime){ $maxlag2 = $nowtime - ($row1[0] + $row1[1]); - // More than 5 times module interval is not lag, is a big - // problem in agent, network or servers.. - if ($maxlag2 < ($row1[1]*5)) - if ($maxlag2 > $maxlag) - $maxlag = $maxlag2; - } + // More than 5 times module interval is not lag, is a big + // problem in agent, network or servers.. + if ($maxlag2 < ($row1[1]*5)) + if ($maxlag2 > $maxlag) + $maxlag = $maxlag2; + } } if ($maxlag < 60) echo $maxlag." sec"; @@ -278,6 +308,7 @@ echo format_numeric($maxlag/60) . " min"; elseif ($maxlag > 86400) echo "+1 ".$lang_label["day"]; + echo " - ".$total_modules_network_LAG ." ".lang_string("modules"); } elseif ($recon_server == 1) { $sql1 = "SELECT * FROM trecon_task WHERE id_network_server = $id_server"; $result1=mysql_query($sql1); @@ -302,6 +333,10 @@ } } echo '
'; + + // Event information + smal_event_table ("", 10, 440); + } echo "
"; diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index f49401e0b8..db828a807e 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -19,22 +19,26 @@ require("include/config.php"); if (comprueba_login() == 0) { - $id_agente = give_parameter_get_numeric("id_agente"); + $id_agente = get_parameter("id_agente",-1); if ($id_agente != -1){ // get group for this id_agente $query="SELECT * FROM tagente WHERE id_agente = ".$id_agente; $res=mysql_query($query); $row=mysql_fetch_array($res); $id_grupo = $row["id_grupo"]; - $id_usuario=$_SESSION["id_usuario"]; + $id_usuario=$config["id_user"]; if (give_acl($id_usuario, $id_grupo, "AR")==1){ // Check for validate alert request $validate_alert = give_parameter_get ("validate_alert"); if ($validate_alert != ""){ if (give_acl($id_usuario, $id_grupo, "AW")==1){ - $alert_name = get_db_value ("descripcion", "talerta_agente_modulo", "id_aam", $validate_alert); - event_insert ("Manual validation of alert for '$alert_name'", $id_grupo, $id_agente, 1, $id_usuario); + $alert_row = get_db_row ("talerta_agente_modulo", "id_aam", $validate_alert); + $am_row = get_db_row ("tagente_modulo", "id_agente_modulo", $alert_row["id_agente_modulo"]); + $ag_row = get_db_row ("tagente", "id_agente", $am_row["id_agente"]); + $alert_name = $alert_row["descripcion"]; + + event_insert("Manual validation of alert for '$alert_name'", $ag_row["id_grupo"], $am_row["id_agente"], 1, $id_usuario, "alert_manual_validation", 1, $alert_row["id_agente_modulo"], $validate_alert); $sql='UPDATE talerta_agente_modulo SET times_fired = 0, internal_counter = 0 WHERE id_aam = '.$validate_alert; $result=mysql_query($sql); } @@ -116,6 +120,7 @@ if (comprueba_login() == 0) { require "estado_generalagente.php"; require "estado_monitores.php"; require "estado_alertas.php"; + require "status_events.php"; break; case "data": diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 8a7037bc95..52dfc1b4c6 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -27,6 +27,7 @@ e.checked = 1; } } + function OpConfirm(text, conf) { for (var i=0;i @@ -55,8 +65,8 @@ if (comprueba_login() != 0) { } $accion = ""; -if (give_acl($id_user, 0, "AR")!=1) { - audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access event viewer"); +if (give_acl($config["id_user"], 0, "AR")!=1) { + audit_db($config["id_user"],$REMOTE_ADDR, "ACL Violation","Trying to access event viewer"); no_permission(); } @@ -84,12 +94,12 @@ if (isset($_GET["check"])){ $id_evento = $_GET["check"]; // Look for event_id following parameters: id_group. $id_group = gime_idgroup_from_idevent($id_evento); - if (give_acl($id_user, $id_group, "IW") ==1){ - $sql2="UPDATE tevento SET estado = 1, id_usuario = '".$id_user."' WHERE id_evento = ".$id_evento; + if (give_acl($config["id_user"], $id_group, "IW") ==1){ + $sql2="UPDATE tevento SET estado = 1, id_usuario = '".$config["id_user"]."' WHERE id_evento = ".$id_evento; $result2=mysql_query($sql2); if ($result2) { echo "

".$lang_label["validate_event_ok"]."

"; - audit_db($id_user,$REMOTE_ADDR, "Event validated","Validate event: ".return_event_description ($id_evento)); + audit_db($config["id_user"],$REMOTE_ADDR, "Event validated","Validate event: ".return_event_description ($id_evento)); } else { echo "

".$lang_label["validate_event_failed"]."

"; } @@ -144,165 +154,269 @@ if (isset($_POST["updatebt"])){ // Get data -$offset=0; -if (isset($_GET["offset"])) - $offset=$_GET["offset"]; +$offset = get_parameter ( "offset",0); +$ev_group = get_parameter ("ev_group", 0); // group +$search = get_parameter ("search", ""); // free search +$event_type = get_parameter ("event_type", "all"); // 0 all +$severity = get_parameter ("severity", -1); // -1 all +$status = get_parameter ("status", 0); // -1 all, 0 only red, 1 only green +$id_agent = get_parameter ("id_agent", -1); -if (isset($_GET["group_id"])) - $group_id = entrada_limpia($_GET["group_id"]); - else - $group_id = 0; +$sql_post = ""; +if ($ev_group > 1) + $sql_post .= " AND id_grupo = $ev_group"; +if ($status == 1) + $sql_post .= " AND estado = 1"; +if ($status == 0) + $sql_post .= " AND estado = 0"; +if ($search != "") + $sql_post .= " AND evento LIKE '%$search%'"; +if ($event_type != "all") + $sql_post .= " AND event_type = '$event_type'"; +if ($severity != -1) + $sql_post .= " AND criticity >= $severity"; +if ($id_agent != -1) + $sql_post .= " AND id_agente = $id_agent"; +$url = "index.php?sec=eventos&sec2=operation/events/events&search=$search&event_type=$event_type&severity=$severity&status=$status&ev_group=$ev_group&refr=60&id_agent=$id_agent"; -if (isset($_POST["ev_group"])) - $ev_group = $_POST["ev_group"]; - elseif (isset($_GET["group_id"])) - $ev_group = $_GET["group_id"]; - else - $ev_group = -1; +echo "

".$lang_label["events"]." > ".lang_string ("event_main_view"). " "; +if ($config["pure"] == 1) + echo ""; +else + echo ""; +echo "

"; -$event="All"; -if (isset($_POST["event"])) - $event = entrada_limpia($_POST["event"]); +echo ""; +echo "".lang_string("Event control filter")." ".''; -echo "

".$lang_label["events"]." > ".$lang_label["event_main_view"]."

"; -echo ""; +if ($config["pure"] == 1) + echo "
"; +echo ""; +echo ""; +echo ""; + +// Free search +echo ""; +echo "
"; + +// Table for filter controls +echo ""; echo ""; -echo ""; -echo ""; +echo ""; + +// Group combo +echo ""; echo ""; +list_group ($config["id_user"]); +echo ""; -echo ""; -echo ""; +echo ""; -// Fill event type combo (DISTINCT!) -if (isset($ev_group) && ($ev_group > 1)) - $sql="SELECT DISTINCT evento FROM tevento WHERE id_grupo = '$ev_group'"; -else - $sql="SELECT DISTINCT evento FROM tevento"; -$result=mysql_query($sql); -// Make query for distinct (to fill combo) -while ($row=mysql_fetch_array($result)) - echo ""; -echo ""; -echo ""; -echo ""; +echo "
".$lang_label["group"]."".lang_string ("group").""; echo "
".$lang_label["events"].""; -echo "".lang_string ("Event type").""; +echo form_event_type_combo ("event_type", $event_type); +echo "
"; -echo ""; +// Severity +echo "".lang_string ("Severity").""; +echo form_priority ($severity, "severity", 1); -echo "
"; - -echo "
"; - -// How many events do I have in total ? -if ($event=="All"){ - if (isset($ev_group) && ($ev_group > 1)) { - $sql3="SELECT COUNT(id_evento) FROM tevento WHERE id_grupo = '$ev_group' "; - } else { - $sql3="SELECT COUNT(id_evento) FROM tevento"; - } -} else { - if (isset($ev_group) && ($ev_group > 1)) { - $sql3="SELECT COUNT(id_evento) FROM tevento WHERE evento = '$event' AND id_grupo = '$ev_group'"; - } else { - $sql3="SELECT COUNT(id_evento) FROM tevento WHERE evento = '$event' "; - } +// Status +echo "
".lang_string ("Event status").""; +echo "
".lang_string ("Free search").""; +echo ""; +echo ""; +echo ""; +echo "
"; +echo ""; +echo ""; +echo ''; +echo ""; +echo "
"; + +$sql2 = "SELECT * FROM tevento WHERE 1=1 "; +$sql2 .= $sql_post . " ORDER BY timestamp DESC LIMIT $offset, ".$config["block_size"]; +$sql3 = "SELECT COUNT(id_evento) FROM tevento WHERE 1=1 "; +$sql3 .= $sql_post; + $result3=mysql_query($sql3); $row3=mysql_fetch_array($result3); $total_events = $row3[0]; -// Show pagination header +// Show pagination header if ($total_events > 0){ - pagination ($total_events, "index.php?sec=eventos&sec2=operation/events/events&group_id=$ev_group&refr=60", $offset); + + $offset = get_parameter ( "offset",0); + pagination ($total_events, $url."&pure=".$config["pure"], $offset); // Show data. echo "
"; echo "
"; - echo ""; + if ($config["pure"] == 0) + echo "
"; + else + echo "
"; echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; echo "'; - echo ""; - $color = 1; + echo ""; $id_evento = 0; - // Prepare index for pagination. Prepare queries - if ($event=="All"){ - if (isset($ev_group) && ($ev_group > 1)) { - $sql2="SELECT * FROM tevento WHERE id_grupo = '$ev_group' ORDER BY timestamp DESC LIMIT $offset, ".$config["block_size"]; - } else { - $sql2="SELECT * FROM tevento ORDER BY timestamp DESC LIMIT $offset, ".$config["block_size"]; - } - } else { - if (isset($ev_group) && ($ev_group > 1)) { - $sql2="SELECT * FROM tevento WHERE evento = '$event' AND id_grupo = '$ev_group' ORDER BY timestamp DESC LIMIT $offset, ".$config["block_size"]; - } else { - $sql2="SELECT * FROM tevento WHERE evento = '$event' ORDER BY timestamp DESC LIMIT $offset, ".$config["block_size"]; - } - } - $offset_counter=0; // Make query for data (all data, not only distinct). $result2=mysql_query($sql2); while ($row2=mysql_fetch_array($result2)){ $id_grupo = $row2["id_grupo"]; - if (give_acl($id_user, $id_grupo, "IR") == 1){ // Only incident read access to view data ! + if (give_acl($config["id_user"], $id_grupo, "AR") == 1){ // Only incident read access to view data ! $id_group = $row2["id_grupo"]; - if ($color == 1){ - $tdcolor = "datos"; - $color = 0; - } - else { - $tdcolor = "datos2"; - $color = 1; - } - echo ""; - echo ""; + + // for System or SNMP generated alerts + } else { + if ($row2["event_type"] == "system"){ + echo ""; } @@ -312,7 +426,7 @@ if ($total_events > 0){ echo "
".$lang_label["status"]."".$lang_label["event_name"]."".$lang_label["agent_name"]."".$lang_label["group"]."".$lang_label["id_user"]."".$lang_label["timestamp"]."".$lang_label["action"]."".lang_string ("St")."".lang_string ("Type")."".$lang_label["event_name"]."".$lang_label["agent_name"]."".lang_string ("source")."".$lang_label["group"]."".$lang_label["id_user"]."".$lang_label["timestamp"]."".$lang_label["action"].""; echo ""; echo '
"; - if ($row2["estado"] == 0) - echo ""; - else - echo ""; - echo "".$row2["evento"]; - if ($row2["id_agente"] > 0){ - echo "".dame_nombre_agente($row2["id_agente"]).""; - echo ""; - } else { // for SNMP generated alerts - echo "".$lang_label["alert"]." / SNMP"; - echo ""; - echo ""; + switch ($row2["criticity"]) { + case 0: + $tdclass = "datos_blue"; + break; + case 1: + $tdclass = "datos_grey"; + break; + case 2: + $tdclass = "datos_green"; + break; + case 3: + $tdclass = "datos_yellow"; + break; + case 4: + $tdclass = "datos_red"; + break; + default: + $tdclass = "datos_grey"; + } + $criticity_label = return_priority ($row2["criticity"]); + // Colored box + echo "
"; + if ($row2["estado"] == 0) + echo ""; + else + echo ""; + + // Event type + echo ""; + switch ($row2["event_type"]){ + case "unknown": + echo ""; + break; + case "alert_recovered": + echo ""; + break; + case "alert_manual_validation": + echo ""; + break; + case "monitor_up": + echo ""; + break; + case "monitor_down": + echo ""; + break; + case "alert_fired": + echo ""; + break; + case "system"; + echo ""; + break; + case "recon_host_detected"; + echo ""; + break; + } + + // Event description + echo ""; + echo substr($row2["evento"],0,45); + if (strlen($row2["evento"]) > 45) + echo ".."; + if ($row2["id_agente"] > 0){ + // Agent name + $agent_name = dame_nombre_agente($row2["id_agente"]); + echo ""; + echo substr($agent_name, 0, 14); + if (strlen($agent_name) > 14) + echo ".."; + echo ""; + + // Module name / Alert + echo ""; + if ($row2["id_agentmodule"] != 0) + echo ""; + echo " "; + if ($row2["id_alert_am"] != 0) + echo ""; + + // Group icon + echo "".lang_string("System"); + } else { + echo "".$lang_label["alert"]."SNMP"; + } } + + // User who validated event + echo ""; if ($row2["estado"] <> 0) echo "".substr($row2["id_usuario"],0,8)." ".dame_nombre_real($row2["id_usuario"]).""; - echo "".$row2["timestamp"]; - echo ""; - - if (($row2["estado"] == 0) and (give_acl($id_user,$id_group,"IW") ==1)) - echo " "; - if (give_acl($id_user,$id_group,"IM") ==1) - echo " "; - - if (give_acl($id_user,$id_group,"IW") == 1) + + // Timestamp + echo ""; + echo human_time_comparation($row2["timestamp"]); + + // Several options grouped here + echo ""; + // Validate event + if (($row2["estado"] == 0) and (give_acl($config["id_user"], $id_group,"IW") ==1)) + echo " "; + // Delete event + if (give_acl($config["id_user"], $id_group,"IM") ==1) + echo " "; + // Create incident from this event + if (give_acl($config["id_user"], $id_group,"IW") == 1) echo ""; - - echo ""; + // Checbox + echo ""; echo ""; echo "
"; echo " "; - if (give_acl($id_user, 0,"IM") ==1){ + if (give_acl($config["id_user"], 0,"IM") ==1){ echo ""; } echo "
"; diff --git a/pandora_console/operation/events/events_rss.php b/pandora_console/operation/events/events_rss.php index 6e279ee84b..66b7a39050 100644 --- a/pandora_console/operation/events/events_rss.php +++ b/pandora_console/operation/events/events_rss.php @@ -55,7 +55,7 @@ while($row=mysql_fetch_array($result,MYSQL_ASSOC)) { $rss_feed .= '

Validated by ' . $row['validated_by']; } $rss_feed .= ''; - $rss_feed .= $url . "/operation/events/view_event?id=" . $event_id; + $rss_feed .= $url . "/operation/events/view_event?id=" . $row["event_id"]; $rss_feed .= ''; //The rest is optional $rss_feed .= '' . date(DATE_RFC822, $row['unix_timestamp']) . ''; diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 183e7387f6..7f844d78e5 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -188,13 +188,15 @@ if (give_acl($_SESSION["id_usuario"], 0, "AR")==1) { } echo "
"; - // User statistic - if(isset($_GET["sec2"]) && $_GET["sec2"] == "operation/users/user_statistics") { - echo "
"; - } else { - echo ""; + // User statistics require UM + if (give_acl($_SESSION["id_usuario"], 0, "UM")==1) { + if(isset($_GET["sec2"]) && $_GET["sec2"] == "operation/users/user_statistics") { + echo "
"; + } else { + echo ""; + } } // SNMP console diff --git a/pandora_console/operation/servers/view_server.php b/pandora_console/operation/servers/view_server.php index 78b2b5d8cb..0c693e86b3 100644 --- a/pandora_console/operation/servers/view_server.php +++ b/pandora_console/operation/servers/view_server.php @@ -95,16 +95,19 @@ if (mysql_num_rows($result)){ // Recon server detail if ($recon_server == 1) - echo "$name "; + if (give_acl($id_user, 0, "PM")==1) + echo "$name "; + else + echo "$name"; else echo "$name"; // Status (bad or good) echo ""; if ($status ==0){ - echo ""; + echo ""; } else { - echo ""; + echo ""; } echo ""; @@ -248,7 +251,8 @@ if (mysql_num_rows($result)){ echo ""; // if ($status ==0) - echo substr($keepalive,0,25).""; + + echo human_date_relative($keepalive).""; } echo ''; echo ""; diff --git a/pandora_console/operation/snmpconsole/snmp_alert.php b/pandora_console/operation/snmpconsole/snmp_alert.php index 1528e21517..9415f9677b 100644 --- a/pandora_console/operation/snmpconsole/snmp_alert.php +++ b/pandora_console/operation/snmpconsole/snmp_alert.php @@ -42,6 +42,7 @@ if (give_acl($id_user, 0, "LW")==1) { $last_fired = ""; $max_alerts = ""; $min_alerts = ""; + $priority = ""; // Alert Delete // ============= @@ -72,16 +73,17 @@ if (give_acl($id_user, 0, "LW")==1) { $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) VALUES ($alert_id,'$field1','$field2','$field3','$description', $alert_type, '$agent', '$custom', '$oid', $time, $max, $min)"; + $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 "

".$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"; + $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 "

".$lang_label["update_alert_no"]."

"; @@ -113,6 +115,7 @@ if (give_acl($id_user, 0, "LW")==1) { $last_fired = $row["last_fired"]; $max_alerts = $row["max_alerts"]; $min_alerts = $row["min_alerts"]; + $priority = $row["priority"]; } } if (isset($_POST["add_alert"])){ @@ -186,19 +189,44 @@ if (give_acl($id_user, 0, "LW")==1) { echo ''; echo ''; echo ''; - echo ''; + echo ''; echo ''; echo ''; echo ''; + + // Time THreshold echo ''; - echo ''; + echo '
'.$lang_label["field2"].'
'.$lang_label["field3"]; - echo '
'.$lang_label["field3"]; + echo ''; - // max & min alerts, time threshold + // Max / Min alerts echo '
'.$lang_label["min_alerts"].'
'.$lang_label["max_alerts"].'
'.$lang_label["time_threshold"].''; + echo ''; + + // Priority + echo '
'.lang_string("Priority"); + echo ''; + echo form_priority ($priority); + echo '
'; echo '
'; diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index e200d8a8f4..11317fad22 100644 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -131,14 +131,13 @@ if (comprueba_login() == 0) { $result2=mysql_query($sql2); if (mysql_num_rows($result2)){ - echo ""; echo ""; echo ""; echo "
"; - echo " - ".$lang_label["validated_event"]; + echo " - ".$lang_label["validated_event"]; echo "
"; - echo " - ".$lang_label["not_validated_event"]; - echo "
"; - echo " - ".$lang_label["alert"]; + echo " - ".$lang_label["not_validated_event"]; + //echo "
"; + //echo " - ".$lang_label["alert"]; echo "
"; echo " - ".$lang_label["validate_event"]; @@ -219,10 +218,10 @@ if (comprueba_login() == 0) { echo "
"; if ($row["status"] == 0){ - echo ""; + echo ""; } else { - echo ""; + echo ""; } echo "".$row["oid"]; $sql="SELECT * FROM tagente WHERE direccion = '".$row["source"]."'"; diff --git a/pandora_console/operation/users/user.php b/pandora_console/operation/users/user.php index e8f5579ca3..d92ef18afb 100644 --- a/pandora_console/operation/users/user.php +++ b/pandora_console/operation/users/user.php @@ -36,7 +36,13 @@ if (comprueba_login() == 0) { ".$layout_name.""; +echo "

".$layout_name; + +if ($config["pure"] == 0){ + echo lang_string("Full screen mode"); + echo " "; + echo ""; + echo ""; + echo ""; +} else { + echo lang_string("Back to normal mode"); + echo " "; + echo ""; + echo ""; + echo ""; +} + +echo "

"; echo "
"; $sql="SELECT * FROM tlayout_data WHERE id_layout = $id_layout"; @@ -98,7 +117,7 @@ while ($row = mysql_fetch_array($res)){ if (($link_layout == "") OR ($link_layout == 0)){ $link_string = ""; } else { - $link_string = ""; + $link_string = ""; } // Draw image echo "
"; @@ -127,7 +146,7 @@ while ($row = mysql_fetch_array($res)){ if (($link_layout == "") OR ($link_layout == 0)){ $link_string = ""; } else { - $link_string = ""; + $link_string = ""; } // Draw image echo "
"; @@ -194,18 +213,13 @@ echo "
"; echo "
"; echo "
"; -echo "
"; +echo ""; echo ""; echo "
"; echo $lang_label["auto_refresh_time"]; echo ""; echo ""; echo ""; echo ""; echo "
"; + echo "
"; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 72f509c93a..1c66c810d8 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -196,6 +196,7 @@ CREATE TABLE `talert_snmp` ( `max_alerts` int(11) NOT NULL default '1', `min_alerts` int(11) NOT NULL default '1', `internal_counter` int(2) unsigned NOT NULL default '0', + `priority` tinyint(4) default '0', PRIMARY KEY (`id_as`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -252,6 +253,12 @@ CREATE TABLE `talerta_agente_modulo` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- Priority : 0 - Maintance (grey) +-- Priority : 1 - Low (green) +-- Priority : 2 - Normal (blue) +-- Priority : 3 - Warning (yellow) +-- Priority : 4 - Critical (red) + CREATE TABLE `tattachment` ( `id_attachment` bigint(20) unsigned NOT NULL auto_increment, `id_incidencia` bigint(20) NOT NULL default '0', @@ -293,12 +300,16 @@ CREATE TABLE `tevento` ( `id_agentmodule` bigint(20) NOT NULL default '0', `id_alert_am` bigint(20) NOT NULL default '0', `criticity` int(4) unsigned NOT NULL default 0, - PRIMARY KEY (`id_evento`), KEY `indice_1` (`id_agente`,`id_evento`), KEY `indice_2` (`utimestamp`,`id_evento`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- Criticity: 0 - Maintance (grey) +-- Criticity: 1 - Low (green) +-- Criticity: 2 - Normal (blue) +-- Criticity: 3 - Warning (yellow) +-- Criticity: 4 - Critical (red) CREATE TABLE `tgrupo` ( `id_grupo` mediumint(8) unsigned NOT NULL auto_increment, diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index fae04a12a1..4d5023dab0 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -26,17 +26,17 @@ -- Dumping data for table `talerta` -- -INSERT INTO `talerta` VALUES (1,'Compound only', '', 'This alert will not be executed individually'); -INSERT INTO `talerta` VALUES (2,'Pandora FMS Alertlog','echo _timestamp_ pandora _agent_ _data_ _field1_ _field2_ >> /var/log/pandora/pandora_alert.log','This is a default alert to write alerts in a standard ASCII plaintext log file in /var/log/pandora/pandora_alert.log\r\n'); -INSERT INTO `talerta` VALUES (3,'Internal Audit','','This alert save alert in Pandora interal audit system. Fields are static and only _field1_ is used.'); +INSERT INTO `talerta` VALUES (1,'Compound only', 'Internal type', 'This alert will not be executed individually'); +INSERT INTO `talerta` VALUES (2,'eMail','Internal type', 'This alert send an email using internal Pandora FMS Server SMTP capabilities (defined in each server, using:\r\n_field1_ as destination email address, and\r\n_field2_ as subject for message. \r\n_field3_ as text of message.'); +INSERT INTO `talerta` VALUES (3,'Internal Audit','Internal type','This alert save alert in Pandora interal audit system. Fields are static and only _field1_ is used.'); +INSERT INTO `talerta` VALUES (4,'Pandora FMS Event','Internal type','This alert create an special event into Pandora FMS event manager.'); -INSERT INTO `talerta` VALUES (4,'eMail','echo _field3_ | sendmail -s _field2_ _field1_','Send email from Pandora Server. mail is a default command on all standard Unix systems, using:\r\n_field1_ as destination email address, and\r\n_field2_ as subject for message. \r\n_field3_ as text of message.'); -INSERT INTO `talerta` VALUES (5,'SNMP Trap','/usr/bin/snmptrap -v 1 -c trap_public 192.168.0.4 1.1.1.1.1.1.1.1 _agent_ _field1_','Send a SNMPTRAP to 192.168.0.4. Please review config and adapt to your needs, this is only a sample, not functional itself.'); -INSERT INTO `talerta` VALUES (6,'SMS Text','echo _field2_ | mail -s PANDORA_field1_ myuser@smsgateway.com','Send SMS via e-mail gateway. Use field1 for a short SMS text (35 chars) and field 2 for text message (full SMS)'); +INSERT INTO `talerta` VALUES (5,'Pandora FMS Alertlog','echo _timestamp_ pandora _agent_ _data_ _field1_ _field2_ >> /var/log/pandora/pandora_alert.log','This is a default alert to write alerts in a standard ASCII plaintext log file in /var/log/pandora/pandora_alert.log\r\n'); +INSERT INTO `talerta` VALUES (6,'SNMP Trap','/usr/bin/snmptrap -v 1 -c trap_public 192.168.0.4 1.1.1.1.1.1.1.1 _agent_ _field1_','Send a SNMPTRAP to 192.168.0.4. Please review config and adapt to your needs, this is only a sample, not functional itself.'); INSERT INTO `talerta` VALUES (7,'Syslog','logger -p daemon.alert Pandora Alert _agent_ _data_ _field1_ _field2_','Uses field1 and field2 to generate Syslog alert in facility daemon with "alert" level.'); INSERT INTO `talerta` VALUES (8,'Sound Alert','/usr/bin/play /usr/share/sounds/alarm.wav',''); INSERT INTO `talerta` VALUES (9,'Jabber Alert','echo _field3_ | sendxmpp -r _field1_ --chatroom _field2_','Send jabber alert to chat room in a predefined server (configure first .sendxmpprc file). Uses field3 as text message, field1 as useralias for source message, and field2 for chatroom name'); -INSERT INTO `talerta` VALUES (10,'Synthetized Speech','flite -t _FIELD2_','Uses commandline voice synthetizer to \"speak\" text given as parameter 1 and 2'); + -- -- Dumping data for table `tconfig` @@ -57,7 +57,7 @@ UNLOCK TABLES; /*!40000 ALTER TABLE `tconfig_os` DISABLE KEYS */; LOCK TABLES `tconfig_os` WRITE; -INSERT INTO `tconfig_os` VALUES (1,'GNU/Linux','Linux: All versions','so_linux.png'),(2,'Solaris','Sun Solaris','so_solaris.png'),(3,'AIX','IBM AIX','so_aix.png'),(4,'BSD','OpenBSD, FreeBSD and Others','so_bsd.png'),(5,'HP-UX','HP-UX Unix OS','so_hpux.png'),(6,'BeOS','BeOS','so_beos.png'),(7,'Cisco','CISCO IOS','so_cisco.png'),(8,'MacOS','MAC OS','so_mac.png'),(9,'Windows','Microsoft Windows OS','so_win.png'),(10,'Other','Other SO','so_other.png'),(11,'Network','Pandora Network Agent','network.png'); +INSERT INTO `tconfig_os` VALUES (1,'Linux','Linux: All versions','so_linux.png'),(2,'Solaris','Sun Solaris','so_solaris.png'),(3,'AIX','IBM AIX','so_aix.png'),(4,'BSD','OpenBSD, FreeBSD and Others','so_bsd.png'),(5,'HP-UX','HP-UX Unix OS','so_hpux.png'),(7,'Cisco','CISCO IOS','so_cisco.png'),(8,'MacOS','MAC OS','so_mac.png'),(9,'Windows','Microsoft Windows OS','so_win.png'),(10,'Other','Other SO','so_other.png'),(11,'Network','Pandora Network Agent','network.png'); UNLOCK TABLES; /*!40000 ALTER TABLE `tconfig_os` ENABLE KEYS */; @@ -71,8 +71,8 @@ INSERT INTO `tgrupo` VALUES (2,'Servers','server_database',0,0); INSERT INTO `tgrupo` VALUES (3,'IDS','eye',0,0); INSERT INTO `tgrupo` VALUES (4,'Firewalls','firewall',0,0); INSERT INTO `tgrupo` VALUES (8,'Databases','database_gear',0,0); -INSERT INTO `tgrupo` VALUES (9,'Comms','transmit',0,0); -INSERT INTO `tgrupo` VALUES (10,'Others','house',0,0); +INSERT INTO `tgrupo` VALUES (9,'Network','transmit',0,0); +INSERT INTO `tgrupo` VALUES (10,'Not classified','house',0,0); INSERT INTO `tgrupo` VALUES (11,'Workstations','computer',0,0); INSERT INTO `tgrupo` VALUES (12,'Applications','applications',0,0); UNLOCK TABLES; @@ -101,7 +101,14 @@ UNLOCK TABLES; /*!40000 ALTER TABLE `tlink` DISABLE KEYS */; LOCK TABLES `tlink` WRITE; -INSERT INTO `tlink` VALUES (0000000001,'GeekTools','www.geektools.com'),(0000000002,'CentralOPS','http://www.centralops.net/'),(0000000003,'Pandora Project','http://pandora.sourceforge.net'),(0000000004,'Babel Project','http://babel.sourceforge.net'),(0000000005,'Google','http://www.google.com'),(0000000006,'ArticaST','http://www.artica.es'); +INSERT INTO `tlink` VALUES +(0000000001,'GeekTools','www.geektools.com'), +(0000000002,'CentralOPS','http://www.centralops.net/'), +(0000000003,'Pandora FMS','http://pandora.sourceforge.net'), +(0000000004,'Babel Enterprise','http://babel.sourceforge.net'), +(0000000006,'Openideas','http://www.openideas.info'), +(0000000007,'Google','http://www.google.com'), +(0000000008,'ArticaST','http://www.artica.es'); UNLOCK TABLES; /*!40000 ALTER TABLE `tlink` ENABLE KEYS */; diff --git a/pandora_console/reporting/fgraph.php b/pandora_console/reporting/fgraph.php index af3f298deb..cdbb9ace67 100644 --- a/pandora_console/reporting/fgraph.php +++ b/pandora_console/reporting/fgraph.php @@ -21,6 +21,17 @@ include ($config["homedir"].'/include/functions.php'); include ($config["homedir"].'/include/functions_db.php'); require ($config["homedir"].'/include/languages/language_'.$config['language'].'.php'); +global $config; + +if (!isset($_SESSION["id_user"])){ + session_start(); + session_write_close(); +} +$config ["id_user"] = $_SESSION["id_usuario"]; + +// Session check +check_login (); + /** * Show a brief error message in a PNG graph */ @@ -129,7 +140,7 @@ function graphic_combined_module ( $module_list, $weight_list, $periodo, if ($show_event == 1){ // If we want to show events in graphs - $sql1="SELECT utimestamp FROM tevento WHERE id_agente = $id_agente AND utimestamp > $fechatope"; + $sql1="SELECT utimestamp FROM tevento WHERE id_agentmodule = $id_agente_modulo AND utimestamp > $fechatope"; $result=mysql_query($sql1); while ($row=mysql_fetch_array($result)){ $utimestamp = $row[0]; @@ -377,8 +388,19 @@ function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $show_event, $id_agente = dame_agente_id($nombre_agente); $nombre_modulo = dame_nombre_modulo_agentemodulo($id_agente_modulo); - if ($show_event == 1) - $real_event = array(); + if ($show_event == 1){ + // If we want to show events in graphs + $sql1="SELECT utimestamp FROM tevento WHERE id_agentmodule = $id_agente_modulo AND utimestamp > $fechatope"; + $result=mysql_query($sql1); + while ($row=mysql_fetch_array($result)){ + $utimestamp = $row[0]; + for ($i=0; $i <= $resolution; $i++) { + if ( ($utimestamp <= $valores[$i][3]) && ($utimestamp >= $valores[$i][2]) ){ + $real_event[$i]=1; + } + } + } + } if ($show_alert == 1){ $alert_high = 0; @@ -1139,27 +1161,48 @@ function grafico_eventos_usuario( $width=420, $height=200) { generic_pie_graph ($width, $height, $data, $legend); } -function grafico_eventos_total() { +function grafico_eventos_total( $filter = "") { require ("../include/config.php"); require ("../include/languages/language_".$config['language'].".php"); - + $filter = str_replace ( "\\" , "", $filter); $data = array(); $legend = array(); $total = 0; - $sql1="SELECT COUNT(id_evento) FROM tevento WHERE estado = 1 "; + $sql1="SELECT COUNT(id_evento) FROM tevento WHERE criticity = 0 $filter"; $result=mysql_query($sql1); $row=mysql_fetch_array($result); $data[] = $row[0]; - $legend[] = "Revised ( $row[0] )"; + $legend[] = lang_string("Maintenance")." ( $row[0] )"; $total = $row[0]; - $sql1="SELECT COUNT(id_evento) FROM tevento WHERE estado = 0 "; + $sql1="SELECT COUNT(id_evento) FROM tevento WHERE criticity = 1 $filter"; $result=mysql_query($sql1); $row=mysql_fetch_array($result); $data[] = $row[0]; $total = $total + $row[0]; - $legend[] = "Not Revised ( $row[0] )"; + $legend[] = lang_string("Informational")."( $row[0] )"; + + $sql1="SELECT COUNT(id_evento) FROM tevento WHERE criticity = 2 $filter"; + $result=mysql_query($sql1); + $row=mysql_fetch_array($result); + $data[] = $row[0]; + $total = $total + $row[0]; + $legend[] = lang_string("Normal")." ( $row[0] )"; + + $sql1="SELECT COUNT(id_evento) FROM tevento WHERE criticity = 3 $filter"; + $result=mysql_query($sql1); + $row=mysql_fetch_array($result); + $data[] = $row[0]; + $total = $total + $row[0]; + $legend[] = lang_string("Warning")." ( $row[0] )"; + + $sql1="SELECT COUNT(id_evento) FROM tevento WHERE criticity = 4 $filter"; + $result=mysql_query($sql1); + $row=mysql_fetch_array($result); + $data[] = $row[0]; + $total = $total + $row[0]; + $legend[] = lang_string("Critical")." ( $row[0] )"; // Sort array by bubble method (yes, I study more methods in university, but if you want more speed, please, submit a patch :) // or much better, pay me to do a special version for you, highly optimized :-)))) @@ -1177,23 +1220,83 @@ function grafico_eventos_total() { generic_pie_graph (320, 200, $data, $legend); } -function grafico_eventos_grupo ($width = 300, $height = 200 ) { + + +function graph_event_module ($width = 300, $height = 200, $id_agent ) { + include ("../include/config.php"); + require ("../include/languages/language_".$config['language'].".php"); + global $config; + + // Need ACL check + $data = array(); + $legend = array(); + $sql1="SELECT * FROM tagente_modulo WHERE id_agente = $id_agent AND disabled = 0"; + $result=mysql_query($sql1); + while ($row=mysql_fetch_array($result)){ + $sql1="SELECT COUNT(*) FROM tevento WHERE id_agentmodule = ".$row["id_agente_modulo"]; + if ($result2=mysql_query($sql1)) + $row2=mysql_fetch_array($result2); + if ($row2[0] > 0){ + $data[] = $row2[0]; + $legend[] = substr($row["nombre"],0,15)." ( $row2[0] )"; + } + } + // Sort array by bubble method (yes, I study more methods in university, but if you want more speed, please, submit a patch :) + // or much better, pay me to do a special version for you, highly optimized :-)))) + for ($a=0;$a < sizeof($data);$a++){ + for ($b=$a; $b $data[$a]){ + $temp = $data[$a]; + $temp_label = $legend[$a]; + $data[$a] = $data[$b]; + $legend[$a] = $legend[$b]; + $data[$b] = $temp; + $legend[$b] = $temp_label; + } + } + $max_items = 6; + // Take only the first x items + if (sizeof($data) >= $max_items){ + for ($a=0;$a < $max_items;$a++){ + $legend2[]= $legend[$a]; + $data2[] = $data[$a]; + } + generic_pie_graph ($width, $height, $data2, $legend2); + } else + generic_pie_graph ($width, $height, $data, $legend); +} + + +function grafico_eventos_grupo ($width = 300, $height = 200, $url = "" ) { include ("../include/config.php"); require ("../include/languages/language_".$config['language'].".php"); - + global $config; + $url = str_replace ( "\\" , "", $url); $data = array(); $legend = array(); - $sql1="SELECT * FROM tgrupo"; + $sql1="SELECT * FROM tagente"; $result=mysql_query($sql1); while ($row=mysql_fetch_array($result)){ - $sql1="SELECT COUNT(id_evento) fROM tevento WHERE id_grupo = ".$row["id_grupo"]; - $result2=mysql_query($sql1); - $row2=mysql_fetch_array($result2); - if ($row2[0] > 0){ - $data[] = $row2[0]; - $legend[] = $row["nombre"]." ( $row2[0] )"; - } + if (give_acl($config["id_user"], $row["id_grupo"], "AR") == 1){ + $sql1="SELECT COUNT(id_evento) FROM tevento WHERE 1=1 $url AND id_agente = ".$row["id_agente"]; + if ($result2=mysql_query($sql1)) + $row2=mysql_fetch_array($result2); + if ($row2[0] > 0){ + $data[] = $row2[0]; + $legend[] = substr($row["nombre"],0,15)." ( $row2[0] )"; + } + } } + + // System events + $sql1="SELECT COUNT(id_evento) FROM tevento WHERE 1=1 $url AND id_agente = 0"; + if ($result2=mysql_query($sql1)) + $row2=mysql_fetch_array($result2); + if ($row2[0] > 0){ + $data[] = $row2[0]; + $legend[] = "SYSTEM"." ( $row2[0] )"; + } + // Sort array by bubble method (yes, I study more methods in university, but if you want more speed, please, submit a patch :) // or much better, pay me to do a special version for you, highly optimized :-)))) for ($a=0;$a < sizeof($data);$a++){ @@ -1207,9 +1310,10 @@ function grafico_eventos_grupo ($width = 300, $height = 200 ) { $legend[$b] = $temp_label; } } -// Take only the first x items - if (sizeof($data) >= 7){ - for ($a=0;$a < 7;$a++){ + $max_items = 6; + // Take only the first x items + if (sizeof($data) >= $max_items){ + for ($a=0;$a < $max_items;$a++){ $legend2[]= $legend[$a]; $data2[] = $data[$a]; } @@ -1368,148 +1472,88 @@ function drawWarning($width,$height) { } -function progress_bar($progress,$width,$height) { - // Copied from the PHP manual: - // http://us3.php.net/manual/en/function.imagefilledrectangle.php - // With some adds from sdonie at lgc dot com - // Get from official documentation PHP.net website. Thanks guys :-) - // Code ripped from Babel Project :-) - function drawRating($rating,$width,$height) { - include ("../include/config.php"); - require ("../include/languages/language_".$config['language'].".php"); - if ($width == 0) { - $width = 150; - } - if ($height == 0) { - $height = 20; - } - //$rating = $_GET['rating']; - $ratingbar = (($rating/100)*$width)-2; - $image = imagecreate($width,$height); - //colors - $back = ImageColorAllocate($image,255,255,255); - $border = ImageColorAllocate($image,0,0,0); - $red = ImageColorAllocate($image,255,60,75); - $fill = ImageColorAllocate($image,44,81,150); - $rating = format_numeric ( $rating, 2); - ImageFilledRectangle($image,0,0,$width-1,$height-1,$back); - if ($rating > 100) - ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$red); - else - ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$fill); - ImageRectangle($image,0,0,$width-1,$height-1,$border); - if ($rating > 50) - if ($rating > 100) - ImageTTFText($image, 8, 0, ($width/4), ($height/2)+($height/5), $back, $config['fontpath'],$lang_label["out_of_limits"]); - else - ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $back, $config['fontpath'], $rating."%"); - else - ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $border, $config['fontpath'], $rating."%"); - imagePNG($image); - imagedestroy($image); - } - Header("Content-type: image/png"); - if ($progress > 100 || $progress < 0){ - // HACK: This report a static image... will increase render in about 200% :-) useful for - // high number of realtime statusbar images creation (in main all agents view, for example - $imgPng = imageCreateFromPng("../images/outof.png"); - imageAlphaBlending($imgPng, true); - imageSaveAlpha($imgPng, true); - imagePng($imgPng); - } else - drawRating($progress,$width,$height); +// *************************************************************************** +// Draw a dynamic progress bar using GDlib directly +// *************************************************************************** + +function progress_bar ($progress, $width, $height, $mode = 1) { + // Copied from the PHP manual: + // http://us3.php.net/manual/en/function.imagefilledrectangle.php + // With some adds from sdonie at lgc dot com + // Get from official documentation PHP.net website. Thanks guys :-) + function drawRating($rating, $width, $height, $mode) { + include ("../include/config.php"); + require ("../include/languages/language_".$config["language"].".php"); + $rating = format_numeric($rating,1); + if ($width == 0) { + $width = 150; + } + if ($height == 0) { + $height = 20; + } + + //$rating = $_GET['rating']; + $ratingbar = (($rating/100)*$width)-2; + + $image = imagecreate($width,$height); + //colors + $back = ImageColorAllocate($image,255,255,255); + $border = ImageColorAllocate($image,140,140,140); + $textcolor = ImageColorAllocate($image,60,60,60); + $red = ImageColorAllocate($image,255,60,75); + + if ($mode == 0){ + if ($rating > 70) + $fill = ImageColorAllocate($image,176,255,84); // Green + elseif ($rating > 50) + $fill = ImageColorAllocate($image,255,230,84); // Yellow + elseif ($rating > 30) + $fill = ImageColorAllocate($image,255,154,83); // Orange + else + $fill = ImageColorAllocate($image,255,0,0); // Red + } + else + $fill = ImageColorAllocate($image,44,81,150); + + + $grey = ImageColorAllocate($image,230,230,210); + + if ($mode == 1){ + ImageFilledRectangle($image,0,0,$width-1,$height-1,$back); + } else { + ImageFilledRectangle($image,0,0,$width-1,$height-1,$grey); + } + if ($rating > 100) + ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$red); + else + ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$fill); + if ($mode == 1){ + ImageRectangle($image,0,0,$width-1,$height-1,$border); + } + if ($mode == 1){ + if ($rating > 50) + if ($rating > 100) + ImageTTFText($image, 8, 0, ($width/4), ($height/2)+($height/5), $back, $config["fontpath"], lang_string ("out_of_limits")); + else + ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $back, $config["fontpath"], $rating."%"); + else + ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $textcolor, $config["fontpath"], $rating."%"); + } + imagePNG($image); + imagedestroy($image); + } + Header("Content-type: image/png"); + if ($progress > 100 || $progress < 0){ + // HACK: This report a static image... will increase render in about 200% :-) useful for + // high number of realtime statusbar images creation (in main all agents view, for example + $imgPng = imageCreateFromPng("../images/outof.png"); + imageAlphaBlending($imgPng, true); + imageSaveAlpha($imgPng, true); + imagePng($imgPng); + } else + drawRating($progress,$width,$height,$mode); } -/*NOT USED ! - -function graphic_test ($id, $period, $interval, $label, $width, $height){ - require_once 'Image/Graph.php'; - include ("../include/config.php"); - $color ="#437722"; // Green pandora 1.1 octopus color - - $intervalo = 500; // We want 30 slices for graph resolution. - $now_date = dame_fecha(0); - $horasint = $period / $intervalo; - $top_date = dame_fecha($period); - - // Para crear las graficas vamos a crear un array de Ax4 elementos, donde - // A es el numero de posiciones diferentes en la grafica (30 para un mes, 7 para una semana, etc) - // y los 4 valores en el ejeY serian los detallados a continuacion: - // Rellenamos la tabla con un solo select, y los calculos se hacen todos sobre memoria - // esto acelera el tiempo de calculo al maximo, aunque complica el algoritmo :-) - - $total_items=5000; - $factor = rand(1,10); $b=0; - // This is my temporal data (only a simple static test by now) - for ($a=0; $a < $total_items; $a++){ - $valor = 1 + cos(deg2rad($b)); - $b = $b + $factor/10; - if ($b > 180){ - $b =0; - } - $valor = $valor * $b ; - $valores[$a][0] = $valor; - $valores[$a][1] = $a; - } - - - // Creamos la tabla (array) con los valores para el grafico. Inicializacion - $valor_maximo = 0; - $maxvalue=0; - $minvalue=100000000; - for ($i = $intervalo-1; $i >0; $i--) { // 30 entries in graph, one by day - $grafica[]=$valores[$i][0]; - $legend[]=$valores[$i][1]; - if ($valores[$i][0] < $minvalue) - $minvalue = $valores[$i][0]; - if ($valores[$i][0] > $maxvalue) - $maxvalue = $valores[$i][0]; - } - - // Create graph - - // Create graph - // create the graph - $Graph =& Image_Graph::factory('graph', array($width, $height)); - // add a TrueType font - $Font =& $Graph->addNew('font', $config['fontpath']); - $Font->setSize(6); - $Graph->setFont($Font); - $Graph->add( - Image_Graph::vertical( - Image_Graph::factory('title', array("", 2)), - $Plotarea = Image_Graph::factory('plotarea'), - 0) - ); - // Create the dataset - // Merge data into a dataset object (sancho) - $Dataset =& Image_Graph::factory('dataset'); - for ($a=0;$a < sizeof($grafica); $a++){ - $Dataset->addPoint($legend[$a],$grafica[$a]); - } - // create the 1st plot as smoothed area chart using the 1st dataset - $Plot =& $Plotarea->addNew('area', array(&$Dataset)); - // set a line color - $Plot->setLineColor('gray'); - // set a standard fill style - $Plot->setFillColor('green@0.4'); - // $Plotarea->hideAxis(); - $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); - // $AxisX->Hide(); - $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); - $AxisY->setLabelOption("showtext",true); - $AxisY->setLabelInterval(ceil(($maxvalue-$minvalue)/4)); - $AxisX->setLabelInterval($intervalo / 5); - $AxisY->forceMinimum($minvalue); - $GridY2 =& $Plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y_SECONDARY); - $GridY2->setLineColor('blue'); - $GridY2->setFillColor('blue@0.1'); - $AxisY2 =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY); - $Graph->done(); - -} -*/ - function odo_tactic ($value1, $value2, $value3){ require_once 'Image/Graph.php'; include ("../include/config.php"); @@ -2023,10 +2067,13 @@ if ( isset($_GET["value2"])) else $value2 = 0; +$mode = get_parameter ("mode", 1); // Progress + $value3 = get_parameter("value3",0); $stacked = get_parameter ("stacked", 0); $time_reference = get_parameter ("time_reference", ""); - +$url = get_parameter ("url", ""); +$id_agent = get_parameter ("id_agent", ""); // Image handler // ***************** @@ -2048,11 +2095,11 @@ if (isset($_GET["tipo"])){ elseif ($_GET["tipo"] =="db_agente_purge") grafico_db_agentes_purge($id, $width, $height); elseif ($_GET["tipo"] =="group_events") - grafico_eventos_grupo($width, $height); + grafico_eventos_grupo($width, $height, $url); elseif ($_GET["tipo"] =="user_events") grafico_eventos_usuario($width, $height); elseif ($_GET["tipo"] =="total_events") - grafico_eventos_total(); + grafico_eventos_total($url); elseif ($_GET["tipo"] =="group_incident") graphic_incident_group(); elseif ($_GET["tipo"] =="user_incident") @@ -2070,11 +2117,14 @@ if (isset($_GET["tipo"])){ // graphic_test ($id, $period, $intervalo, $label, $width, $height); elseif ( $_GET["tipo"] =="progress"){ $percent= $_GET["percent"]; - progress_bar($percent,$width,$height); + progress_bar($percent,$width,$height,$mode); } elseif ( $_GET["tipo"] == "odo_tactic"){ odo_tactic ( $value1, $value2, $value3 ); } + elseif ( $_GET["tipo"] == "event_module"){ + graph_event_module ($width, $height, $id_agent); + } elseif ( $_GET["tipo"] =="combined"){ // Split id to get all parameters $module_list = array();