From e5adb86b982e2de7e1e1fe0ba934df2a9aee4c8e Mon Sep 17 00:00:00 2001
From: zarzuelo <zarzuelo@gmail.com>
Date: Tue, 5 Mar 2013 09:23:03 +0000
Subject: [PATCH] 2013-03-05  Sergio Martin <sergio.martin@artica.es>

	* include/functions_reporting.php
	pandoradb.sql
	extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql: set the
	counts columns of agent table as "signed" to avoid overflow
	and add check to tactical statistics to avoid show negative
	numbers

	* godmode/agentes/module_manager_editor_plugin.php: Increase
	the size of text inputs in plugin modules for bug 3606401



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7777 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_console/ChangeLog                      | 12 ++++++++++++
 .../pandoradb_migrate_4.0.x_to_5.0.mysql.sql   | 14 +++++++-------
 .../agentes/module_manager_editor_plugin.php   |  2 +-
 .../include/functions_reporting.php            | 18 +++++++++---------
 pandora_console/pandoradb.sql                  | 14 +++++++-------
 5 files changed, 36 insertions(+), 24 deletions(-)

diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index 83e1716050..f724e12261 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,3 +1,15 @@
+2013-03-05  Sergio Martin <sergio.martin@artica.es>
+
+	* include/functions_reporting.php
+	pandoradb.sql
+	extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql: set the
+	counts columns of agent table as "signed" to avoid overflow
+	and add check to tactical statistics to avoid show negative
+	numbers
+
+	* godmode/agentes/module_manager_editor_plugin.php: Increase
+	the size of text inputs in plugin modules for bug 3606401
+
 2013-03-05  Junichi Satoh  <junichi@rworks.jp>
 	
 	* include/help/ja/help_tags_config.php,
diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql
index d5e12a3b43..552fe0414a 100644
--- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql
+++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql
@@ -58,13 +58,13 @@ ALTER TABLE `tincidencia` ADD COLUMN `id_agent` int(10) unsigned NULL default 0;
 -- ---------------------------------------------------------------------
 ALTER TABLE `tagente` ADD COLUMN `url_address` mediumtext NULL;
 ALTER TABLE `tagente` ADD COLUMN `quiet` tinyint(1) NOT NULL DEFAULT '0';
-ALTER TABLE `tagente` ADD COLUMN `normal_count` bigint(20) unsigned NOT NULL default '0';
-ALTER TABLE `tagente` ADD COLUMN `warning_count` bigint(20) unsigned NOT NULL default '0';
-ALTER TABLE `tagente` ADD COLUMN `critical_count` bigint(20) unsigned NOT NULL default '0';
-ALTER TABLE `tagente` ADD COLUMN `unknown_count` bigint(20) unsigned NOT NULL default '0';
-ALTER TABLE `tagente` ADD COLUMN `notinit_count` bigint(20) unsigned NOT NULL default '0';
-ALTER TABLE `tagente` ADD COLUMN `total_count` bigint(20) unsigned NOT NULL default '0';
-ALTER TABLE `tagente` ADD COLUMN `fired_count` bigint(20) unsigned NOT NULL default '0';
+ALTER TABLE `tagente` ADD COLUMN `normal_count` bigint(20) NOT NULL default '0';
+ALTER TABLE `tagente` ADD COLUMN `warning_count` bigint(20) NOT NULL default '0';
+ALTER TABLE `tagente` ADD COLUMN `critical_count` bigint(20) NOT NULL default '0';
+ALTER TABLE `tagente` ADD COLUMN `unknown_count` bigint(20) NOT NULL default '0';
+ALTER TABLE `tagente` ADD COLUMN `notinit_count` bigint(20) NOT NULL default '0';
+ALTER TABLE `tagente` ADD COLUMN `total_count` bigint(20) NOT NULL default '0';
+ALTER TABLE `tagente` ADD COLUMN `fired_count` bigint(20) NOT NULL default '0';
 
 -- ---------------------------------------------------------------------
 -- Table `talert_special_days`
diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php
index fa771bd602..3ca31b7bf2 100644
--- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php
+++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php
@@ -84,7 +84,7 @@ if(!empty($macros)) {
 		if(!empty($m['help'])) {
 			$data[0] .= ui_print_help_tip ($m['help'], true);
 		}
-		$data[1] = html_print_input_text($m['macro'], $m['value'], '', 15, 60, true);
+		$data[1] = html_print_input_text($m['macro'], $m['value'], '', 100, 255, true);
 		$table_simple->colspan['macro'.$m['macro']][1] = 3;
 		$table_simple->rowclass['macro'.$m['macro']] = 'macro_field';
 
diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php
index 5c3fc5c917..6a7de1097c 100644
--- a/pandora_console/include/functions_reporting.php
+++ b/pandora_console/include/functions_reporting.php
@@ -1009,29 +1009,29 @@ function reporting_get_stats_modules_status($data, $graph_width = 250, $graph_he
 	
 	$tdata = array();
 	$tdata[0] = html_print_image('images/status_sets/default/agent_critical_ball.png', true, array('title' => __('Monitor critical'), 'width' => '20px'));
-	$tdata[1] = $data["monitor_critical"] == 0 ? '-' : $data["monitor_critical"];
+	$tdata[1] = $data["monitor_critical"] <= 0 ? '-' : $data["monitor_critical"];
 	$tdata[1] = '<a style="color: ' . COL_CRITICAL . ';" class="big_data" href="' . $urls['monitor_critical'] . '">' . $tdata[1] . '</a>';
 
 	$tdata[2] = html_print_image('images/status_sets/default/agent_warning_ball.png', true, array('title' => __('Monitor warning'), 'width' => '20px'));
-	$tdata[3] = $data["monitor_warning"] == 0 ? '-' : $data["monitor_warning"];
+	$tdata[3] = $data["monitor_warning"] <= 0 ? '-' : $data["monitor_warning"];
 	$tdata[3] = '<a style="color: ' . COL_WARNING_DARK . ';" class="big_data" href="' . $urls['monitor_warning'] . '">' . $tdata[3] . '</a>';
 	$table_mbs->rowclass[] = '';
 	$table_mbs->data[] = $tdata;
 
 	$tdata = array();
 	$tdata[0] = html_print_image('images/status_sets/default/agent_ok_ball.png', true, array('title' => __('Monitor normal'), 'width' => '20px'));
-	$tdata[1] = $data["monitor_ok"] == 0 ? '-' : $data["monitor_ok"];
+	$tdata[1] = $data["monitor_ok"] <= 0 ? '-' : $data["monitor_ok"];
 	$tdata[1] = '<a style="color: ' . COL_NORMAL . ';" class="big_data" href="' . $urls["monitor_ok"] . '">' . $tdata[1] . '</a>';
 
 	$tdata[2] = html_print_image('images/status_sets/default/agent_no_monitors_ball.png', true, array('title' => __('Monitor unknown'), 'width' => '20px'));
-	$tdata[3] = $data["monitor_unknown"] == 0 ? '-' : $data["monitor_unknown"];
+	$tdata[3] = $data["monitor_unknown"] <= 0 ? '-' : $data["monitor_unknown"];
 	$tdata[3] = '<a style="color: ' . COL_UNKNOWN . ';" class="big_data" href="' . $urls["monitor_unknown"] . '">' . $tdata[3] . '</a>';
 	$table_mbs->rowclass[] = '';
 	$table_mbs->data[] = $tdata;
 
 	$tdata = array();
 	$tdata[0] = html_print_image('images/status_sets/default/agent_no_data_ball.png', true, array('title' => __('Monitor not init'), 'width' => '20px'));
-	$tdata[1] = $data["monitor_not_init"] == 0 ? '-' : $data["monitor_not_init"];
+	$tdata[1] = $data["monitor_not_init"] <= 0 ? '-' : $data["monitor_not_init"];
 	$tdata[1] = '<a style="color: ' . COL_NOTINIT . ';" class="big_data" href="' . $urls["monitor_not_init"] . '">' . $tdata[1] . '</a>';
 
 	$tdata[2] = $tdata[3] = '';
@@ -1106,11 +1106,11 @@ function reporting_get_stats_alerts($data) {
 
 	$tdata = array();
 	$tdata[0] = html_print_image('images/bell.png', true, array('title' => __('Defined alerts'), 'width' => '20px'));
-	$tdata[1] = $data["monitor_alerts"] == 0 ? '-' : $data["monitor_alerts"];
+	$tdata[1] = $data["monitor_alerts"] <= 0 ? '-' : $data["monitor_alerts"];
 	$tdata[1] = '<a style="color: ' . COL_NORMAL . ';" class="big_data" href="' . $urls["monitor_alerts"] . '">' . $tdata[1] . '</a>';
 
 	$tdata[2] = html_print_image('images/bell_error.png', true, array('title' => __('Fired alerts'), 'width' => '20px'));
-	$tdata[3] = $data["monitor_alerts_fired"] == 0 ? '-' : $data["monitor_alerts_fired"];
+	$tdata[3] = $data["monitor_alerts_fired"] <= 0 ? '-' : $data["monitor_alerts_fired"];
 	$tdata[3] = '<a style="color: ' . COL_ALERTFIRED . ';" class="big_data" href="' . $urls["monitor_alerts_fired"] . '">' . $tdata[3] . '</a>';
 	$table_al->rowclass[] = '';
 	$table_al->data[] = $tdata;
@@ -1170,11 +1170,11 @@ function reporting_get_stats_agents_monitors($data) {
 
 	$tdata = array();
 	$tdata[0] = html_print_image('images/bricks.png', true, array('title' => __('Total agents'), 'width' => '20px'));
-	$tdata[1] = $data["total_agents"] == 0 ? '-' : $data["total_agents"];
+	$tdata[1] = $data["total_agents"] <= 0 ? '-' : $data["total_agents"];
 	$tdata[1] = '<a style="color: black;" class="big_data" href="' . $urls['total_agents'] . '">' . $tdata[1] . '</a>';
 
 	$tdata[2] = html_print_image('images/brick.png', true, array('title' => __('Monitor checks'), 'width' => '20px'));
-	$tdata[3] = $data["monitor_checks"] == 0 ? '-' : $data["monitor_checks"];
+	$tdata[3] = $data["monitor_checks"] <= 0 ? '-' : $data["monitor_checks"];
 	$tdata[3] = '<a style="color: black;" class="big_data" href="' . $urls['monitor_checks'] . '">' . $tdata[3] . '</a>';
 	$table_am->rowclass[] = '';
 	$table_am->data[] = $tdata;
diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql
index de64417bfb..978582100b 100644
--- a/pandora_console/pandoradb.sql
+++ b/pandora_console/pandoradb.sql
@@ -71,13 +71,13 @@ CREATE TABLE IF NOT EXISTS `tagente` (
 	`update_gis_data` TINYINT(1) NOT NULL DEFAULT '1' COMMENT 'set it to one to update the position data (altitude, longitude, latitude) when getting information from the agent or to 0 to keep the last value and do not update it' ,
 	`url_address` mediumtext NULL,
 	`quiet` tinyint(1) NOT NULL default '0',
-	`normal_count` bigint(20) unsigned NOT NULL default '0',
-	`warning_count` bigint(20) unsigned NOT NULL default '0',
-	`critical_count` bigint(20) unsigned NOT NULL default '0',
-	`unknown_count` bigint(20) unsigned NOT NULL default '0',
-	`notinit_count` bigint(20) unsigned NOT NULL default '0',
-	`total_count` bigint(20) unsigned NOT NULL default '0',
-	`fired_count` bigint(20) unsigned NOT NULL default '0',
+	`normal_count` bigint(20) NOT NULL default '0',
+	`warning_count` bigint(20) NOT NULL default '0',
+	`critical_count` bigint(20) NOT NULL default '0',
+	`unknown_count` bigint(20) NOT NULL default '0',
+	`notinit_count` bigint(20) NOT NULL default '0',
+	`total_count` bigint(20) NOT NULL default '0',
+	`fired_count` bigint(20) NOT NULL default '0',
 	PRIMARY KEY  (`id_agente`),
 	KEY `nombre` (`nombre`),
 	KEY `direccion` (`direccion`),