From ee961ee64920c5a5140e75377c07d9442e3381fd Mon Sep 17 00:00:00 2001 From: slerena Date: Mon, 26 Jan 2009 16:51:14 +0000 Subject: [PATCH] 2009-01-26 Sancho Lerena * include/functions_reporting.php: Fixed count of total alerts. Ignore delete pending modules. * operation/agentes/status_monitor.php: Added filter for pending delete modules. * reporting/fgraph.php: Fixed typo in combined graphs that makes them unusable. Now renders fine. * pandora_console_upgrade: New script to upgrade console from latest code. Also upgrade database (from 2.0 to 2.1/Trunk version). * godmode/agentes/alert_manager.php: Notice fix when no modules defined. * godmode/agentes/configurar_agente.php: Delete agent renames modulename to avoid that a pending delete module makes this module name unusable until efective deletion. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1404 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 20 ++++ .../godmode/agentes/alert_manager.php | 72 +++++++------ .../godmode/agentes/configurar_agente.php | 2 +- .../include/functions_reporting.php | 3 +- .../operation/agentes/status_monitor.php | 1 + pandora_console/pandora_console_upgrade | 100 ++++++++++++++++++ pandora_console/reporting/fgraph.php | 7 +- 7 files changed, 166 insertions(+), 39 deletions(-) create mode 100644 pandora_console/pandora_console_upgrade diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 5ebe7db7ae..0866945eb8 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,23 @@ +2009-01-26 Sancho Lerena + + * include/functions_reporting.php: Fixed count of total alerts. Ignore + delete pending modules. + + * operation/agentes/status_monitor.php: Added filter for pending delete + modules. + + * reporting/fgraph.php: Fixed typo in combined graphs that makes them + unusable. Now renders fine. + + * pandora_console_upgrade: New script to upgrade console from latest code. + Also upgrade database (from 2.0 to 2.1/Trunk version). + + * godmode/agentes/alert_manager.php: Notice fix when no modules defined. + + * godmode/agentes/configurar_agente.php: Delete agent renames modulename to + avoid that a pending delete module makes this module name unusable until + efective deletion. + 2009-01-26 Evi Vanoost * include/styles/pandora.css: Fixed several small errors. Now it looks diff --git a/pandora_console/godmode/agentes/alert_manager.php b/pandora_console/godmode/agentes/alert_manager.php index 13c91fc106..f40fa8968a 100644 --- a/pandora_console/godmode/agentes/alert_manager.php +++ b/pandora_console/godmode/agentes/alert_manager.php @@ -125,6 +125,7 @@ $table_alerts->style = array (); $table_alerts->style[0] = 'vertical-align: top'; $table_alerts->style[1] = 'vertical-align: top'; + foreach ($modules as $id_agent_module => $module) { $last_data = return_value_agent_module ($id_agent_module); if ($last_data === false) @@ -248,43 +249,44 @@ foreach ($modules as $id_agent_module => $module) { $table->data = array (); } +if (isset($module)){ -/* This hidden value is used in Javascript. It's a workaraound for IE because - it doesn't allow input elements creation. */ -print_input_hidden ('add_action', 1); -print_input_hidden ('id_alert_module', 0); - -echo ''; + /* This hidden value is used in Javascript. It's a workaraound for IE because + it doesn't allow input elements creation. */ + print_input_hidden ('add_action', 1); + print_input_hidden ('id_alert_module', 0); + echo ''; +} ?> diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 1625481368..8532459fa7 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -631,7 +631,7 @@ if (isset ($_GET["delete_module"])){ // DELETE agent module ! // First delete from tagente_modulo -> if not successful, increment // error - if (process_sql ("UPDATE tagente_modulo SET disabled = 1, delete_pending = 1 WHERE id_agente_modulo = ".$id_borrar_modulo) === false) + if (process_sql ("UPDATE tagente_modulo SET nombre = 'pendingdelete', disabled = 1, delete_pending = 1 WHERE id_agente_modulo = ".$id_borrar_modulo) === false) $error++; if (process_sql ("DELETE FROM tagente_estado WHERE id_agente_modulo = ".$id_borrar_modulo) === false) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 7ef598e312..a72b852c5c 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -162,6 +162,7 @@ function get_group_stats ($id_group) { utimestamp FROM tagente_estado, tagente_modulo WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + AND tagente_modulo.delete_pending = 0 AND tagente_modulo.id_agente IN (%s)", implode (",", array_keys ($agents))); $result = get_db_all_rows_sql ($sql); @@ -204,7 +205,7 @@ function get_group_stats ($id_group) { $data["total_checks"] = $data["monitor_checks"]; $data["total_ok"] = $data["monitor_ok"]; // Todo, count SNMP Alerts and Inventory alerts here - $data["total_alerts"] = $data["monitor_alerts"]; + $data["total_alerts"] = $data["monitor_alerts"] + $data["monitor_alerts_fired"]; $data["total_alerts_fired"] = $data["monitor_alerts_fired"]; $data["total_alerts_fire_count"] = $data["monitor_alerts_fire_count"]; $data["monitor_bad"] = $data["monitor_critical"] + $data["monitor_unknown"] +$data["monitor_warning"]; diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 2ac09febe1..c3e9509509 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -116,6 +116,7 @@ $sql = " FROM tagente, tagente_modulo, tagente_estado WHERE tagente.id_agente = tagente_modulo.id_agente AND tagente_modulo.disabled = 0 AND tagente.disabled = 0 + AND tagente_modulo.delete_pending = 0 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo"; // Agent group selector diff --git a/pandora_console/pandora_console_upgrade b/pandora_console/pandora_console_upgrade new file mode 100644 index 0000000000..09b10c18dd --- /dev/null +++ b/pandora_console/pandora_console_upgrade @@ -0,0 +1,100 @@ +# Pandora FMS 2.0 Console Upgrade (c) 2009 Artica ST +# Please see http://www.pandorafms.com +# This code is licensed under GPL 2.0 license. +# ********************************************************************** + +#!/bin/bash + +USER=`whoami` + +if [ $USER != "root" ] +then + echo "Upgrade process need to be executed by root" + exit -1 +fi + +MODE=$1 + +pandora_upgrade () { + + if [ ! -e "$PANDORAPATH/index.php" ] + then + echo "ERROR: Provided path for current Pandora FMS console, do not exist ($PANDORAPATH)" + exit -1 + fi + echo "Installing new console code in $PANDORAPATH" + cp -R * $PANDORAPATH + + if [ "$UPGRADEDB" == "1" ] + then + echo "Setting database schema changes" + DBUSER=`cat $PANDORAPATH/include/config.php | grep dbuser | grep -v "^\/" | grep -o "\=\"[a-zA-Z0-9]*\"" | grep -o "[A-Za-z0-9]*"` + DBPASS=`cat $PANDORAPATH/include/config.php | grep dbpass | grep -v "^\/" | grep -o "\=\"[a-zA-Z0-9]*\"" | grep -o "[A-Za-z0-9]*"` + DBHOST=`cat $PANDORAPATH/include/config.php | grep dbhost | grep -v "^\/" | grep -o "\=\"[a-zA-Z0-9]*\"" | grep -o "[A-Za-z0-9]*"` + DBNAME=`cat $PANDORAPATH/include/config.php | grep dbname | grep -v "^\/" | grep -o "\=\"[a-zA-Z0-9]*\"" | grep -o "[A-Za-z0-9]*"` + cat pandoradb_migrate_20_to_21.sql | mysql -u $DBUSER -p$DBPASS -h $DBHOST -D $DBNAME + fi + + WWWUSER=`ls -la $PANDORAPATH/index.php | awk '{ print $3 }'` + echo "Setting permissions for $WWWUSER in $PANDORAPATH" + chown -R $WWWUSER $PANDORAPATH + + echo "Setting permissions for $WWWUSER in /var/spool/pandora/data_in" + chgrp -R $WWWUSER /var/spool/pandora/data_in + + echo " " + echo "DONE!" + echo " " +} + +help () { + echo " -p Upgrade Pandora FMS Console in path (pe: /var/www/pandora_console)" + echo " -d Upgrade also Database (by default not upgrade Database) " + echo " " + exit 0 +} + +# Script banner at start +echo " " +echo "Pandora FMS 2.1 Console Upgrade (c) 2009 Artica ST" +echo "This program is licensed under GPL2 Terms. http://pandorafms.com" +echo " " + +UPGRADEDB=0 +UPGRADE=0 + +if [ $# -eq 0 ] +then + help +fi + +# Main parsing code + +while getopts ":hdp:" optname + do + case "$optname" in + "h") + help + ;; + "d") + UPGRADEDB=1 + ;; + "p") + PANDORAPATH=$OPTARG + UPGRADE=1 + ;; + ?) + help + ;; + default) + help + ;; + esac +done + +if [ "$UPGRADE" == "1" ] +then + pandora_upgrade +fi + +exit diff --git a/pandora_console/reporting/fgraph.php b/pandora_console/reporting/fgraph.php index 94ef31821f..c32fe0501b 100644 --- a/pandora_console/reporting/fgraph.php +++ b/pandora_console/reporting/fgraph.php @@ -95,7 +95,7 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width, $title, $unit_name, $show_event = 0, $show_alert = 0, $pure = 0, $stacked = 0, $date = 0) { global $config; - + require_once 'Image/Graph.php'; $resolution = $config['graph_res'] * 50; // Number of "slices" we want in graph @@ -143,6 +143,8 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width, } // Init other general variables + + 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"; @@ -175,7 +177,8 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width, $previous = (float) get_db_sql ($sql); $sql1="SELECT datos,utimestamp FROM tagente_datos WHERE id_agente_modulo = $id_agente_modulo AND utimestamp >= $fechatope AND utimestamp < $date"; - $result = (array) get_db_all_rows_sql ($sql); + + $result = (array) get_db_all_rows_sql ($sql1); foreach ($result as $row) { $datos = $row["datos"]; $utimestamp = $row["utimestamp"];