2013-03-11 Sergio Martin <sergio.martin@artica.es>

* include/functions_groups.php
	include/functions_graph.php: Added extral controls in status
	count retrieving functions to avoid negative numbers for
	bug 3607315

	* extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql
	extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql
	extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql: Updated
	the data of unknown modules to new fields in migration




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7828 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2013-03-11 15:57:35 +00:00
parent 9e66f14612
commit f2276e57b7
6 changed files with 68 additions and 14 deletions

View File

@ -1,3 +1,15 @@
2013-03-11 Sergio Martin <sergio.martin@artica.es>
* include/functions_groups.php
include/functions_graph.php: Added extral controls in status
count retrieving functions to avoid negative numbers for
bug 3607315
* extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql: Updated
the data of unknown modules to new fields in migration
2013-03-11 Miguel de Dios <miguel.dedios@artica.es> 2013-03-11 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/planned_downtime.list.php: fixed the lost data * godmode/agentes/planned_downtime.list.php: fixed the lost data

View File

@ -1108,3 +1108,9 @@ UPDATE talert_commands SET fields_descriptions = '["Community","Destination&#x20
UPDATE talert_commands SET fields_descriptions = '["Log&#x20;Info&#x20;1","Log&#x20;Info&#x20;2","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 6; UPDATE talert_commands SET fields_descriptions = '["Log&#x20;Info&#x20;1","Log&#x20;Info&#x20;2","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 6;
UPDATE talert_commands SET fields_descriptions = '["Destination&#x20;number","Message","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 9; UPDATE talert_commands SET fields_descriptions = '["Destination&#x20;number","Message","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 9;
UPDATE talert_commands SET fields_descriptions = '["Agent&#x20;name","Module&#x20;name","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 10; UPDATE talert_commands SET fields_descriptions = '["Agent&#x20;name","Module&#x20;name","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 10;
-- ---------------------------------------------------------------------
-- Update the data of unknown modules to new fields (11/3/13)
-- ---------------------------------------------------------------------
UPDATE tagente_estado SET last_known_status = last_status, last_status = 3 WHERE estado = 3;

View File

@ -1114,3 +1114,9 @@ UPDATE talert_commands SET fields_descriptions = '["Community","Destination&#x20
UPDATE talert_commands SET fields_descriptions = '["Log&#x20;Info&#x20;1","Log&#x20;Info&#x20;2","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 6; UPDATE talert_commands SET fields_descriptions = '["Log&#x20;Info&#x20;1","Log&#x20;Info&#x20;2","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 6;
UPDATE talert_commands SET fields_descriptions = '["Destination&#x20;number","Message","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 9; UPDATE talert_commands SET fields_descriptions = '["Destination&#x20;number","Message","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 9;
UPDATE talert_commands SET fields_descriptions = '["Agent&#x20;name","Module&#x20;name","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 10; UPDATE talert_commands SET fields_descriptions = '["Agent&#x20;name","Module&#x20;name","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 10;
-- ---------------------------------------------------------------------
-- Update the data of unknown modules to new fields (11/3/13)
-- ---------------------------------------------------------------------
UPDATE tagente_estado SET last_known_status = last_status, last_status = 3 WHERE estado = 3;

View File

@ -1104,3 +1104,9 @@ UPDATE "talert_commands" SET "fields_descriptions" = '["Community","Destination&
UPDATE "talert_commands" SET "fields_descriptions" = '["Log&#x20;Info&#x20;1","Log&#x20;Info&#x20;2","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 6; UPDATE "talert_commands" SET "fields_descriptions" = '["Log&#x20;Info&#x20;1","Log&#x20;Info&#x20;2","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 6;
UPDATE "talert_commands" SET "fields_descriptions" = '["Destination&#x20;number","Message","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 9; UPDATE "talert_commands" SET "fields_descriptions" = '["Destination&#x20;number","Message","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 9;
UPDATE "talert_commands" SET "fields_descriptions" = '["Agent&#x20;name","Module&#x20;name","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 10; UPDATE "talert_commands" SET "fields_descriptions" = '["Agent&#x20;name","Module&#x20;name","","","","","","","",""]', fields_values = '["","","","","","","","","",""]' WHERE id = 10;
-- ---------------------------------------------------------------------
-- Update the data of unknown modules to new fields (11/3/13)
-- ---------------------------------------------------------------------
UPDATE tagente_estado SET last_known_status = last_status, last_status = 3 WHERE estado = 3;

View File

@ -1397,10 +1397,16 @@ function graph_agent_status ($id_agent = false, $width = 300, $height = 200, $re
$fields[] = 'SUM(notinit_count) "Not init"'; $fields[] = 'SUM(notinit_count) "Not init"';
} }
$agent_status = db_get_all_rows_filter('tagente', $filter, $fields); $data = db_get_row_filter('tagente', $filter, $fields);
$data = reset($agent_status); // If any value is negative, truncate it to 0
function truncate_negatives(&$element) {
if($element < 0) {
$element = 0;
}
}
array_walk($data, 'truncate_negatives');
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png", $water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("/images/logo_vertical_water.png")); 'url' => ui_get_full_url("/images/logo_vertical_water.png"));

View File

@ -868,7 +868,9 @@ function groups_agent_not_init ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count=0 AND notinit_count>0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count=0 AND notinit_count>0 AND id_grupo IN $group_clause");
return $count > 0 ? $count : 0;
} }
@ -886,7 +888,9 @@ function groups_agent_unknown ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count=0 AND unknown_count>0 AND id_grupo IN $group_clause");
return $count > 0 ? $count : 0;
} }
// Get ok agents by using the status code in modules. // Get ok agents by using the status code in modules.
@ -904,7 +908,9 @@ function groups_agent_ok ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND normal_count=total_count AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND normal_count=total_count AND id_grupo IN $group_clause");
return $count > 0 ? $count : 0;
} }
// Get critical agents by using the status code in modules. // Get critical agents by using the status code in modules.
@ -923,8 +929,9 @@ function groups_agent_critical ($group_array) {
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count>0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count>0 AND id_grupo IN $group_clause");
return $count > 0 ? $count : 0;
} }
// Get warning agents by using the status code in modules. // Get warning agents by using the status code in modules.
@ -942,7 +949,9 @@ function groups_agent_warning ($group_array) {
$group_clause = implode (",", $group_array); $group_clause = implode (",", $group_array);
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count>0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT COUNT(*) FROM tagente WHERE tagente.disabled=0 AND critical_count=0 AND warning_count>0 AND id_grupo IN $group_clause");
return $count > 0 ? $count : 0;
} }
@ -964,7 +973,9 @@ function groups_monitor_not_init ($group_array) {
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT SUM(notinit_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
return $count > 0 ? $count : 0;
} }
// Get monitor OK, except disabled and non-init // Get monitor OK, except disabled and non-init
@ -985,7 +996,9 @@ function groups_monitor_ok ($group_array) {
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT SUM(normal_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT SUM(normal_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
return $count > 0 ? $count : 0;
} }
// Get monitor CRITICAL, except disabled and non-init // Get monitor CRITICAL, except disabled and non-init
@ -1006,7 +1019,9 @@ function groups_monitor_critical ($group_array) {
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT SUM(critical_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT SUM(critical_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
return $count > 0 ? $count : 0;
} }
// Get monitor WARNING, except disabled and non-init // Get monitor WARNING, except disabled and non-init
@ -1027,7 +1042,9 @@ function groups_monitor_warning ($group_array) {
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT SUM(warning_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
return $count > 0 ? $count : 0;
} }
// Get monitor UNKNOWN, except disabled and non-init // Get monitor UNKNOWN, except disabled and non-init
@ -1048,7 +1065,9 @@ function groups_monitor_unknown ($group_array) {
$group_clause = "(" . $group_clause . ")"; $group_clause = "(" . $group_clause . ")";
//TODO REVIEW ORACLE AND POSTGRES //TODO REVIEW ORACLE AND POSTGRES
return db_get_sql ("SELECT SUM(unknown_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause"); $count = db_get_sql ("SELECT SUM(unknown_count) FROM tagente WHERE disabled = 0 AND id_grupo IN $group_clause");
return $count > 0 ? $count : 0;
} }
// Get alerts defined for a given group, except disabled // Get alerts defined for a given group, except disabled
@ -1162,7 +1181,6 @@ function groups_agent_disabled ($group_array) {
$sql = "SELECT COUNT(*) FROM tagente WHERE id_grupo IN $group_clause AND disabled = 1"; $sql = "SELECT COUNT(*) FROM tagente WHERE id_grupo IN $group_clause AND disabled = 1";
return db_get_sql ($sql); return db_get_sql ($sql);
} }
?> ?>