From f8264cf15342d0eb92cc643f1c71707ba903565a Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Tue, 24 Aug 2010 15:40:19 +0000 Subject: [PATCH] 2010-08-24 Sergio Martin * extensions/agents_modules.php: Improved the agents/modules matrix adding new filters, full screen mode, autorefresh selection and links in the agents names and status squares. For bug: 3051073 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3178 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 ++ pandora_console/extensions/agents_modules.php | 92 ++++++++++++++----- 2 files changed, 77 insertions(+), 22 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index f90e9558c9..b072c15082 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2010-08-24 Sergio Martin + + * extensions/agents_modules.php: Improved the agents/modules + matrix adding new filters, full screen mode, autorefresh + selection and links in the agents names and status squares. + For bug: 3051073 + 2010-08-24 Sergio Martin * extensions/agents_modules.php diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 916fceac87..7610a4646e 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -44,40 +44,78 @@ function mainAgentsModules() { if ($config["realtimestats"] == 0){ - $updated_time = __('Last update'). " : ". print_timestamp (get_db_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true); + $updated_info = __('Last update'). " : ". print_timestamp (get_db_sql ("SELECT min(utimestamp) FROM tgroup_stat"), true); } else { - $updated_time = __("Updated at realtime"); + $updated_info = __("Updated at realtime"); } + $updated_time = print_image ("images/information.png", true, array ("title" => $updated_info, "style" => 'margin: 5px 3px 0px 10px')).$updated_info; + + $modulegroup = get_parameter('modulegroup', 0); + $refr = get_parameter('refr', 30); // By default 30 seconds + $group_id = get_parameter('group_id', 0); $offset = get_parameter('offset', 0); $hor_offset = get_parameter('hor_offset', 0); $block = 20; + $groups = get_user_groups (); + + $filter_module_groups = '
'; + $filter_module_groups .= ''.__('Module group').''; + $filter_module_groups .= print_select_from_sql ("SELECT * FROM tmodule_group ORDER BY name", + 'modulegroup', $modulegroup, 'this.form.submit()',__('All'), 0, true, false, true, false, 'width: 100px; margin-right: 10px; margin-top: 5px;'); + $filter_module_groups .= '
'; + + $filter_groups = '
'; + $filter_groups .= ''.__('Group').''; + $filter_groups .= print_select_groups(false, "AR", true, 'group_id', $group_id, 'this.form.submit()', '', '', true, false, true, '', false , 'width: 100px; margin-right: 10px;; margin-top: 5px;'); + $filter_groups .= '
'; + + $comborefr = '
'; + $comborefr .= ''.__('Refresh').''; + $comborefr .= print_select (array('30' => '30 '.__('seconds'), '60' => '1 '.__('minute'), '120' => '2 '.__('minutes'), '300' => '5 '.__('minutes'), '600' => '10 '.__('minutes')) , 'refr', $config['refr'], $script = 'this.form.submit()', '', 0, true, false, false, '', false, 'width: 100px; margin-right: 10px; margin-top: 5px;'); + $comborefr .= "
"; + + if ($config["pure"] == 0) { + $fullscreen = '' + . print_image ("images/fullscreen.png", true, array ("title" => __('Full screen mode'))) + . ""; + } else { + $fullscreen = '' + . print_image ("images/normalscreen.png", true, array ("title" => __('Back to normal mode'))) + . ""; + $config['refr'] = $refr; + } + + $onheader = array('updated_time' => $updated_time, 'fullscreen' => $fullscreen, + 'combo_module_groups' => $filter_module_groups, + 'combo_groups' => $filter_groups); + + if($config['pure'] == 1) { + $onheader['combo_refr'] = $comborefr; + } + // Header - print_page_header (__("Agents/Modules"), "images/bricks.png", false, "", false, $updated_time ); + print_page_header (__("Agents/Modules"), "images/bricks.png", false, "", false, $onheader); // Old style table, we need a lot of special formatting,don't use table function // Prepare old-style table - echo '
'; - - echo ''; - echo '
'.__('Group').': '; - - $groups = get_user_groups (); - print_select_groups(false, "AR", true, 'group_id', $group_id, 'this.form.submit()', '', ''); - - echo ' 
'; - $agents = ''; if($group_id > 0) { $agents = get_group_agents($group_id); $agents = array_keys($agents); } - $all_modules = get_agent_modules($agents, false, false, true, false); + $filter_module_groups = false; + if($modulegroup > 0) { + $filter_module_groups['id_module_group'] = $modulegroup; + } + + $all_modules = get_agent_modules($agents, false, $filter_module_groups, true, false); + $modules_by_name = array(); $name = ''; $cont = 0; @@ -93,6 +131,10 @@ function mainAgentsModules() { $cont ++; } } + + if($config["pure"] == 1) { + $block = count($modules_by_name); + } $filter_groups = array ('offset' => (int) $offset, 'limit' => (int) $config['block_size']); @@ -100,11 +142,11 @@ function mainAgentsModules() { if($group_id > 0) { $filter_groups['id_grupo'] = $group_id; } - + $agents = get_agents ($filter_groups); $nagents = count($agents); - if($all_modules === false || $agents === false) { + if($all_modules == false || $agents == false) { echo "
".__('There are no agents with modules')."
"; return; } @@ -115,7 +157,7 @@ function mainAgentsModules() { if($hor_offset > 0) { $new_hor_offset = $hor_offset-$block; - echo "".print_image("images/darrowleft.png",true, array('title' => __('Previous modules')))." "; + echo "".print_image("images/darrowleft.png",true, array('title' => __('Previous modules')))." "; } $nmodules = 0; foreach($modules_by_name as $module) { @@ -124,13 +166,14 @@ function mainAgentsModules() { if($nmodules <= $hor_offset || $nmodules > ($hor_offset+$block)) { continue; } + $file_name = string2image(printTruncateText($module['name'],15, false, true, false, '...'), 115, 13, 3, 270, '#9EAC8B', 'FFF', 4, 0); - echo "".print_image($file_name, true, array('title' => $module['name'])).""; + echo ''.print_image($file_name, true, array('title' => $module['name'])).""; } if(($hor_offset + $block) < $nmodules) { $new_hor_offset = $hor_offset+$block; - echo "".print_image("images/darrowright.png",true, array('title' => __('More modules')))." "; + echo "".print_image("images/darrowright.png",true, array('title' => __('More modules')))." "; } $filter_agents = false; @@ -173,7 +216,7 @@ function mainAgentsModules() { echo ""; $file_name = string2image(printTruncateText($agent['nombre'],17, false, true, false, '...'), 140, 15, 3, 0, $rowcolor, $textcolor, 4, 0); - echo "".print_image($file_name, true, array('title' => $agent['nombre'])).""; + echo "".print_image($file_name, true, array('title' => $agent['nombre'])).""; $agent_modules = get_agent_modules($agent['id_agente']); $nmodules = 0; @@ -186,11 +229,15 @@ function mainAgentsModules() { } $match = false; - foreach($module['id'] as $module_id){ if(!$match && array_key_exists($module_id,$agent_modules)) { $status = get_agentmodule_status($module_id); echo ""; + $win_handle = dechex(crc32($module_id.$module["name"])); + $graph_type = return_graphtype (get_agentmodule_type($module_id)); + $link ="winopeng('operation/agentes/stat_win.php?type=$graph_type&period=86400&id=".$module_id."&label=".$module["name"]."&refresh=600','day_".$win_handle."')"; + + echo ''; switch($status){ case 0: print_status_image ('module_ok.png', $module['name']." in ".$agent['nombre'].": ".__('NORMAL'), false, array('width' => '20px', 'height' => '20px')); @@ -208,11 +255,12 @@ function mainAgentsModules() { print_status_image ('module_alertsfired.png', $module['name']." in ".$agent['nombre'].": ".__('ALERTS FIRED'), false, array('width' => '20px', 'height' => '20px')); break; } + echo ''; echo ""; $match = true; } } - + if(!$match) { echo ""; }