mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Merge from the pandora_5.1 branch to feature/#1978-REESCRITURA_DEL_MOTOR_DE_INFORMES branch the new report items (availability and time overlaped in the simple graphs).
This commit is contained in:
parent
62c7ac463d
commit
f84863540f
@ -227,6 +227,7 @@ config_check();
|
||||
}
|
||||
|
||||
$table->data[0][3] = $maintenance_img;
|
||||
|
||||
// Main help icon
|
||||
$table->data[0][4] = ui_print_help_icon ("main_help", true, '', 'images/header_help.png');
|
||||
|
||||
|
@ -139,6 +139,7 @@ if (!$own_info['is_admin'] && !check_acl ($config['id_user'], 0, "PM"))
|
||||
else
|
||||
$return_all_group = true;
|
||||
html_print_select_groups(false, "AR", $return_all_group, "ag_group", $ag_group, 'this.form.submit();', '', 0, false, false, true, '', false, 'width:100px;');
|
||||
|
||||
echo "<td>";
|
||||
echo __('Show Agents') . ' ';
|
||||
$fields = array(
|
||||
@ -406,6 +407,7 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$agents = db_get_all_rows_sql ($sql);
|
||||
|
||||
// Delete rnum row generated by oracle_recode_query() function
|
||||
|
@ -132,6 +132,7 @@ if (!empty($result)) {
|
||||
$iterator++;
|
||||
|
||||
$data = array ();
|
||||
|
||||
if(defined('METACONSOLE')){
|
||||
$data[0] = "<a href='index.php?sec=advanced&sec2=godmode/category/edit_category&action=update&id_category=" . $category["id"] . "&pure=" . (int)$config['pure'] . "'>" . $category["name"] . "</a>";
|
||||
$data[1] = "<a href='index.php?sec=advanced&sec2=godmode/category/edit_category&action=update&id_category=".$category["id"] . "&pure=" . (int)$config['pure'] . "'>" . html_print_image("images/config.png", true, array("title" => "Edit")) . "</a> ";
|
||||
|
@ -28,6 +28,7 @@ if (! check_acl($config['id_user'], 0, "EW")) {
|
||||
$update = get_parameter('upd_button', '');
|
||||
$default = (int) get_parameter('default', 0);
|
||||
|
||||
|
||||
if ($default != 0) {
|
||||
$event_fields = io_safe_input('evento,id_agente,estado,timestamp');
|
||||
$fields_selected = explode (',', $event_fields);
|
||||
|
@ -157,6 +157,7 @@ $table->class = "databox";
|
||||
$table->style[0] = 'vertical-align: top;';
|
||||
|
||||
$table->valign[1] = 'top';
|
||||
|
||||
if (defined('METACONSOLE')) {
|
||||
$table->width = '100%';
|
||||
$table->border = 0;
|
||||
|
@ -58,6 +58,7 @@ $group = 0;
|
||||
$group_by_agent = 0;
|
||||
$order_uptodown = 0;
|
||||
$show_resume = 0;
|
||||
$show_address_agent = 0;
|
||||
$top_n = 0;
|
||||
$top_n_value = 10;
|
||||
$exception_condition = REPORT_EXCEPTION_CONDITION_EVERYTHING;
|
||||
@ -87,6 +88,7 @@ $inventory_modules = array();
|
||||
$date = null;
|
||||
// Only avg is selected by default for the simple graphs
|
||||
$only_avg = true;
|
||||
$time_compare_overlapped = false;
|
||||
|
||||
//Added for events items
|
||||
$filter_event_validated = false;
|
||||
@ -187,6 +189,9 @@ switch ($action) {
|
||||
$projection_period = $item['top_n_value'];
|
||||
$period_pg = $item['period'];
|
||||
}
|
||||
|
||||
// HACK it is saved in show_graph field.
|
||||
$time_compare_overlapped = $item['show_graph'];
|
||||
break;
|
||||
case 'prediction_date':
|
||||
$description = $item['description'];
|
||||
@ -419,7 +424,15 @@ switch ($action) {
|
||||
$period = $item['period'];
|
||||
$order_uptodown = $item['order_uptodown'];
|
||||
$show_resume = $item['show_resume'];
|
||||
$show_graph = $item['show_graph'];
|
||||
break;
|
||||
case 'availability':
|
||||
$description = $item['description'];
|
||||
$period = $item['period'];
|
||||
$order_uptodown = $item['order_uptodown'];
|
||||
$show_resume = $item['show_resume'];
|
||||
// HACK it is saved in show_graph field.
|
||||
// Show interfaces instead the modules
|
||||
$show_address_agent = $item['show_graph'];
|
||||
break;
|
||||
case 'group_report':
|
||||
$description = $item['description'];
|
||||
@ -498,7 +511,8 @@ switch ($action) {
|
||||
break;
|
||||
}
|
||||
|
||||
$urlForm = $config['homeurl'] . 'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action=' . $actionParameter . '&id_report=' . $idReport;
|
||||
$urlForm = $config['homeurl'] .
|
||||
'index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=item_editor&action=' . $actionParameter . '&id_report=' . $idReport;
|
||||
|
||||
echo '<form action="' . $urlForm . '" method="post">';
|
||||
html_print_input_hidden('id_item', $idItem);
|
||||
@ -552,8 +566,8 @@ else
|
||||
</tr>
|
||||
<tr id="row_netflow_filter" style="" class="datos">
|
||||
<td><?php echo __('Filter');?></td>
|
||||
<td><?php
|
||||
|
||||
<td>
|
||||
<?php
|
||||
$own_info = get_user_info ($config['id_user']);
|
||||
|
||||
// Get group list that user has access
|
||||
@ -1039,6 +1053,14 @@ else
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row_time_compare_overlapped" style="" class="datos">
|
||||
<td><?php echo __('Time compare (Overlapped)');?></td>
|
||||
<td>
|
||||
<?php
|
||||
html_print_checkbox('time_compare_overlapped', 1, $time_compare_overlapped);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row_only_avg" style="" class="datos">
|
||||
<td><?php echo __('Only average');?></td>
|
||||
<td><?php html_print_checkbox('only_avg', 1, $only_avg);?></td>
|
||||
@ -1080,9 +1102,28 @@ else
|
||||
<td><?php html_print_select ($show_graph_options, 'combo_graph_options', $show_graph);?></td>
|
||||
|
||||
</tr>
|
||||
<tr id="row_show_address_agent" style="" class="datos">
|
||||
<td>
|
||||
<?php
|
||||
echo __('Show address instead module name.') .
|
||||
ui_print_help_tip(__('Show the main address of agent.'), true);
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
html_print_checkbox('checkbox_show_address_agent', 1,
|
||||
$show_address_agent);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row_show_resume" style="" class="datos">
|
||||
<td><?php echo __('Show resume') . ui_print_help_tip(__('Show a resume table with max, min, average of total modules on the report bottom'), true);?></td>
|
||||
<td><?php html_print_checkbox('checkbox_show_resume', 1, $show_resume);?></td>
|
||||
<td>
|
||||
<?php
|
||||
html_print_checkbox('checkbox_show_resume', 1,
|
||||
$show_resume);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row_event_filter" style="" class="datos">
|
||||
<td><?php echo __('Event filter'); ?></td>
|
||||
@ -1144,7 +1185,7 @@ else
|
||||
<br />
|
||||
<?php
|
||||
print_SLA_list('95%', $action, $idItem);
|
||||
print_General_list('95%', $action, $idItem);
|
||||
print_General_list('95%', $action, $idItem, $type);
|
||||
echo '<div class="action-buttons" style="width: 100%">';
|
||||
if ($action == 'new') {
|
||||
html_print_submit_button(__('Create item'), 'create_item', false, 'class="sub wand"');
|
||||
@ -1170,7 +1211,8 @@ function print_SLA_list($width, $action, $idItem = null) {
|
||||
global $config;
|
||||
global $meta;
|
||||
|
||||
$report_item_type = db_get_value ('type', 'treport_content', 'id_rc', $idItem);
|
||||
$report_item_type = db_get_value('type', 'treport_content', 'id_rc',
|
||||
$idItem);
|
||||
?>
|
||||
<table class="databox" id="sla_list" border="0" cellpadding="4" cellspacing="4" width="100%">
|
||||
<thead>
|
||||
@ -1322,9 +1364,10 @@ function print_SLA_list($width, $action, $idItem = null) {
|
||||
<?php
|
||||
}
|
||||
|
||||
function print_General_list($width, $action, $idItem = null) {
|
||||
function print_General_list($width, $action, $idItem = null, $type = 'general') {
|
||||
global $config;
|
||||
global $meta;
|
||||
|
||||
if (!isset($meta))
|
||||
$meta = false;
|
||||
|
||||
@ -1339,11 +1382,24 @@ function print_General_list($width, $action, $idItem = null) {
|
||||
<table class="databox" id="general_list" border="0" cellpadding="4" cellspacing="4" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php
|
||||
if ($type == "availability") {
|
||||
?>
|
||||
<th class="header" scope="col"><?php echo __('Agent');?></th>
|
||||
<th class="header" scope="col"><?php echo __('Module');?></th>
|
||||
<th class="header" scope="col"><?php echo __('Action');?></th>
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<th class="header" scope="col"><?php echo __('Agent');?></th>
|
||||
<th class="header" scope="col"><?php echo __('Module');?></th>
|
||||
<th class="header" scope="col"><?php echo __('Operation') .
|
||||
ui_print_help_tip(__("Please be careful, when the module have diferent intervals in their life, the summatory maybe get bad result."), true);?></th>
|
||||
<th class="header" scope="col"><?php echo __('Action');?></th>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
</thead>
|
||||
<?php
|
||||
@ -1359,10 +1415,13 @@ function print_General_list($width, $action, $idItem = null) {
|
||||
case 'update':
|
||||
case 'edit':
|
||||
echo '<tbody id="list_general">';
|
||||
$itemsGeneral = db_get_all_rows_filter('treport_content_item', array('id_report_content' => $idItem));
|
||||
$itemsGeneral = db_get_all_rows_filter(
|
||||
'treport_content_item',
|
||||
array('id_report_content' => $idItem));
|
||||
if ($itemsGeneral === false) {
|
||||
$itemsGeneral = array();
|
||||
}
|
||||
|
||||
foreach ($itemsGeneral as $item) {
|
||||
$server_name = $item ['server_name'];
|
||||
// Metaconsole db connection
|
||||
@ -1373,7 +1432,10 @@ function print_General_list($width, $action, $idItem = null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$idAgent = db_get_value_filter('id_agente', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module']));
|
||||
$idAgent = db_get_value_filter(
|
||||
'id_agente', 'tagente_modulo',
|
||||
array('id_agente_modulo' => $item['id_agent_module']));
|
||||
|
||||
$nameAgent = agents_get_name ($idAgent);
|
||||
$nameModule = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $item['id_agent_module']));
|
||||
|
||||
@ -1381,14 +1443,30 @@ function print_General_list($width, $action, $idItem = null) {
|
||||
if ($meta && $server_name != '')
|
||||
$server_name_element .= ' (' . $server_name . ')';
|
||||
|
||||
|
||||
if ($type == "availability") {
|
||||
echo '<tr id="general_' . $item['id'] . '" style="" class="datos">
|
||||
<td>' . printSmallFont($nameAgent) . $server_name_element . '</td>
|
||||
<td>' . printSmallFont($nameModule) . '</td>
|
||||
<td>' . printSmallFont($operation[$item['operation']]) . '</td>
|
||||
<td style="text-align: center;">
|
||||
<a href="javascript: deleteGeneralRow(' . $item['id'] . ');">' . html_print_image("images/cross.png", true) . '</a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
else {
|
||||
echo '<tr id="general_' . $item['id'] . '" style="" class="datos">
|
||||
<td>' . printSmallFont($nameAgent) . $server_name_element . '</td>
|
||||
<td>' . printSmallFont($nameModule) . '</td>
|
||||
<td>' .
|
||||
printSmallFont($operation[$item['operation']]) .
|
||||
'</td>
|
||||
<td style="text-align: center;">
|
||||
<a href="javascript: deleteGeneralRow(' . $item['id'] . ');">' . html_print_image("images/cross.png", true) . '</a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
|
||||
if ($meta) {
|
||||
//Restore db connection
|
||||
metaconsole_restore_db();
|
||||
@ -1400,7 +1478,13 @@ function print_General_list($width, $action, $idItem = null) {
|
||||
<tr id="row" style="display: none;" class="datos">
|
||||
<td class="agent_name"></td>
|
||||
<td class="module_name"></td>
|
||||
<?php
|
||||
if ($type != "availability") {
|
||||
?>
|
||||
<td class="operation_name"></td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<td style="text-align: center;"><a class="delete_button" href="javascript: deleteGeneralRow(0);"><?php html_print_image("images/cross.png", false); ?></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -1427,8 +1511,25 @@ function print_General_list($width, $action, $idItem = null) {
|
||||
ui_print_agent_autocomplete_input($params);
|
||||
?>
|
||||
</td>
|
||||
<td><select id="id_agent_module_general" name="id_agente_modulo_general" disabled="disabled" style="max-width: 180px"><option value="0"><?php echo __('Select an Agent first'); ?></option></select></td>
|
||||
<td><?php html_print_select ($operation, 'id_operation_module_general', 0, false, '', '', false, false, true, 'width: 200px', false); ?></td>
|
||||
<td>
|
||||
<select id="id_agent_module_general" name="id_agente_modulo_general" disabled="disabled" style="max-width: 180px">
|
||||
<option value="0"><?php echo __('Select an Agent first'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<?php
|
||||
if ($type !== "availability") {
|
||||
?>
|
||||
<td>
|
||||
<?php
|
||||
html_print_select($operation,
|
||||
'id_operation_module_general', 0,
|
||||
false, '', '', false, false, true,
|
||||
'width: 200px', false);
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<td style="text-align: center;"><a href="javascript: addGeneralRow();"><?php html_print_image("images/disk.png", false); ?></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -1460,7 +1561,8 @@ $(document).ready (function () {
|
||||
minuteText: '<?php echo __('Minute');?>',
|
||||
secondText: '<?php echo __('Second');?>',
|
||||
currentText: '<?php echo __('Now');?>',
|
||||
closeText: '<?php echo __('Close');?>'});
|
||||
closeText: '<?php echo __('Close');?>'
|
||||
});
|
||||
});
|
||||
|
||||
function create_custom_graph() {
|
||||
@ -1800,7 +1902,13 @@ function addGeneralRow() {
|
||||
var idAgent = $("input[name=id_agent_general]").val();
|
||||
var serverId = $("input[name=id_server]").val();
|
||||
var idModule = $("#id_agent_module_general").val();
|
||||
var operation = $("#id_operation_module_general").val();
|
||||
var operation;
|
||||
if ($("#id_operation_module_general").length) {
|
||||
operation = $("#id_operation_module_general").val();
|
||||
}
|
||||
else {
|
||||
operation = "";
|
||||
}
|
||||
var nameModule = $("#id_agent_module_general :selected").text();
|
||||
var nameOperation = $("#id_operation_module_general :selected").text();
|
||||
|
||||
@ -1835,6 +1943,7 @@ function addGeneralRow() {
|
||||
nameModule = data;
|
||||
}
|
||||
});
|
||||
|
||||
//Truncate nameOperation
|
||||
var params = [];
|
||||
params.push("truncate_text=1");
|
||||
@ -1850,6 +1959,7 @@ function addGeneralRow() {
|
||||
nameOperation = data;
|
||||
}
|
||||
});
|
||||
|
||||
var params = [];
|
||||
params.push("add_general=1");
|
||||
params.push("id=" + $("input[name=id_item]").val());
|
||||
@ -1919,9 +2029,11 @@ function chooseType() {
|
||||
$("#general_list").hide();
|
||||
$("#row_order_uptodown").hide();
|
||||
$("#row_show_resume").hide();
|
||||
$("#row_show_address_agent").hide();
|
||||
$("#row_show_graph").hide();
|
||||
$("#row_max_min_avg").hide();
|
||||
$("#row_only_avg").hide();
|
||||
$("#row_time_compare_overlapped").hide();
|
||||
$("#row_quantity").hide();
|
||||
$("#row_exception_condition_value").hide();
|
||||
$("#row_exception_condition").hide();
|
||||
@ -1965,6 +2077,7 @@ function chooseType() {
|
||||
$("#row_event_graphs").show();
|
||||
break;
|
||||
case 'simple_graph':
|
||||
$("#row_time_compare_overlapped").show();
|
||||
$("#row_only_avg").show();
|
||||
// The break hasn't be forgotten, this element
|
||||
// only should be shown on the simple graphs.
|
||||
@ -1975,6 +2088,7 @@ function chooseType() {
|
||||
$("#row_period").show();
|
||||
$("#row_show_in_two_columns").show();
|
||||
$("#row_show_in_landscape").show();
|
||||
$("#row_time_compare_overlapped").show();
|
||||
break;
|
||||
case 'projection_graph':
|
||||
$("#row_description").show();
|
||||
@ -2207,6 +2321,14 @@ function chooseType() {
|
||||
$("input[name='last_value']").prop("checked", true);
|
||||
}
|
||||
break;
|
||||
case 'availability':
|
||||
$("#row_description").show();
|
||||
$("#row_period").show();
|
||||
$("#general_list").show();
|
||||
$("#row_order_uptodown").show();
|
||||
$("#row_show_address_agent").show();
|
||||
$("#row_show_in_two_columns").show();
|
||||
break;
|
||||
case 'group_report':
|
||||
$("#row_group").show();
|
||||
$("#row_servers").show();
|
||||
|
@ -450,8 +450,14 @@ switch ($action) {
|
||||
$filter['metaconsole'] = 0;
|
||||
|
||||
$reports = reports_get_reports ($filter,
|
||||
array ('name', 'id_report', 'description', 'private',
|
||||
'id_user', 'id_group', 'non_interactive'), $return_all_group, 'RR', $group, $strict_user);
|
||||
array (
|
||||
'name',
|
||||
'id_report',
|
||||
'description',
|
||||
'private',
|
||||
'id_user',
|
||||
'id_group',
|
||||
'non_interactive'), $return_all_group, 'RR', $group, $strict_user);
|
||||
|
||||
$table->width = '0px';
|
||||
if (sizeof ($reports)) {
|
||||
@ -542,6 +548,7 @@ switch ($action) {
|
||||
$next = 7;
|
||||
}
|
||||
|
||||
|
||||
//Admin options only for RM flag
|
||||
if (check_acl ($config['id_user'], 0, "RM")) {
|
||||
|
||||
@ -753,7 +760,8 @@ switch ($action) {
|
||||
$first_page = $config['custom_report_front_firstpage'];
|
||||
$footer = $config['custom_report_front_footer'];
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
|
||||
$start_url = ui_get_full_url(false, false, false, false);
|
||||
$first_page = "<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;"><img src="" . $start_url . "/images/pandora_report_logo.png" alt="" width="800" /></p>
<p style="text-align: center;">&nbsp;</p>
<p style="text-align: center;"><span style="font-size: xx-large;">(_REPORT_NAME_)</span></p>
<p style="text-align: center;"><span style="font-size: large;">(_DATETIME_)</span></p>";
|
||||
@ -798,7 +806,8 @@ switch ($action) {
|
||||
break;
|
||||
case 'item_editor':
|
||||
$resultOperationDB = null;
|
||||
$report = db_get_row_filter('treport', array('id_report' => $idReport));
|
||||
$report = db_get_row_filter('treport',
|
||||
array('id_report' => $idReport));
|
||||
|
||||
$reportName = $report['name'];
|
||||
$idGroupReport = $report['id_group'];
|
||||
@ -871,11 +880,27 @@ switch ($action) {
|
||||
$values['top_n_value'] = get_parameter('max_values');
|
||||
$good_format = true;
|
||||
break;
|
||||
case 'availability':
|
||||
// HACK it is saved in show_graph field.
|
||||
// Show interfaces instead the modules
|
||||
$values['show_graph'] =
|
||||
get_parameter('checkbox_show_address_agent');
|
||||
$good_format = true;
|
||||
break;
|
||||
case 'simple_graph':
|
||||
case 'simple_baseline_graph':
|
||||
// HACK it is saved in show_graph field.
|
||||
$values['show_graph'] =
|
||||
(int)get_parameter('time_compare_overlapped');
|
||||
$values['period'] = get_parameter('period');
|
||||
$good_format = true;
|
||||
break;
|
||||
default:
|
||||
$values['period'] = get_parameter('period');
|
||||
$values['top_n'] = get_parameter('radiobutton_max_min_avg',0);
|
||||
$values['top_n_value'] = get_parameter('quantity');
|
||||
$values['text'] = get_parameter('text');
|
||||
$values['show_graph'] = get_parameter('combo_graph_options');
|
||||
$good_format = true;
|
||||
}
|
||||
|
||||
@ -907,7 +932,6 @@ switch ($action) {
|
||||
$values['order_uptodown'] = get_parameter ('radiobutton_order_uptodown');
|
||||
$values['exception_condition'] = (int)get_parameter('exception_condition', 0);
|
||||
$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');
|
||||
$values['server_name'] = get_parameter ('server_name');
|
||||
@ -1087,11 +1111,27 @@ switch ($action) {
|
||||
$values['top_n_value'] = get_parameter('max_values');
|
||||
$good_format = true;
|
||||
break;
|
||||
case 'availability':
|
||||
// HACK it is saved in show_graph field.
|
||||
// Show interfaces instead the modules
|
||||
$values['show_graph'] =
|
||||
get_parameter('checkbox_show_address_agent');
|
||||
$good_format = true;
|
||||
break;
|
||||
case 'simple_graph':
|
||||
case 'simple_baseline_graph':
|
||||
// HACK it is saved in show_graph field.
|
||||
$values['show_graph'] =
|
||||
(int)get_parameter('time_compare_overlapped');
|
||||
$values['period'] = get_parameter('period');
|
||||
$good_format = true;
|
||||
break;
|
||||
default:
|
||||
$values['period'] = get_parameter('period');
|
||||
$values['top_n'] = get_parameter('radiobutton_max_min_avg',0);
|
||||
$values['top_n_value'] = get_parameter('quantity');
|
||||
$values['text'] = get_parameter('text');
|
||||
$values['show_graph'] = get_parameter('combo_graph_options');
|
||||
$good_format = true;
|
||||
}
|
||||
|
||||
@ -1139,7 +1179,6 @@ switch ($action) {
|
||||
$values['order_uptodown'] = get_parameter ('radiobutton_order_uptodown',0);
|
||||
$values['exception_condition'] = (int)get_parameter('radiobutton_exception_condition', 0);
|
||||
$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');
|
||||
$values['server_name'] = get_parameter ('server_name');
|
||||
|
@ -2067,11 +2067,125 @@ function modules_change_relation_lock ($id_relation) {
|
||||
$old_value = (int) db_get_value('disable_update', 'tmodule_relationship', 'id', $id_relation);
|
||||
$new_value = $old_value === 1 ? 0 : 1;
|
||||
|
||||
$result = db_process_sql_update('tmodule_relationship',
|
||||
$result = db_process_sql_update(
|
||||
'tmodule_relationship',
|
||||
array('disable_update' => $new_value),
|
||||
array('id' => $id_relation));
|
||||
|
||||
return ($result !== false ? $new_value : $old_value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function modules_get_count_datas($id_agent_module, $date_init, $date_end) {
|
||||
$interval = modules_get_interval ($id_agent_module);
|
||||
|
||||
// TODO REMOVE THE TIME IN PLANNED DOWNTIME
|
||||
|
||||
if (!is_numeric($date_init)) {
|
||||
$date_init = strtotime($date_init);
|
||||
}
|
||||
|
||||
if (!is_numeric($date_end)) {
|
||||
$date_end = strtotime($date_end);
|
||||
}
|
||||
|
||||
$first_date = modules_get_first_contact_date($id_agent_module);
|
||||
|
||||
if ($date_init < $first_date) {
|
||||
$date_init = $first_date;
|
||||
}
|
||||
|
||||
$diff = $date_end - $date_init;
|
||||
|
||||
return ($diff / $interval);
|
||||
}
|
||||
|
||||
function modules_get_data_with_value($id_agent_module, $date_init,
|
||||
$date_end, $value, $split_interval = false) {
|
||||
|
||||
global $config;
|
||||
|
||||
// TODO REMOVE THE TIME IN PLANNED DOWNTIME
|
||||
|
||||
// TODO FOR OTHER KIND OF DATA
|
||||
|
||||
if (!is_numeric($date_init)) {
|
||||
$date_init = strtotime($date_init);
|
||||
}
|
||||
|
||||
if (!is_numeric($date_end)) {
|
||||
$date_end = strtotime($date_end);
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM tagente_datos
|
||||
WHERE
|
||||
datos = " . (int)$value . "
|
||||
AND id_agente_modulo = " . (int)$id_agent_module . "
|
||||
AND (utimestamp >= " . $date_init . " AND utimestamp <= " . $date_end . ")";
|
||||
|
||||
$data = db_get_all_rows_sql($sql,
|
||||
$config['history_db_enabled']);
|
||||
|
||||
if (empty($data)) {
|
||||
$data = array();
|
||||
}
|
||||
|
||||
if ($split_interval) {
|
||||
$temp = array();
|
||||
$previous_utimestamp = false;
|
||||
foreach ($data as $row) {
|
||||
if ($previous_utimestamp === false) {
|
||||
$previous_utimestamp = $row['utimestamp'];
|
||||
|
||||
$temp[] = $row;
|
||||
}
|
||||
else {
|
||||
$diff = $row['utimestamp'] - $previous_utimestamp;
|
||||
|
||||
$interval = modules_get_interval($id_agent_module);
|
||||
|
||||
if ($diff > $interval) {
|
||||
$fake_count = (int)($diff / $interval);
|
||||
|
||||
$fake = $row;
|
||||
for ($iterator = 1; $iterator <= $fake_count; $iterator++) {
|
||||
$fake['utimestamp'] = $previous_utimestamp + ($iterator * $interval);
|
||||
$temp[] = $fake;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$temp[] = $row;
|
||||
}
|
||||
|
||||
$previous_utimestamp = $row['utimestamp'];
|
||||
|
||||
$data = $temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function modules_get_first_contact_date($id_agent_module) {
|
||||
global $config;
|
||||
|
||||
// TODO REMOVE THE TIME IN PLANNED DOWNTIME
|
||||
|
||||
// TODO FOR OTHER KIND OF DATA
|
||||
|
||||
$sql = "
|
||||
SELECT utimestamp
|
||||
FROM tagente_datos
|
||||
WHERE id_agente_modulo = " . (int)($id_agent_module) . "
|
||||
ORDER BY utimestamp ASC
|
||||
LIMIT 1";
|
||||
|
||||
$first_date = db_get_sql($sql, 0, $config['history_db_enabled']);
|
||||
|
||||
return $first_date;
|
||||
}
|
||||
?>
|
||||
|
@ -155,6 +155,12 @@ function reporting_make_reporting_data($id_report, $date, $time,
|
||||
$report,
|
||||
$content);
|
||||
break;
|
||||
case 'availability':
|
||||
$report['contents'][] =
|
||||
reporting_availability(
|
||||
$report,
|
||||
$content);
|
||||
break;
|
||||
case 'sql':
|
||||
$report['contents'][] = reporting_sql(
|
||||
$report,
|
||||
@ -608,6 +614,232 @@ function reporting_sql($report, $content) {
|
||||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
function reporting_availability($report, $content) {
|
||||
|
||||
global $config;
|
||||
|
||||
$return = array();
|
||||
$return['type'] = 'availability';
|
||||
$return['subtype'] = $content['group_by_agent'];
|
||||
$return['resume'] = $content['show_resume'];
|
||||
|
||||
if (empty($content['name'])) {
|
||||
$content['name'] = __('Availability');
|
||||
}
|
||||
|
||||
$return['title'] = $content['name'];
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text(
|
||||
$report,
|
||||
$content);
|
||||
|
||||
if ($content['show_graph']) {
|
||||
$return['kind_availability'] = "address";
|
||||
}
|
||||
else {
|
||||
$return['kind_availability'] = "module";
|
||||
}
|
||||
|
||||
|
||||
$sql = sprintf("
|
||||
SELECT id_agent_module,
|
||||
server_name, operation
|
||||
FROM treport_content_item
|
||||
WHERE id_report_content = %d",
|
||||
$content['id_rc']);
|
||||
|
||||
$items = db_process_sql ($sql);
|
||||
|
||||
|
||||
$data = array();
|
||||
|
||||
$avg = 0;
|
||||
$min = null;
|
||||
$min_text = "";
|
||||
$max = null;
|
||||
$max_text = "";
|
||||
$count = 0;
|
||||
foreach ($items as $item) {
|
||||
//aaMetaconsole connection
|
||||
$server_name = $item ['server_name'];
|
||||
if (($config ['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
|
||||
$connection = metaconsole_get_connection($server_name);
|
||||
if (metaconsole_load_external_db($connection) != NOERR) {
|
||||
//ui_print_error_message ("Error connecting to ".$server_name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (modules_is_disable_agent($item['id_agent_module'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$row = array();
|
||||
|
||||
$text = "";
|
||||
|
||||
// HACK it is saved in show_graph field.
|
||||
// Show interfaces instead the modules
|
||||
if ($content['show_graph']) {
|
||||
$text = $row['availability_item'] = agents_get_address(
|
||||
modules_get_agentmodule_agent($item['id_agent_module']));
|
||||
|
||||
if (empty($text)) {
|
||||
$text = $row['availability_item'] = __('No Address');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$text = $row['availability_item'] = modules_get_agentmodule_name(
|
||||
$item['id_agent_module']);
|
||||
}
|
||||
$row['agent'] = modules_get_agentmodule_agent_name(
|
||||
$item['id_agent_module']);
|
||||
|
||||
$text = $row['agent'] . " (" . $text . ")";
|
||||
|
||||
$count_checks = modules_get_count_datas(
|
||||
$item['id_agent_module'],
|
||||
$report["datetime"] - $content['period'],
|
||||
$report["datetime"]);
|
||||
|
||||
|
||||
if (empty($count_checks)) {
|
||||
$row['checks'] = __('Unknown');
|
||||
$row['failed'] = __('Unknown');
|
||||
$row['fail'] = __('Unknown');
|
||||
$row['poling_time'] = __('Unknown');
|
||||
$row['time_unavaliable'] = __('Unknown');
|
||||
$row['ok'] = __('Unknown');
|
||||
|
||||
$percent_ok = 0;
|
||||
}
|
||||
else {
|
||||
$count_fails = count(
|
||||
modules_get_data_with_value(
|
||||
$item['id_agent_module'],
|
||||
$report["datetime"] - $content['period'],
|
||||
$report["datetime"],
|
||||
0, true));
|
||||
$percent_ok = (($count_checks - $count_fails) * 100) / $count_checks;
|
||||
$percent_fail = 100 - $percent_ok;
|
||||
|
||||
$row['ok'] = format_numeric($percent_ok, 2) . " %";
|
||||
$row['fail'] = format_numeric($percent_fail, 2) . " %";
|
||||
$row['checks'] = format_numeric($count_checks, 2);
|
||||
$row['failed'] = format_numeric($count_fails ,2);
|
||||
$row['poling_time'] = human_time_description_raw(
|
||||
($count_checks - $count_fails) * modules_get_interval($item['id_agent_module']),
|
||||
true);
|
||||
$row['time_unavaliable'] = "-";
|
||||
if ($count_fails > 0) {
|
||||
$row['time_unavaliable'] = human_time_description_raw(
|
||||
$count_fails * modules_get_interval($item['id_agent_module']),
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
$data[] = $row;
|
||||
|
||||
|
||||
$avg = (($avg * $count) + $percent_ok) / ($count + 1);
|
||||
if (is_null($min)) {
|
||||
$min = $percent_ok;
|
||||
$min_text = $text;
|
||||
}
|
||||
else {
|
||||
if ($min > $percent_ok) {
|
||||
$min = $percent_ok;
|
||||
$min_text = $text;
|
||||
}
|
||||
}
|
||||
if (is_null($max)) {
|
||||
$max = $percent_ok;
|
||||
$max_text = $text;
|
||||
}
|
||||
else {
|
||||
if ($max < $percent_ok) {
|
||||
$max = $percent_ok;
|
||||
$max_text = $text;
|
||||
}
|
||||
}
|
||||
|
||||
//Restore dbconnection
|
||||
if (($config ['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
||||
|
||||
switch ($content['order_uptodown']) {
|
||||
case REPORT_ITEM_ORDER_BY_AGENT_NAME:
|
||||
$temp = array();
|
||||
foreach ($data as $row) {
|
||||
$i = 0;
|
||||
foreach ($temp as $t_row) {
|
||||
if (strcmp($row['agent'], $t_row['agent']) < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
array_splice($temp, $i, 0, array($row));
|
||||
}
|
||||
|
||||
$data = $temp;
|
||||
break;
|
||||
case REPORT_ITEM_ORDER_BY_ASCENDING:
|
||||
$temp = array();
|
||||
foreach ($data as $row) {
|
||||
$i = 0;
|
||||
foreach ($temp as $t_row) {
|
||||
if (strcmp($row['availability_item'], $t_row['availability_item']) < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
array_splice($temp, $i, 0, array($row));
|
||||
}
|
||||
|
||||
$data = $temp;
|
||||
break;
|
||||
case REPORT_ITEM_ORDER_BY_DESCENDING:
|
||||
$temp = array();
|
||||
foreach ($data as $row) {
|
||||
$i = 0;
|
||||
foreach ($temp as $t_row) {
|
||||
|
||||
if (strcmp($row['availability_item'], $t_row['availability_item']) > 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
array_splice($temp, $i, 0, array($row));
|
||||
}
|
||||
|
||||
$data = $temp;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$return["data"] = $data;
|
||||
$return["resume"] = array();
|
||||
$return["resume"]['min_text'] = $min_text;
|
||||
$return["resume"]['min'] = $min;
|
||||
$return["resume"]['avg'] = $avg;
|
||||
$return["resume"]['max_text'] = $max_text;
|
||||
$return["resume"]['max'] = $max;
|
||||
|
||||
|
||||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
function reporting_general($report, $content) {
|
||||
|
||||
global $config;
|
||||
@ -992,6 +1224,12 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
|
||||
|
||||
}
|
||||
else {
|
||||
// HACK it is saved in show_graph field.
|
||||
$time_compare_overlapped = false;
|
||||
if ($content['show_graph']) {
|
||||
$time_compare_overlapped = 'overlapped';
|
||||
}
|
||||
|
||||
$return['chart'] = grafico_modulo_sparse(
|
||||
$content['id_agent_module'],
|
||||
$content['period'],
|
||||
@ -1013,7 +1251,7 @@ function reporting_simple_graph($report, $content, $type = 'dinamic',
|
||||
1,
|
||||
false,
|
||||
'',
|
||||
false,
|
||||
$time_compare_overlapped,
|
||||
true);
|
||||
}
|
||||
break;
|
||||
|
@ -125,6 +125,9 @@ function reporting_html_print_report($report, $mini = false) {
|
||||
}
|
||||
|
||||
switch ($item['type']) {
|
||||
case 'availability':
|
||||
reporting_html_availability($table, $item);
|
||||
break;
|
||||
case 'general':
|
||||
reporting_html_general($table, $item);
|
||||
break;
|
||||
@ -343,6 +346,93 @@ function reporting_html_text(&$table, $item) {
|
||||
$table->data['data']['cell'] = $item['data'];
|
||||
}
|
||||
|
||||
function reporting_html_availability(&$table, $item) {
|
||||
|
||||
if (!empty($item["data"])) {
|
||||
$table1->width = '99%';
|
||||
$table1->data = array ();
|
||||
$table1->head = array ();
|
||||
$table1->head[0] = __('Agent');
|
||||
// HACK it is saved in show_graph field.
|
||||
// Show interfaces instead the modules
|
||||
if ($item['kind_availability'] == 'address') {
|
||||
$table1->head[1] = __('IP Address');
|
||||
}
|
||||
else {
|
||||
$table1->head[1] = __('Module');
|
||||
}
|
||||
$table1->head[2] = __('# Checks');
|
||||
$table1->head[3] = __('# Failed');
|
||||
$table1->head[4] = __('% Fail');
|
||||
$table1->head[5] = __('Poling time');
|
||||
$table1->head[6] = __('Time unavailable');
|
||||
$table1->head[7] = __('% Ok');
|
||||
|
||||
$table1->style[0] = 'text-align: left';
|
||||
$table1->style[1] = 'text-align: left';
|
||||
$table1->style[2] = 'text-align: right';
|
||||
$table1->style[3] = 'text-align: right';
|
||||
$table1->style[4] = 'text-align: right';
|
||||
$table1->style[5] = 'text-align: right';
|
||||
$table1->style[6] = 'text-align: right';
|
||||
$table1->style[7] = 'text-align: right';
|
||||
|
||||
foreach ($item['data'] as $row) {
|
||||
$table_row = array();
|
||||
$table_row[] = $row['agent'];
|
||||
$table_row[] = $row['availability_item'];
|
||||
$table_row[] = $row['checks'];
|
||||
$table_row[] = $row['failed'];
|
||||
$table_row[] = $row['fail'];
|
||||
$table_row[] = $row['poling_time'];
|
||||
$table_row[] = $row['time_unavaliable'];
|
||||
$table_row[] = $row['ok'];
|
||||
|
||||
$table1->data[] = $table_row;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$table->colspan['error']['cell'] = 3;
|
||||
$table->data['error']['cell'] =
|
||||
__('There are no Agent/Modules defined');
|
||||
}
|
||||
|
||||
$table->colspan[1][0] = 3;
|
||||
$data = array();
|
||||
$data[0] = html_print_table($table1, true);
|
||||
array_push ($table->data, $data);
|
||||
|
||||
if ($item['resume'] && !empty($item["data"])) {
|
||||
$table1->width = '99%';
|
||||
$table1->data = array ();
|
||||
$table1->head = array ();
|
||||
$table1->style = array();
|
||||
$table1->head['min_text'] = '';
|
||||
$table1->head['min'] = __('Min Value');
|
||||
$table1->head['avg'] = __('Average Value');
|
||||
$table1->head['max_text'] = '';
|
||||
$table1->head['max'] = __('Max Value');
|
||||
$table1->style['min_text'] = 'text-align: left';
|
||||
$table1->style['min'] = 'text-align: right';
|
||||
$table1->style['avg'] = 'text-align: right';
|
||||
$table1->style['max_text'] = 'text-align: left';
|
||||
$table1->style['max'] = 'text-align: right';
|
||||
|
||||
$table1->data[] = array(
|
||||
'min_text' => $item['resume']['min_text'],
|
||||
'min' => format_numeric($item['resume']['min'], 2) . "%",
|
||||
'avg' => format_numeric($item['resume']['avg'], 2) . "%",
|
||||
'max_text' => $item['resume']['max_text'],
|
||||
'max' => format_numeric($item['resume']['max'], 2) . "%"
|
||||
);
|
||||
|
||||
$table->colspan[2][0] = 3;
|
||||
$data = array();
|
||||
$data[0] = html_print_table($table1, true);
|
||||
array_push ($table->data, $data);
|
||||
}
|
||||
}
|
||||
|
||||
function reporting_html_general(&$table, $item) {
|
||||
|
||||
if (!empty($item["data"])) {
|
||||
|
@ -578,7 +578,8 @@ function reports_get_report_types ($template = false, $not_editor = false) {
|
||||
'name' => __('Top n'));
|
||||
$types['network_interfaces_report'] = array('optgroup' => __('Grouped'),
|
||||
'name' => __('Network interfaces'));
|
||||
|
||||
$types['availability'] = array('optgroup' => __('Grouped'),
|
||||
'name' => __('Availability'));
|
||||
|
||||
|
||||
$types['text'] = array('optgroup' => __('Text/HTML '),
|
||||
|
Loading…
x
Reference in New Issue
Block a user