From f21973589ac492aa32cf86b58410b8bd3401f4cc Mon Sep 17 00:00:00 2001 From: javilanz Date: Wed, 6 Apr 2011 11:53:54 +0000 Subject: [PATCH] 2011-04-06 Javier Lanz * include/functions_reporting.php: Added case to display 'agent_module' reports * include/functions.php: Added the option 'agent_module' for the reporting type in combo selecion * godmode/reporting/reporting_builder.php: Added options to store 'agent_module' report info * godmode/reporting/reporting_builder.item_editor.php: Added html fields for the 'agent_module' report git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4174 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 11 + .../reporting_builder.item_editor.php | 21 +- .../godmode/reporting/reporting_builder.php | 4 + pandora_console/include/functions.php | 1 + .../include/functions_reporting.php | 211 ++++++++++++++++++ 5 files changed, 247 insertions(+), 1 deletion(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9c1eb90d30..2c537ef2c2 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2011-04-06 Javier Lanz + + * include/functions_reporting.php: Added case to display 'agent_module' + reports + * include/functions.php: Added the option 'agent_module' for the + reporting type in combo selecion + * godmode/reporting/reporting_builder.php: Added options to store + 'agent_module' report info + * godmode/reporting/reporting_builder.item_editor.php: Added html fields + for the 'agent_module' report + 2011-04-06 Sergio Martin * include/graphs/pChart/pData.class.php diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 07acd31c27..5664ae37a3 100644 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -65,6 +65,7 @@ switch ($action) { $show_graph = 0; $show_in_two_columns = 0; $show_in_landscape = 0; + $modulegroup = 0; break; default: $actionParameter = 'update'; @@ -258,6 +259,12 @@ switch ($action) { $show_resume = $item['show_resume']; $show_graph = $item['show_graph']; $order_uptodown = $item['order_uptodown']; + break; + case 'agent_module': + $description = $item['description']; + $group = $item['id_group']; + $modulegroup = $item ['id_module_group']; + break; } break; @@ -331,7 +338,14 @@ print_input_hidden('id_item', $idItem); - + + + + + + + @@ -944,6 +958,7 @@ function chooseType() { $("#row_exception_condition").css('display', 'none'); $("#row_show_in_two_columns").css('display', 'none'); $("#row_show_in_landscape").css('display', 'none'); + $("#row_module_group").css('display', 'none'); switch (type) { case 'event_report_group': @@ -1154,6 +1169,10 @@ function chooseType() { $("#row_show_graph").css('display', ''); $("#row_show_in_two_columns").css('display', ''); break; + case 'agent_module': + $("#row_description").css('display', ''); + $("#row_group").css('display', ''); + $("#row_module_group").css('display', ''); } } diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index aa05447ca5..c8be4e582d 100644 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -195,6 +195,8 @@ switch ($action) { $values['exception_condition'] = get_parameter('radiobutton_exception_condition'); $values['exception_condition_value'] = get_parameter('exception_condition_value'); $values['show_graph'] = get_parameter('combo_graph_options'); + $values['id_module_group'] = get_parameter('combo_modulegroup'); + $values['id_group'] = get_parameter ('combo_group'); if (($values['type'] == 'sql') OR ($values['type'] == 'sql_graph_hbar')OR ($values['type'] == 'sql_graph_vbar') OR ($values['type'] == 'sql_graph_pie')) { $values['treport_custom_sql_id'] = get_parameter('id_custom'); @@ -248,6 +250,8 @@ switch ($action) { $values['exception_condition'] = get_parameter('radiobutton_exception_condition'); $values['exception_condition_value'] = get_parameter('exception_condition_value'); $values['show_graph'] = get_parameter('combo_graph_options'); + $values['id_module_group'] = get_parameter('combo_modulegroup'); + $values['id_group'] = get_parameter ('combo_group'); if (($values['type'] == 'sql') OR ($values['type'] == 'sql_graph_hbar')OR ($values['type'] == 'sql_graph_vbar') OR ($values['type'] == 'sql_graph_pie')) { diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 757e770af1..6c0ed6b1b6 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -659,6 +659,7 @@ function get_report_types () { $types['general'] = __('General'); $types['top_n'] = __('Top n'); $types['exception'] = __('Exception'); + $types['agent_module'] = __('Agents/Modules'); // $types['agent_detailed_event'] = __('Agent detailed event'); // $types['list_events_module'] = __('List events of module'); // $types['list_events_agent'] = __('List events of agent'); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 6c3c05cd17..e633fb9974 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -3255,6 +3255,217 @@ function render_report_html_item ($content, $table, $report, $mini = false) { array_push ($table->data, $data_resume); } break; + case 'agent_module': + $id_group = $content['id_group']; + $id_module_group = $content['id_module_group']; + $offset = get_parameter('offset', 0); + $block = 20; //Maximun number of modules displayed on the table + $modulegroup = get_parameter('modulegroup', 0); + $table->style[1] = 'text-align: right'; + $data = array (); + $data[0] = $sizh.__('Agents/Modules').$sizhfin; + $data[1] = $sizh.human_time_description_raw ($content['period']).$sizhfin; + array_push ($table->data, $data); + + // Put description at the end of the module (if exists) + $table->colspan[1][0] = 3; + if ($content["description"] != ""){ + $data_desc = array(); + $data_desc[0] = $content["description"]; + array_push ($table->data, $data_desc); + } + + $agents = ''; + if($id_group > 0) { + $agents = get_group_agents($id_group); + $agents = array_keys($agents); + } + + $filter_module_groups = false; + if($id_module_group > 0) { + $filter_module_groups['id_module_group'] = $id_module_group; + } + + $all_modules = get_agent_modules ($agents, false, $filter_module_groups, true, false); + + $modules_by_name = array(); + $name = ''; + $cont = 0; + + foreach($all_modules as $key => $module) { + if($module == $name) { + $modules_by_name[$cont-1]['id'][] = $key; + } + else { + $name = $module; + $modules_by_name[$cont]['name'] = $name; + $modules_by_name[$cont]['id'][] = $key; + $cont ++; + } + } + + if($config["pure"] == 1) { + $block = count($modules_by_name); + } + + $filter_groups = array ('offset' => (int) $offset, + 'limit' => (int) $config['block_size']); + + if($id_group > 0) { + $filter_groups['id_grupo'] = $id_group; + } + + $agents = get_agents ($filter_groups); + $nagents = count($agents); + + if($all_modules == false || $agents == false) { + $data = array (); + $table->colspan[2][0] = 3; + $data[0] = __('There are no agents with modules'); + array_push ($table->data, $data); + break; + } + $table_data = ''; + + $table_data .= ""; + + $nmodules = 0; + foreach($modules_by_name as $module) { + $nmodules++; + + if($nmodules > $block) { //Will show only the (block) first modules + continue; + } + + $file_name = string2image(printTruncateText($module['name'],15, false, true, false, '...'), 115, 13, 3, 270, '#9EAC8B', 'FFF', 4, 0); + $table_data .= '"; + } + + if ($block < $nmodules) { + $table_data .= ""; + } + + $filter_agents = false; + if($id_group > 0) { + $filter_agents = array('id_grupo' => $id_group); + } + // Prepare pagination + pagination ((int)count(get_agents ($filter_agents))); + $table_data .= "
"; + + foreach ($agents as $agent) { + // Get stats for this group + $agent_status = get_agent_status($agent['id_agente']); + + switch($agent_status) { + case 4: // Alert fired status + $rowcolor = '#ffa300'; + $textcolor = '#000'; + break; + case 1: // Critical status + $rowcolor = '#bc0000'; + $textcolor = '#FFF'; + break; + case 2: // Warning status + $rowcolor = '#f2ef00'; + $textcolor = '#000'; + break; + case 0: // Normal status + $rowcolor = '#8ae234'; + $textcolor = '#000'; + break; + case 3: + case -1: + default: // Unknown status + $rowcolor = '#babdb6'; + $textcolor = '#000'; + break; + } + + $table_data .= ""; + + $file_name = string2image(printTruncateText($agent['nombre'],19, false, true, false, '...'), 140, 15, 3, 0, $rowcolor, $textcolor, 4, 0); + $table_data .= ""; + $agent_modules = get_agent_modules($agent['id_agente']); + + $nmodules = 0; + + foreach($modules_by_name as $module) { + $nmodules++; + + if($nmodules > $block) { + continue; + } + + $match = false; + foreach($module['id'] as $module_id){ + if(!$match && array_key_exists($module_id,$agent_modules)) { + $status = get_agentmodule_status($module_id); + $table_data .= ""; + $match = true; + } + } + + if(!$match) { + $table_data .= ""; + } + } + + $table_data .= ""; + } + + $table_data .= "
".__("Agents")." / ".__("Modules")."'.print_image($file_name, true, array('title' => $module['name']))."...
".print_image($file_name, true, array('title' => $agent['nombre'])).""; + $win_handle = dechex(crc32($module_id.$module["name"])); + $graph_type = return_graphtype (get_agentmodule_type($module_id)); + + switch($status){ + case 0: + $table_data .= print_status_image ('module_ok.png', $module['name']." in ".$agent['nombre'].": ".__('NORMAL'), true, array('width' => '20px', 'height' => '20px')); + break; + case 1: + $table_data .= print_status_image ('module_critical.png', $module['name']." in ".$agent['nombre'].": ".__('CRITICAL'), true, array('width' => '20px', 'height' => '20px')); + break; + case 2: + $table_data .= print_status_image ('module_warning.png', $module['name']." in ".$agent['nombre'].": ".__('WARNING'), true, array('width' => '20px', 'height' => '20px')); + break; + case 3: + $table_data .= print_status_image ('module_unknown.png', $module['name']." in ".$agent['nombre'].": ".__('UNKNOWN'), true, array('width' => '20px', 'height' => '20px')); + break; + case 4: + $table_data .= print_status_image ('module_alertsfired.png', $module['name']." in ".$agent['nombre'].": ".__('ALERTS FIRED'), true, array('width' => '20px', 'height' => '20px')); + break; + } + $table_data .= "
"; + + $table_data .= "

" . __("The colours meaning:") . + "

    " . + '
  • +
     
    ' . + __("Orange cell when the module has fired alerts") . + '
  • ' . + '
  • +
     
    ' . + __("Red cell when the module has a critical status") . + '
  • ' . + '
  • +
     
    ' . + __("Yellow cell when the module has a warning status") . + '
  • ' . + '
  • +
     
    ' . + __("Green cell when the module has a normal status") . + '
  • ' . + '
  • +
     
    ' . + __("Grey cell when the module has an unknown status") . + '
  • ' . + "
" . + "

"; + $data = array (); + $table->colspan[2][0] = 3; + $data[0] = $table_data; + array_push ($table->data, $data); + break; } }