From 6c37935339afd8c8942b956e159b71db6d1a0707 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Tue, 10 Jul 2012 11:37:14 +0000 Subject: [PATCH] 2012-07-10 Miguel de Dios * include/functions_ui.php: moved the constants for the status images to contants file. * include/constants.php: added the contants for the "Agent module status" and added contants for the "Status images" from functions_ui.php. * include/functions_modules.php: killed a unicorn (magic number) into the function "modules_get_agentmodule_status". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6761 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 12 +++++++ pandora_console/include/constants.php | 32 +++++++++++++++++++ pandora_console/include/functions_modules.php | 2 +- pandora_console/include/functions_ui.php | 31 ++++-------------- 4 files changed, 51 insertions(+), 26 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index fb2cb7e972..79f4bb398a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,15 @@ +2012-07-10 Miguel de Dios + + * include/functions_ui.php: moved the constants for the status + images to contants file. + + * include/constants.php: added the contants for the + "Agent module status" and added contants for the "Status images" + from functions_ui.php. + + * include/functions_modules.php: killed a unicorn (magic number) + into the function "modules_get_agentmodule_status". + 2012-07-10 Miguel de Dios * include/functions_networkmap.php, include/functions_netflow.php, diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 3881829752..bf171e5637 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -109,6 +109,15 @@ define('GENERIC_SIZE_TEXT', 25); +/* Agent module status */ +define('AGENT_MODULE_STATUS_CRITICAL_BAD', 1); +define('AGENT_MODULE_STATUS_CRITICAL_ALERT', 4); +define('AGENT_MODULE_STATUS_NORMAL', 0); +define('AGENT_MODULE_STATUS_WARNING', 2); +define('AGENT_MODULE_STATUS_UNKNOW', 3); + + + /* Visual maps contants */ //The items kind define('STATIC_GRAPH', 0); @@ -146,4 +155,27 @@ define('SERVICE_STATUS_UNKNOW', -1); define('SERVICE_STATUS_NORMAL', 0); define('SERVICE_STATUS_CRITICAL', 1); define('SERVICE_STATUS_WARNING', 2); + + + +/* Status images */ +//For modules +define ('STATUS_MODULE_OK', 'module_ok.png'); +define ('STATUS_MODULE_CRITICAL', 'module_critical.png'); +define ('STATUS_MODULE_WARNING', 'module_warning.png'); +define ('STATUS_MODULE_NO_DATA', 'module_no_data.png'); +define ('STATUS_MODULE_UNKNOWN', 'module_unknown.png'); +//For agents +define ('STATUS_AGENT_CRITICAL', 'agent_critical.png'); +define ('STATUS_AGENT_WARNING', 'agent_warning.png'); +define ('STATUS_AGENT_DOWN', 'agent_down.png'); +define ('STATUS_AGENT_OK', 'agent_ok.png'); +define ('STATUS_AGENT_NO_DATA', 'agent_no_data.png'); +//For alerts +define ('STATUS_ALERT_FIRED', 'alert_fired.png'); +define ('STATUS_ALERT_NOT_FIRED', 'alert_not_fired.png'); +define ('STATUS_ALERT_DISABLED', 'alert_disabled.png'); +//For servers +define ('STATUS_SERVER_OK', 'server_ok.png'); +define ('STATUS_SERVER_DOWN', 'server_down.png'); ?> \ No newline at end of file diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index c0d5866087..4f737041b5 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -1006,7 +1006,7 @@ function modules_get_agentmodule_status($id_agentmodule = 0, $without_alerts = f if (!$without_alerts) { $times_fired = db_get_value ('SUM(times_fired)', 'talert_template_modules', 'id_agent_module', $id_agentmodule); if ($times_fired > 0) { - return 4; // Alert fired + return AGENT_MODULE_STATUS_CRITICAL_ALERT; // Alert fired } } diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 21b7be3ba6..034fb226ca 100644 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1644,41 +1644,22 @@ function ui_format_filesize ($bytes) { */ function ui_get_status_images_path () { global $config; - + $imageset = $config["status_images_set"]; - + if (strpos ($imageset, ",") === false) $imageset .= ",40x18"; list ($imageset, $sizes) = preg_split ("/\,/", $imageset); - + if (strpos ($sizes, "x") === false) $sizes .= "x18"; list ($imagewidth, $imageheight) = preg_split ("/x/", $sizes); - + $imagespath = 'images/status_sets/'.$imageset; - + return array ($imagespath); } -define ('STATUS_MODULE_OK', 'module_ok.png'); -define ('STATUS_MODULE_CRITICAL', 'module_critical.png'); -define ('STATUS_MODULE_WARNING', 'module_warning.png'); -define ('STATUS_MODULE_NO_DATA', 'module_no_data.png'); -define ('STATUS_MODULE_UNKNOWN', 'module_unknown.png'); - -define ('STATUS_AGENT_CRITICAL', 'agent_critical.png'); -define ('STATUS_AGENT_WARNING', 'agent_warning.png'); -define ('STATUS_AGENT_DOWN', 'agent_down.png'); -define ('STATUS_AGENT_OK', 'agent_ok.png'); -define ('STATUS_AGENT_NO_DATA', 'agent_no_data.png'); - -define ('STATUS_ALERT_FIRED', 'alert_fired.png'); -define ('STATUS_ALERT_NOT_FIRED', 'alert_not_fired.png'); -define ('STATUS_ALERT_DISABLED', 'alert_disabled.png'); - -define ('STATUS_SERVER_OK', 'server_ok.png'); -define ('STATUS_SERVER_DOWN', 'server_down.png'); - /** * Prints an image representing a status. * @@ -1712,7 +1693,7 @@ function ui_print_ui_agents_list ($options = false, $filter = false, $return = f global $config; $output = ''; - + $group_filter = true; $text_filter = true; $access = 'AR';