Custom fields in availability report type

Former-commit-id: 1f04e5728cf7d0ed5079c16488493188379d536c
This commit is contained in:
manuel 2019-04-02 16:24:29 +02:00
parent f67c3d5fc0
commit 1fd40447e1
5 changed files with 370 additions and 59 deletions

View File

@ -2,5 +2,17 @@ START TRANSACTION;
UPDATE tuser_task SET parameters = 'a:5:{i:0;a:6:{s:11:\"description\";s:28:\"Report pending to be created\";s:5:\"table\";s:7:\"treport\";s:8:\"field_id\";s:9:\"id_report\";s:10:\"field_name\";s:4:\"name\";s:4:\"type\";s:3:\"int\";s:9:\"acl_group\";s:8:\"id_group\";}i:1;a:2:{s:11:\"description\";s:46:\"Send to email addresses (separated by a comma)\";s:4:\"type\";s:4:\"text\";}i:2;a:2:{s:11:\"description\";s:7:\"Subject\";s:8:\"optional\";i:1;}i:3;a:3:{s:11:\"description\";s:7:\"Message\";s:4:\"type\";s:4:\"text\";s:8:\"optional\";i:1;}i:4;a:2:{s:11:\"description\";s:11:\"Report Type\";s:4:\"type\";s:11:\"report_type\";}}' where function_name = "cron_task_generate_report";
ALTER TABLE `treport_content` ADD COLUMN `total_time` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `time_failed` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `time_in_ok_status` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `time_in_unknown_status` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `time_of_not_initialized_module` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `time_of_downtime` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `total_checks` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `checks_failed` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `checks_in_ok_status` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `unknown_checks` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1';
COMMIT;

View File

@ -1379,6 +1379,18 @@ ALTER TABLE treport_content ADD COLUMN `hide_no_data` tinyint(1) default '0';
ALTER TABLE treport_content ADD COLUMN `recursion` tinyint(1) default NULL;
ALTER TABLE treport_content ADD COLUMN `show_extended_events` tinyint(1) default '0';
UPDATE `treport_content` SET type="netflow_summary" WHERE type="netflow_pie" OR type="netflow_statistics";
ALTER TABLE `treport_content` ADD COLUMN `total_time` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `time_failed` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `time_in_ok_status` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `time_in_unknown_status` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `time_of_not_initialized_module` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `time_of_downtime` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `total_checks` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `checks_failed` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `checks_in_ok_status` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `unknown_checks` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `agent_max_value` TINYINT(1) DEFAULT '1';
ALTER TABLE `treport_content` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1';
-- ---------------------------------------------------------------------
-- Table `tmodule_relationship`

View File

@ -119,6 +119,20 @@ $visual_format = 0;
// Others
$filter_search = '';
// Added for select fields.
$total_time = true;
$time_failed = true;
$time_in_ok_status = true;
$time_in_unknown_status = true;
$time_of_not_initialized_module = true;
$time_of_downtime = true;
$total_checks = true;
$checks_failed = true;
$checks_in_ok_status = true;
$unknown_checks = true;
$agent_max_value = true;
$agent_min_value = true;
switch ($action) {
case 'new':
$actionParameter = 'save';
@ -501,6 +515,18 @@ switch ($action) {
$sunday = $item['sunday'];
$time_from = $item['time_from'];
$time_to = $item['time_to'];
$total_time = $item['total_time'];
$time_failed = $item['time_failed'];
$time_in_ok_status = $item['time_in_ok_status'];
$time_in_unknown_status = $item['time_in_unknown_status'];
$time_of_not_initialized_module = $item['time_of_not_initialized_module'];
$time_of_downtime = $item['time_of_downtime'];
$total_checks = $item['total_checks'];
$checks_failed = $item['checks_failed'];
$checks_in_ok_status = $item['checks_in_ok_status'];
$unknown_checks = $item['unknown_checks'];
$agent_max_value = $item['agent_max_value'];
$agent_min_value = $item['agent_min_value'];
break;
case 'group_report':
@ -1597,20 +1623,6 @@ $class = 'databox filters';
REPORT_EXCEPTION_CONDITION_NOT_OK => __('Not OK'),
];
html_print_select($list_exception_condition, 'exception_condition', $exception_condition);
/*
echo ;
html_print_radio_button ('radiobutton_exception_condition', 0, '', $exception_condition);
echo __('>=');
html_print_radio_button ('radiobutton_exception_condition', 1, '', $exception_condition);
echo __('<');
html_print_radio_button ('radiobutton_exception_condition', 2, '', $exception_condition);
echo __('OK');
html_print_radio_button ('radiobutton_exception_condition', 3, '', $exception_condition);
echo __('Not OK');
html_print_radio_button ('radiobutton_exception_condition', 4, '', $exception_condition);
*/
?>
</td>
</tr>
@ -1620,6 +1632,65 @@ $class = 'databox filters';
<td><?php html_print_select($show_graph_options, 'combo_graph_options', $show_graph); ?></td>
</tr>
<tr id="row_select_fields" style="" class="datos">
<td style="font-weight:bold;margin-right:150px;">
<?php
echo __('Select fields to show');
?>
</td>
<td>
<table border="0">
<td>
<p style="margin-right:30px;">
<?php
echo __('Total time');
html_print_checkbox('total_time', 1, $total_time);
?>
</p>
</td>
<td>
<p style="margin-right:30px;">
<?php
echo __('Time failed');
html_print_checkbox('time_failed', 1, $time_failed);
?>
</p>
</td>
<td>
<p style="margin-right:30px;">
<?php
echo __('Time in OK status');
html_print_checkbox('time_in_ok_status', 1, $time_in_ok_status);
?>
</p>
</td>
<td>
<p style="margin-right:30px;">
<?php
echo __('Time in unknown status');
html_print_checkbox('time_in_unknown_status', 1, $time_in_unknown_status);
?>
</p>
</td>
<td>
<p style="margin-right:30px;">
<?php
echo __('Time of not initialized module');
html_print_checkbox('time_of_not_initialized_module', 1, $time_of_not_initialized_module);
?>
</p>
</td>
<td>
<p style="margin-right:30px;">
<?php
echo __('Time of downtime');
html_print_checkbox('time_of_downtime', 1, $time_of_downtime);
?>
</p>
</td>
</table>
</td>
</tr>
<tr id="row_show_address_agent" style="" class="datos">
<td style="font-weight:bold;">
@ -1629,7 +1700,7 @@ $class = 'databox filters';
</td>
<td>
<?php
html_print_checkbox(
html_print_checkbox_switch(
'checkbox_show_address_agent',
1,
$show_address_agent
@ -1637,12 +1708,13 @@ $class = 'databox filters';
?>
</td>
</tr>
<tr id="row_show_resume" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Show resume').ui_print_help_tip(__('Show a summary chart with max, min and average number of total modules at the end of the report and Checks.'), true); ?></td>
<td>
<?php
html_print_checkbox(
html_print_checkbox_switch(
'checkbox_show_resume',
1,
$show_resume
@ -1650,6 +1722,78 @@ $class = 'databox filters';
?>
</td>
</tr>
<tr id="row_select_fields2" style="" class="datos">
<td style="font-weight:bold;margin-right:150px;">
<?php
echo __('<p style= "margin-left:15px;">Select fields to show</p>');
?>
</td>
<td>
<table border="0">
<td>
<p style="margin-right:30px;">
<?php
echo __('Total checks');
html_print_checkbox('total_checks', 1, $total_checks);
?>
</p>
</td>
<td>
<p style="margin-right:30px;">
<?php
echo __('Checks failed');
html_print_checkbox('checks_failed', 1, $checks_failed);
?>
</p>
</td>
<td>
<p style="margin-right:30px;">
<?php
echo __('Checks in OK status');
html_print_checkbox('checks_in_ok_status', 1, $checks_in_ok_status);
?>
</p>
</td>
<td>
<p style="margin-right:30px;">
<?php
echo __('Unknown checks');
html_print_checkbox('unknown_checks', 1, $unknown_checks);
?>
</p>
</td>
<td>
</table>
</td>
</tr>
<tr id="row_select_fields3" style="" class="datos">
<td style="font-weight:bold;margin-right:150px;">
<?php
echo __('<p style= "margin-left:15px;">Select fields to show</p>');
?>
</td>
<td>
<table border="0">
<td>
<p style="margin-right:30px;">
<?php
echo __('Agent max value');
html_print_checkbox('agent_max_value', 1, $agent_max_value);
?>
</p>
</td>
<td>
<p style="margin-right:30px;">
<?php
echo __('Agent min values');
html_print_checkbox('agent_min_value', 1, $agent_min_value);
?>
</p>
</td>
<td>
</table>
</td>
</tr>
<tr id="row_show_summary_group" style="" class="datos">
<td style="font-weight:bold;"><?php echo __('Show Summary group'); ?></td>
@ -2625,6 +2769,17 @@ $(document).ready (function () {
}
});
$("#checkbox-checkbox_show_resume").change(function(){
if($(this).is(":checked")){
$("#row_select_fields2").show();
$("#row_select_fields3").show();
}
else{
$("#row_select_fields2").hide();
$("#row_select_fields3").hide();
}
});
});
@ -3139,6 +3294,9 @@ function chooseType() {
$("#row_event_type").hide();
$("#row_event_status").hide();
$("#row_source").hide();
$('#row_select_fields').hide();
$("#row_select_fields2").hide();
$("#row_select_fields3").hide();
// SLA list default state
$("#sla_list").hide();
@ -3547,6 +3705,15 @@ function chooseType() {
$("#row_show_resume").show();
$("#row_working_time").show();
$('#row_hide_notinit_agents').show();
$('#row_select_fields').show();
if($("#checkbox-checkbox_show_resume").is(":checked")){
$("#row_select_fields2").show();
$("#row_select_fields3").show();
}
else{
$("#row_select_fields2").hide();
$("#row_select_fields3").hide();
}
$("#row_historical_db_check").hide();
break;

View File

@ -1282,6 +1282,19 @@ switch ($action) {
$values['friday'] = get_parameter('friday', 0);
$values['saturday'] = get_parameter('saturday', 0);
$values['sunday'] = get_parameter('sunday', 0);
$values['total_time'] = get_parameter('total_time', 0);
$values['time_failed'] = get_parameter('time_failed', 0);
$values['time_in_ok_status'] = get_parameter('time_in_ok_status', 0);
$values['time_in_unknown_status'] = get_parameter('time_in_unknown_status', 0);
$values['time_of_not_initialized_module'] = get_parameter('time_of_not_initialized_module', 0);
$values['time_of_downtime'] = get_parameter('time_of_downtime', 0);
$values['total_checks'] = get_parameter('total_checks', 0);
$values['checks_failed'] = get_parameter('checks_failed', 0);
$values['checks_in_ok_status'] = get_parameter('checks_in_ok_status', 0);
$values['unknown_checks'] = get_parameter('unknown_checks', 0);
$values['agent_max_value'] = get_parameter('agent_max_value', 0);
$values['agent_min_value'] = get_parameter('agent_min_value', 0);
switch ($config['dbtype']) {
case 'mysql':
case 'postgresql':

View File

@ -2907,7 +2907,24 @@ function reporting_html_availability($table, $item, $pdf=0)
io_safe_output($style),
true
);
$sql = 'SELECT
total_time,
time_failed,
time_in_ok_status,
time_in_unknown_status,
time_of_not_initialized_module,
time_of_downtime,
total_checks,
checks_failed,
checks_in_ok_status,
unknown_checks,
agent_max_value,
agent_min_value
FROM treport_content
WHERE id_rc ='.$item['id_rc'];
$fields = db_get_all_rows_sql(
$sql
);
$same_agent_in_resume = '';
global $config;
@ -2927,32 +2944,62 @@ function reporting_html_availability($table, $item, $pdf=0)
$table1->head[1] = __('Module');
}
$table1->head[2] = __('Total time');
$table1->head[3] = __('Time failed');
$table1->head[4] = __('Time OK');
$table1->head[5] = __('Time Uknown');
$table1->head[6] = __('Time Not Init Module');
$table1->head[7] = __('Time Downtime');
if ($fields[0]['total_time']) {
$table1->head[2] = __('Total time');
} else {
$table1->head[2] = __('');
}
if ($fields[0]['time_failed']) {
$table1->head[3] = __('Time failed');
} else {
$table1->head[3] = __('');
}
if ($fields[0]['time_in_ok_status']) {
$table1->head[4] = __('Time OK');
} else {
$table1->head[4] = __('');
}
if ($fields[0]['time_in_unknown_status']) {
$table1->head[5] = __('Time Unknown');
} else {
$table1->head[5] = __('');
}
if ($fields[0]['time_of_not_initialized_module']) {
$table1->head[6] = __('Time Not Init Module');
} else {
$table1->head[6] = __('');
}
if ($fields[0]['time_of_downtime']) {
$table1->head[7] = __('Time Downtime');
} else {
$table1->head[7] = __('');
}
$table1->head[8] = __('% Ok');
$table1->headstyle = [];
$table1->headstyle[0] = 'text-align: left';
$table1->headstyle[1] = 'text-align: left';
$table1->headstyle[2] = 'text-align: right';
$table1->headstyle[3] = 'text-align: right';
$table1->headstyle[4] = 'text-align: right';
$table1->headstyle[5] = 'text-align: right';
$table1->headstyle[6] = 'text-align: right';
$table1->headstyle[2] = 'text-align: center';
$table1->headstyle[3] = 'text-align: center';
$table1->headstyle[4] = 'text-align: center';
$table1->headstyle[5] = 'text-align: center';
$table1->headstyle[6] = 'text-align: center';
$table1->headstyle[7] = 'text-align: right';
$table1->headstyle[8] = 'text-align: right';
$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[2] = 'text-align: center';
$table1->style[3] = 'text-align: center';
$table1->style[4] = 'text-align: center';
$table1->style[5] = 'text-align: center';
$table1->style[6] = 'text-align: center';
$table1->style[7] = 'text-align: right';
$table1->style[8] = 'text-align: right';
@ -2970,10 +3017,29 @@ function reporting_html_availability($table, $item, $pdf=0)
$table2->head[1] = __('Module');
}
$table2->head[2] = __('Total checks');
$table2->head[3] = __('Checks failed');
$table2->head[4] = __('Checks OK');
$table2->head[5] = __('Checks Uknown');
if ($fields[0]['total_checks']) {
$table2->head[2] = __('Total checks');
} else {
$table2->head[2] = __('');
}
if ($fields[0]['checks_failed']) {
$table2->head[3] = __('Checks failed');
} else {
$table2->head[3] = __('');
}
if ($fields[0]['checks_in_ok_status']) {
$table2->head[4] = __('Checks OK');
} else {
$table2->head[4] = __('');
}
if ($fields[0]['unknown_checks']) {
$table2->head[5] = __('Checks Uknown');
} else {
$table2->head[5] = __('');
}
$table2->headstyle = [];
$table2->headstyle[0] = 'text-align: left';
@ -2995,69 +3061,97 @@ function reporting_html_availability($table, $item, $pdf=0)
$table_row[] = $row['agent'];
$table_row[] = $row['availability_item'];
if ($row['time_total'] != 0) {
if ($row['time_total'] != 0 && $fields[0]['total_time']) {
$table_row[] = human_time_description_raw(
$row['time_total'],
true
);
} else {
} else if ($row['time_total'] == 0 && $fields[0]['total_time']) {
$table_row[] = '--';
}
} else {
$table_row[] = '';
};
if ($row['time_error'] != 0) {
if ($row['time_error'] != 0 && $fields[0]['time_failed']) {
$table_row[] = human_time_description_raw(
$row['time_error'],
true
);
} else {
} else if ($row['time_error'] == 0 && $fields[0]['time_failed']) {
$table_row[] = '--';
}
} else {
$table_row[] = '';
};
if ($row['time_ok'] != 0) {
if ($row['time_ok'] != 0 && $fields[0]['time_in_ok_status']) {
$table_row[] = human_time_description_raw(
$row['time_ok'],
true
);
} else {
} else if ($row['time_ok'] == 0 && $fields[0]['time_in_ok_status']) {
$table_row[] = '--';
}
} else {
$table_row[] = '';
};
if ($row['time_unknown'] != 0) {
if ($row['time_unknown'] != 0 && $fields[0]['time_in_unknown_status']) {
$table_row[] = human_time_description_raw(
$row['time_unknown'],
true
);
} else {
} else if ($row['time_unknown'] == 0 && $fields[0]['time_in_unknown_status']) {
$table_row[] = '--';
}
} else {
$table_row[] = '';
};
if ($row['time_not_init'] != 0) {
if ($row['time_not_init'] != 0 && $fields[0]['time_of_not_initialized_module']) {
$table_row[] = human_time_description_raw(
$row['time_not_init'],
true
);
} else {
} else if ($row['time_not_init'] == 0 && $fields[0]['time_of_not_initialized_module']) {
$table_row[] = '--';
}
} else {
$table_row[] = '';
};
if ($row['time_downtime'] != 0) {
if ($row['time_downtime'] != 0 && $fields[0]['time_of_downtime']) {
$table_row[] = human_time_description_raw(
$row['time_downtime'],
true
);
} else {
} else if ($row['time_downtime'] == 0 && $fields[0]['time_of_downtime']) {
$table_row[] = '--';
}
} else {
$table_row[] = '';
};
$table_row[] = '<span style="font-size: 1.2em; font-weight:bold;">'.sla_truncate($row['SLA'], $config['graph_precision']).'%</span>';
$table_row2 = [];
$table_row2[] = $row['agent'];
$table_row2[] = $row['availability_item'];
$table_row2[] = $row['checks_total'];
$table_row2[] = $row['checks_error'];
$table_row2[] = $row['checks_ok'];
$table_row2[] = $row['checks_unknown'];
if ($fields[0]['total_checks']) {
$table_row2[] = $row['checks_total'];
} else {
$table_row2[] = '';
};
if ($fields[0]['checks_failed']) {
$table_row2[] = $row['checks_error'];
} else {
$table_row2[] = '';
};
if ($fields[0]['checks_in_ok_status']) {
$table_row2[] = $row['checks_ok'];
} else {
$table_row2[] = '';
};
if ($fields[0]['unknown_checks']) {
$table_row2[] = $row['checks_unknown'];
} else {
$table_row2[] = '';
};
$table1->data[] = $table_row;
$table2->data[] = $table_row2;
@ -3131,6 +3225,19 @@ function reporting_html_availability($table, $item, $pdf=0)
).'%',
'avg' => '<span style="font-size: 1.2em; font-weight:bold;">'.sla_truncate($item['resume']['avg'], $config['graph_precision']).'%</span>',
];
if ($fields[0]['agent_max_value'] == 0) {
$table1->head['max_text'] = '';
$table1->data[0]['max_text'] = '';
$table1->head['max'] = '';
$table1->data[0]['max'] = '';
}
if ($fields[0]['agent_min_value'] == 0) {
$table1->head['min_text'] = '';
$table1->data[0]['min_text'] = '';
$table1->head['min'] = '';
$table1->data[0]['min'] = '';
}
if ($pdf === 0) {
$table->colspan[3][0] = 3;