2009-01-26 Sancho Lerena <slerena@artica.es>

* 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
This commit is contained in:
slerena 2009-01-26 16:51:14 +00:00
parent 45b05d670f
commit 313844c94b
7 changed files with 166 additions and 39 deletions

View File

@ -1,3 +1,23 @@
2009-01-26 Sancho Lerena <slerena@artica.es>
* 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 <vanooste@rcbi.rochester.edu> 2009-01-26 Evi Vanoost <vanooste@rcbi.rochester.edu>
* include/styles/pandora.css: Fixed several small errors. Now it looks * include/styles/pandora.css: Fixed several small errors. Now it looks

View File

@ -125,6 +125,7 @@ $table_alerts->style = array ();
$table_alerts->style[0] = 'vertical-align: top'; $table_alerts->style[0] = 'vertical-align: top';
$table_alerts->style[1] = 'vertical-align: top'; $table_alerts->style[1] = 'vertical-align: top';
foreach ($modules as $id_agent_module => $module) { foreach ($modules as $id_agent_module => $module) {
$last_data = return_value_agent_module ($id_agent_module); $last_data = return_value_agent_module ($id_agent_module);
if ($last_data === false) if ($last_data === false)
@ -248,43 +249,44 @@ foreach ($modules as $id_agent_module => $module) {
$table->data = array (); $table->data = array ();
} }
if (isset($module)){
/* This hidden value is used in Javascript. It's a workaraound for IE because /* This hidden value is used in Javascript. It's a workaraound for IE because
it doesn't allow input elements creation. */ it doesn't allow input elements creation. */
print_input_hidden ('add_action', 1); print_input_hidden ('add_action', 1);
print_input_hidden ('id_alert_module', 0); print_input_hidden ('id_alert_module', 0);
echo '<form class="add_alert_form" method="post" style="display: none"
action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.
$module['id_agente'].'">';
echo '<div style="float:left">';
print_label (__('Template'), 'template');
$templates = get_alert_templates ();
if (empty ($templates))
$templates = array ();
print_select ($templates, 'template', '', '', __('None'), 0);
echo '</div><div style="margin-left: 270px">';
print_label (__('Action'), 'action');
$actions = get_alert_actions ();
if (empty ($actions))
$actions = array ();
print_select ($actions, 'action', '', '', __('None'), 0);
echo '<br />';
echo '<span><a href="#" class="show_advanced_actions">'.__('Advanced options').' &raquo; </a></span>';
echo '<span class="advanced_actions" style="display: none">';
echo __('From').' ';
print_input_text ('fires_min', -1, '', 4, 10);
echo ' '.__('to').' ';
print_input_text ('fires_max', -1, '', 4, 10);
echo ' '.__('matches of the alert');
echo pandora_help("alert-matches", true);
echo '</span></div>';
echo '<div style="float: right; margin-left: 30px;"><br />';
print_submit_button (__('Add'), 'add', false, 'class="sub next"');
print_input_hidden ('id_agent_module', 0);
print_input_hidden ('create_alert', 1);
echo '</div></form>';
echo '<form class="add_alert_form" method="post" style="display: none"
action="index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&id_agente='.
$module['id_agente'].'">';
echo '<div style="float:left">';
print_label (__('Template'), 'template');
$templates = get_alert_templates ();
if (empty ($templates))
$templates = array ();
print_select ($templates, 'template', '', '', __('None'), 0);
echo '</div><div style="margin-left: 270px">';
print_label (__('Action'), 'action');
$actions = get_alert_actions ();
if (empty ($actions))
$actions = array ();
print_select ($actions, 'action', '', '', __('None'), 0);
echo '<br />';
echo '<span><a href="#" class="show_advanced_actions">'.__('Advanced options').' &raquo; </a></span>';
echo '<span class="advanced_actions" style="display: none">';
echo __('From').' ';
print_input_text ('fires_min', -1, '', 4, 10);
echo ' '.__('to').' ';
print_input_text ('fires_max', -1, '', 4, 10);
echo ' '.__('matches of the alert');
echo pandora_help("alert-matches", true);
echo '</span></div>';
echo '<div style="float: right; margin-left: 30px;"><br />';
print_submit_button (__('Add'), 'add', false, 'class="sub next"');
print_input_hidden ('id_agent_module', 0);
print_input_hidden ('create_alert', 1);
echo '</div></form>';
}
?> ?>
<link rel="stylesheet" href="include/styles/cluetip.css" type="text/css" /> <link rel="stylesheet" href="include/styles/cluetip.css" type="text/css" />

View File

@ -631,7 +631,7 @@ if (isset ($_GET["delete_module"])){ // DELETE agent module !
// First delete from tagente_modulo -> if not successful, increment // First delete from tagente_modulo -> if not successful, increment
// error // 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++; $error++;
if (process_sql ("DELETE FROM tagente_estado WHERE id_agente_modulo = ".$id_borrar_modulo) === false) if (process_sql ("DELETE FROM tagente_estado WHERE id_agente_modulo = ".$id_borrar_modulo) === false)

View File

@ -162,6 +162,7 @@ function get_group_stats ($id_group) {
utimestamp utimestamp
FROM tagente_estado, tagente_modulo FROM tagente_estado, tagente_modulo
WHERE tagente_modulo.id_agente_modulo = tagente_estado.id_agente_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))); AND tagente_modulo.id_agente IN (%s)", implode (",", array_keys ($agents)));
$result = get_db_all_rows_sql ($sql); $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_checks"] = $data["monitor_checks"];
$data["total_ok"] = $data["monitor_ok"]; $data["total_ok"] = $data["monitor_ok"];
// Todo, count SNMP Alerts and Inventory alerts here // 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_fired"] = $data["monitor_alerts_fired"];
$data["total_alerts_fire_count"] = $data["monitor_alerts_fire_count"]; $data["total_alerts_fire_count"] = $data["monitor_alerts_fire_count"];
$data["monitor_bad"] = $data["monitor_critical"] + $data["monitor_unknown"] +$data["monitor_warning"]; $data["monitor_bad"] = $data["monitor_critical"] + $data["monitor_unknown"] +$data["monitor_warning"];

View File

@ -116,6 +116,7 @@ $sql = " FROM tagente, tagente_modulo, tagente_estado
WHERE tagente.id_agente = tagente_modulo.id_agente WHERE tagente.id_agente = tagente_modulo.id_agente
AND tagente_modulo.disabled = 0 AND tagente_modulo.disabled = 0
AND tagente.disabled = 0 AND tagente.disabled = 0
AND tagente_modulo.delete_pending = 0
AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo"; AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo";
// Agent group selector // Agent group selector

View File

@ -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 <path> 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

View File

@ -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) { $title, $unit_name, $show_event = 0, $show_alert = 0, $pure = 0, $stacked = 0, $date = 0) {
global $config; global $config;
require_once 'Image/Graph.php'; require_once 'Image/Graph.php';
$resolution = $config['graph_res'] * 50; // Number of "slices" we want in graph $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 // Init other general variables
if ($show_event == 1){ if ($show_event == 1){
// If we want to show events in graphs // If we want to show events in graphs
$sql1="SELECT utimestamp FROM tevento WHERE id_agentmodule = $id_agente_modulo AND utimestamp > $fechatope"; $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); $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"; $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) { foreach ($result as $row) {
$datos = $row["datos"]; $datos = $row["datos"];
$utimestamp = $row["utimestamp"]; $utimestamp = $row["utimestamp"];