diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 29cca89a86..fdec89b37c 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,19 @@ +2009-05-28 Esteban Sanchez + + * install.php: Use server address if the db host is not localhost. + Fixes #2796790. + + * include/functions_agents.php: Fixed an array cast on + get_agent_alerts_compound(). + + * include/functions_events.php: Critical and warning colors where + swapped on print_events_table(). + + * include/functions_reporting.php: Fixed alerts count on + get_group_stats() and count combined alerts too. Fixes #2791577 + + * operation/agentes/tactical.php: Style corrections. + 2009-05-27 Evi Vanoost * godmode/agentes/configurar_agente.php: Should fix bug #2785154. Wasn't diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 913e52b475..c0ba98f62b 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -169,10 +169,10 @@ function get_agent_alerts_compound ($id_agent, $filter = '', $options = false) { $filter .= format_array_to_where_clause_sql ($options); } - $id_agent = array ($id_agent); + $id_agent = (array) $id_agent; $sql = sprintf ("SELECT * FROM talert_compound - WHERE id_agent in (%s)%s", + WHERE id_agent IN (%s)%s", implode (',', $id_agent), $filter); $alerts = get_db_all_rows_sql ($sql); diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index ccd60eb953..fc4f85a835 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -279,11 +279,14 @@ function print_events_table ($filter = "", $limit = 10, $width = 440, $return = $data = array (); /* Colored box */ - if ($event["estado"] == 0) { - $data[0] = print_image ("images/pixel_red.png", true, array ("width" => 20, "height" => 20, "title" => get_priority_name ($event["criticity"]))); + if ($event["estado"] == 1) { + $img = 'images/pixel_red.png'; } else { - $data[0] = print_image ("images/pixel_green.png", true, array ("width" => 20, "height" => 20, "title" => get_priority_name ($event["criticity"]))); + $img = 'images/pixel_green.png'; } + $data[0] = print_image ($img, true, array ("width" => 20, + "height" => 20, + "title" => get_priority_name ($event["criticity"]))); /* Event type */ $data[1] = print_event_type_img ($event["event_type"], true); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 8c0268faed..f3a74b6e56 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -118,7 +118,7 @@ function get_group_stats ($id_group = 0) { if ($id_group == 0) { $id_group = array_keys (get_user_groups ()); } - $agents = array_keys (get_group_agents ($id_group)); + $agents = array_keys (get_group_agents ($id_group)); if (empty ($agents)) { //No agents in this group, means no data @@ -134,18 +134,19 @@ function get_group_stats ($id_group = 0) { $data["monitor_warning"] = (int) get_db_sql ("SELECT COUNT(*) FROM tagente_estado WHERE ".$filter."AND utimestamp > 0 AND estado = 2 AND UNIX_TIMESTAMP() - utimestamp < current_interval * 2"); $data["monitor_ok"] = $data["monitor_checks"] - $data["monitor_not_init"] - $data["monitor_unknown"] - $data["monitor_critical"] - $data["monitor_warning"]; - $result = get_db_all_rows_filter ('talert_template_modules', - array ('id_agent_module' => array_keys ($agents)), - array ('times_fired')); - if (empty ($result)) { - $result = array (); - } + $alerts = get_agent_alerts ($agents); - foreach ($result as $row) { - $data["monitor_alerts"]++; - if ($row["times_fired"] > 0) { - $data["monitor_alerts_fired"]++; - $data["monitor_alerts_fire_count"] += $row["times_fired"]; + if (empty ($alerts)) + $alerts = array (); + + $data["monitor_alerts"] = 0; + foreach ($alerts as $alert_type) { + $data["monitor_alerts"] += count ($alert_type); + foreach ($alert_type as $alert) { + if ($alert["times_fired"] > 0) { + $data["monitor_alerts_fired"]++; + $data["monitor_alerts_fire_count"] += $alert["times_fired"]; + } } } diff --git a/pandora_console/install.php b/pandora_console/install.php index c8212ee5d0..a10f4cda66 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -346,7 +346,6 @@ function install_step3() { "; } - function install_step4() { $pandora_config = "include/config.php"; @@ -410,7 +409,10 @@ function install_step4() { check_generic ($step4, "Populating database"); $random_password = random_name (8); - $step5 = mysql_query ("GRANT ALL PRIVILEGES ON $dbname.* to pandora@localhost + $host = 'localhost'; + if ($dbhost != 'localhost') + $host = $_SERVER['SERVER_ADDR']; + $step5 = mysql_query ("GRANT ALL PRIVILEGES ON $dbname.* to pandora@$host IDENTIFIED BY '".$random_password."'"); mysql_query ("FLUSH PRIVILEGES"); check_generic ($step5, "Established privileges for user pandora. A new random password has been generated: $random_password
Please write it down, you will need to setup your Pandora FMS server, editing the /etc/pandora/pandora_server.conf file
"); diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index 828c1b8801..77eb3667b2 100644 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -23,11 +23,11 @@ require_once ("include/functions_events.php"); check_login (); -if (give_acl ($config['id_user'], 0, "AR") != 1) { +if (! give_acl ($config['id_user'], 0, "AR")) { audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access Agent view (Grouped)"); require ("general/noaccess.php"); - exit; + return; } require_once ("include/functions_reporting.php"); @@ -185,9 +185,9 @@ foreach ($serverinfo as $server) { $data[0] = $server["name"]; if ($server["status"] == 0){ - $data[1] = print_status_image(STATUS_SERVER_DOWN, '', true); + $data[1] = print_status_image (STATUS_SERVER_DOWN, '', true); } else { - $data[1] = print_status_image(STATUS_SERVER_OK, '', true); + $data[1] = print_status_image (STATUS_SERVER_OK, '', true); } $data[2] = print_image ("reporting/fgraph.php?tipo=progress&percent=".$server["load"]."&height=20&width=80",