2011-04-06 Javier Lanz <javier.lanz@artica.es>
* 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
This commit is contained in:
parent
4e6ca06a74
commit
f21973589a
|
@ -1,3 +1,14 @@
|
|||
2011-04-06 Javier Lanz <javier.lanz@artica.es>
|
||||
|
||||
* 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 <sergio.martin@artica.es>
|
||||
|
||||
* include/graphs/pChart/pData.class.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);
|
|||
<tr id="row_group" style="" class="datos">
|
||||
<td style="vertical-align: top;"><?php echo __('Group');?></td>
|
||||
<td style="">
|
||||
<?php print_select_groups($config['id_user'], "AR", true, 'combo_group', '', 'extract_group_agents()');?>
|
||||
<?php print_select_groups($config['id_user'], "AR", true, 'combo_group', $group, 'extract_group_agents()');?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row_module_group" style="" class="datos">
|
||||
<td style="vertical-align: top;"><?php echo __('Module group');?></td>
|
||||
<td style="">
|
||||
<?php print_select_from_sql ("SELECT * FROM tmodule_group ORDER BY name",
|
||||
'combo_modulegroup', $modulegroup, '',__('All'));?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row_agent" style="" class="datos">
|
||||
|
@ -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', '');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -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')) {
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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 cellpadding="1" cellspacing="4" cellspacing="0" border="0" style="background-color: #EEE;">';
|
||||
|
||||
$table_data .= "<th width='140px' style='background-color: #799E48;'>".__("Agents")." / ".__("Modules")."</th>";
|
||||
|
||||
$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 .= '<th width="22px">'.print_image($file_name, true, array('title' => $module['name']))."</th>";
|
||||
}
|
||||
|
||||
if ($block < $nmodules) {
|
||||
$table_data .= "<th width='20px' style='vertical-align:top; padding-top: 35px;' rowspan='".($nagents+1)."'><b>...</b></th>";
|
||||
}
|
||||
|
||||
$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 .= "<br>";
|
||||
|
||||
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 .= "<tr style='height: 35px;'>";
|
||||
|
||||
$file_name = string2image(printTruncateText($agent['nombre'],19, false, true, false, '...'), 140, 15, 3, 0, $rowcolor, $textcolor, 4, 0);
|
||||
$table_data .= "<td style='background-color: ".$rowcolor.";'>".print_image($file_name, true, array('title' => $agent['nombre']))."</td>";
|
||||
$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 .= "<td style='text-align: center; background-color: #DDD;'>";
|
||||
$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 .= "</td>";
|
||||
$match = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$match) {
|
||||
$table_data .= "<td style='background-color: #DDD;'></td>";
|
||||
}
|
||||
}
|
||||
|
||||
$table_data .= "</tr>";
|
||||
}
|
||||
|
||||
$table_data .= "</table>";
|
||||
|
||||
$table_data .= "<br><br><p>" . __("The colours meaning:") .
|
||||
"<ul style='float: left;'>" .
|
||||
'<li style="clear: both;">
|
||||
<div style="float: left; background: #ffa300; height: 14px; width: 26px;margin-right: 5px; margin-bottom: 5px;"> </div>' .
|
||||
__("Orange cell when the module has fired alerts") .
|
||||
'</li>' .
|
||||
'<li style="clear: both;">
|
||||
<div style="float: left; background: #cc0000; height: 14px; width: 26px;margin-right: 5px; margin-bottom: 5px;"> </div>' .
|
||||
__("Red cell when the module has a critical status") .
|
||||
'</li>' .
|
||||
'<li style="clear: both;">
|
||||
<div style="float: left; background: #fce94f; height: 14px; width: 26px;margin-right: 5px; margin-bottom: 5px;"> </div>' .
|
||||
__("Yellow cell when the module has a warning status") .
|
||||
'</li>' .
|
||||
'<li style="clear: both;">
|
||||
<div style="float: left; background: #8ae234; height: 14px; width: 26px;margin-right: 5px; margin-bottom: 5px;"> </div>' .
|
||||
__("Green cell when the module has a normal status") .
|
||||
'</li>' .
|
||||
'<li style="clear: both;">
|
||||
<div style="float: left; background: #babdb6; height: 14px; width: 26px;margin-right: 5px; margin-bottom: 5px;"> </div>' .
|
||||
__("Grey cell when the module has an unknown status") .
|
||||
'</li>' .
|
||||
"</ul>" .
|
||||
"</p>";
|
||||
$data = array ();
|
||||
$table->colspan[2][0] = 3;
|
||||
$data[0] = $table_data;
|
||||
array_push ($table->data, $data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue