#10194 adjust bars 24 hrs in events and changed numbers

This commit is contained in:
Daniel Cebrian 2023-10-16 20:47:47 +02:00
parent 9237e4038a
commit d54a6faede
13 changed files with 135 additions and 697 deletions

View File

@ -30,341 +30,3 @@ use PandoraFMS\TacticalView\GeneralTacticalView;
$tacticalView = new GeneralTacticalView();
$tacticalView->render();
return;
// Temporal return for develop.
// Config functions.
require_once 'include/config.php';
// This solves problems in enterprise load.
global $config;
check_login();
// ACL Check.
if (check_acl($config['id_user'], 0, 'AR') === 0) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Default view'
);
include 'general/noaccess.php';
exit;
}
require_once 'include/functions_reporting.php';
require_once 'include/functions_tactical.php';
require_once $config['homedir'].'/include/functions_graph.php';
if (tags_has_user_acl_tags()) {
ui_print_tags_warning();
}
$all_data = tactical_status_modules_agents(
$config['id_user'],
false,
'AR'
);
$data = [];
$data['monitor_not_init'] = (int) $all_data['_monitors_not_init_'];
$data['monitor_unknown'] = (int) $all_data['_monitors_unknown_'];
$data['monitor_ok'] = (int) $all_data['_monitors_ok_'];
$data['monitor_warning'] = (int) $all_data['_monitors_warning_'];
$data['monitor_critical'] = (int) $all_data['_monitors_critical_'];
$data['monitor_not_normal'] = (int) $all_data['_monitor_not_normal_'];
$data['monitor_alerts'] = (int) $all_data['_monitors_alerts_'];
$data['monitor_alerts_fired'] = (int) $all_data['_monitors_alerts_fired_'];
$data['monitor_total'] = (int) $all_data['_monitor_total_'];
$data['total_agents'] = (int) $all_data['_total_agents_'];
$data['monitor_checks'] = (int) $all_data['_monitor_checks_'];
if (!empty($all_data)) {
if ($data['monitor_not_normal'] > 0 && $data['monitor_checks'] > 0) {
$data['monitor_health'] = format_numeric((100 - ($data['monitor_not_normal'] / ($data['monitor_checks'] / 100))), 1);
} else {
$data['monitor_health'] = 100;
}
if ($data['monitor_not_init'] > 0 && $data['monitor_checks'] > 0) {
$data['module_sanity'] = format_numeric((100 - ($data['monitor_not_init'] / ($data['monitor_checks'] / 100))), 1);
} else {
$data['module_sanity'] = 100;
}
if (isset($data['alerts'])) {
if ($data['monitor_alerts_fired'] > 0 && $data['alerts'] > 0) {
$data['alert_level'] = format_numeric((100 - ($data['monitor_alerts_fired'] / ($data['alerts'] / 100))), 1);
} else {
$data['alert_level'] = 100;
}
} else {
$data['alert_level'] = 100;
$data['alerts'] = 0;
}
$data['monitor_bad'] = ($data['monitor_critical'] + $data['monitor_warning']);
if ($data['monitor_bad'] > 0 && $data['monitor_checks'] > 0) {
$data['global_health'] = format_numeric((100 - ($data['monitor_bad'] / ($data['monitor_checks'] / 100))), 1);
} else {
$data['global_health'] = 100;
}
$data['server_sanity'] = format_numeric((100 - $data['module_sanity']), 1);
}
ui_require_css_file('logon');
echo '<div id="welcome_panel">';
//
// Overview Table.
//
$table = new stdClass();
$table->class = 'no-class';
$table->cellpadding = 4;
$table->cellspacing = 4;
$table->head = [];
$table->data = [];
$table->headstyle[0] = 'text-align:center;';
$table->width = '100%';
$table->head_colspan[0] = 4;
// Indicators.
$tdata = [];
$stats = reporting_get_stats_indicators($data, 120, 10, false);
$status = '<table class="status_tactical">';
foreach ($stats as $stat) {
$status .= '<tr><td><b>'.$stat['title'].'</b></td><td>'.$stat['graph'].'</td></tr>';
}
$status .= '</table>';
$table->rowclass = [];
$table->rowclass[0] = 'w100p';
$table->rowclass[1] = 'w100p';
$table->rowclass[2] = 'w100p';
$table->rowclass[3] = 'w100p';
$table->rowclass[4] = 'w100p';
$table->rowclass[5] = 'w100p';
$table->data[0][0] = $status;
$table->data[] = $tdata;
// Alerts.
$tdata = [];
$tdata[0] = reporting_get_stats_alerts($data);
$table->rowclass[] = '';
$table->data[] = $tdata;
// Modules by status.
$tdata = [];
$data_agents = [
__('Critical') => $data['monitor_critical'],
__('Warning') => $data['monitor_warning'],
__('Normal') => $data['monitor_ok'],
__('Unknown') => $data['monitor_unknown'],
__('Not init') => $data['monitor_not_init'],
];
$tdata[0] = reporting_get_stats_modules_status($data, 180, 100, false, $data_agents);
$table->rowclass[] = '';
$table->data[] = $tdata;
// Total agents and modules.
$tdata = [];
$tdata[0] = reporting_get_stats_agents_monitors($data);
$table->rowclass[] = '';
$table->data[] = $tdata;
// Users.
if (users_is_admin() || check_acl($config['id_user'], 0, 'UM')) {
$tdata = [];
$tdata[0] = reporting_get_stats_users($data);
$table->rowclass[] = '';
$table->data[] = $tdata;
}
ui_toggle(
html_print_table($table, true),
__('%s Overview', get_product_name()),
'',
'overview',
false
);
unset($table);
echo '<div id="right">';
// News.
require_once 'general/news_dialog.php';
$options = [];
$options['id_user'] = $config['id_user'];
$options['modal'] = false;
$options['limit'] = 3;
$news = get_news($options);
if (!empty($news)) {
ui_require_css_file('news');
// NEWS BOARD.
if ($config['prominent_time'] == 'timestamp') {
$comparation_suffix = '';
} else {
$comparation_suffix = __('ago');
}
$output_news = '<div id="news_board" class="new">';
foreach ($news as $article) {
$default = false;
if ($article['text'] == '&amp;lt;p&#x20;style=&quot;text-align:&#x20;center;&#x20;font-size:&#x20;13px;&quot;&amp;gt;Hello,&#x20;congratulations,&#x20;if&#x20;you&apos;ve&#x20;arrived&#x20;here&#x20;you&#x20;already&#x20;have&#x20;an&#x20;operational&#x20;monitoring&#x20;console.&#x20;Remember&#x20;that&#x20;our&#x20;forums&#x20;and&#x20;online&#x20;documentation&#x20;are&#x20;available&#x20;24x7&#x20;to&#x20;get&#x20;you&#x20;out&#x20;of&#x20;any&#x20;trouble.&#x20;You&#x20;can&#x20;replace&#x20;this&#x20;message&#x20;with&#x20;a&#x20;personalized&#x20;one&#x20;at&#x20;Admin&#x20;tools&#x20;-&amp;amp;gt;&#x20;Site&#x20;news.&amp;lt;/p&amp;gt;&#x20;') {
$article['subject'] = __('Welcome to Pandora FMS Console');
$default = true;
}
$text_bbdd = io_safe_output($article['text']);
$text = html_entity_decode($text_bbdd);
$output_news .= '<div class="new-board">';
$output_news .= '<div class="new-board-header">';
$output_news .= '<span class="new-board-title">'.$article['subject'].'</span>';
$output_news .= '<span class="new-board-author">'.__('By').' '.$article['author'].' '.ui_print_timestamp($article['timestamp'], true).'</span>';
$output_news .= '</div>';
$output_news .= '<div class="new content">';
if ($default) {
$output_news .= '<div class="default-new">';
$output_news .= '<div class="default-image-new">';
$output_news .= '<img src="./images/welcome_image.svg" alt="img colabora con nosotros - Support">';
$output_news .= '</div><div class="default-text-new">';
$output_news .= '
<p>'.__('Welcome to our monitoring tool so grand,').'
<br>'.__('Where data insights are at your command.').'
<br>'.__('Sales, marketing, operations too,').'
<br>'.__("Customer support, we've got you.").'
</p>
<p>'.__('Our interface is user-friendly,').'
<br>'.__("Customize your dashboard, it's easy.").'
<br>'.__('Set up alerts and gain insights so keen,').'
<br>'.__("Optimize your data, like you've never seen.").'
</p>
<p>'.__('Unleash its power now, and join the pro league,').'
<br>'.__('Unlock the potential of your data to intrigue.').'
<br>'.__('Monitoring made simple, efficient and fun,').'
<br>'.__('Discover a whole new way to get things done.').'
</p>
<p>'.__('And take control of your IT once and for all.').'</p>
<span>'.__('You can replace this message with a personalized one at Admin tools -> Site news.').'</span>
';
$output_news .= '</div></div>';
} else {
$text = str_replace('<script', '&lt;script', $text);
$text = str_replace('</script', '&lt;/script', $text);
$output_news .= nl2br($text);
}
$output_news .= '</div></div>';
}
$output_news .= '</div>';
// News board.
ui_toggle(
$output_news,
__('News board'),
'',
'news',
false
);
// END OF NEWS BOARD.
}
// LAST ACTIVITY.
// Show last activity from this user.
$table = new stdClass();
$table->class = 'no-td-padding info_table';
$table->cellpadding = 0;
$table->cellspacing = 0;
$table->width = '100%';
// Don't specify px.
$table->data = [];
$table->size = [];
$table->headstyle = [];
$table->size[0] = '5%';
$table->size[1] = '15%';
$table->headstyle[1] = 'min-width: 12em;';
$table->size[2] = '5%';
$table->headstyle[2] = 'min-width: 65px;';
$table->size[3] = '10%';
$table->size[4] = '25%';
$table->head = [];
$table->head[0] = __('User');
$table->head[1] = __('Action');
$table->head[2] = __('Date');
$table->head[3] = __('Source IP');
$table->head[4] = __('Comments');
$table->align[4] = 'left';
$sql = sprintf(
'SELECT id_usuario,accion, ip_origen,descripcion,utimestamp
FROM tsesion
WHERE (`utimestamp` > UNIX_TIMESTAMP(NOW()) - '.SECONDS_1WEEK.")
AND `id_usuario` = '%s' ORDER BY `utimestamp` DESC LIMIT 10",
$config['id_user']
);
$sessions = db_get_all_rows_sql($sql);
if ($sessions === false) {
$sessions = [];
}
foreach ($sessions as $session) {
$data = [];
$session_id_usuario = $session['id_usuario'];
$session_ip_origen = $session['ip_origen'];
$data[0] = '<strong>'.$session_id_usuario.'</strong>';
$data[1] = ui_print_session_action_icon($session['accion'], true).' '.$session['accion'];
$data[2] = ui_print_help_tip(
date($config['date_format'], $session['utimestamp']),
true
).human_time_comparation($session['utimestamp'], 'tiny');
$data[3] = $session_ip_origen;
$description = io_safe_output(str_replace([',', ', '], ', ', $session['descripcion']));
if (strlen($description) > 100) {
$data[4] = '<div >'.io_safe_input(substr($description, 0, 150)).'...</div>';
} else {
$data[4] = '<div >'.io_safe_input($description).'</div>';
}
array_push($table->data, $data);
}
$activity = html_print_table($table, true);
unset($table);
ui_toggle(
$activity,
__('Latest activity'),
'',
'activity',
false,
false,
'',
'white-box-content padded'
);
// END OF LAST ACTIVIYY.
// Close right panel.
echo '</div>';
// Close welcome panel.
echo '</div>';

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="27px" height="27px" viewBox="0 0 27 27" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>F7C0551D-EEAD-4AA0-87B8-DE2D255390BB</title>
<g id="Welcome-dashboard---v1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Pandora-FMS---Tactical-view-v6" transform="translate(-1764, -1865)" fill="#95A3BF">
<g id="Log-storage" transform="translate(1102, 1662)">
<g id="Card-1/8" transform="translate(594, 203)">
<g id="System-event" transform="translate(68, 0)">
<path d="M11.7078546,2.70325912 C11.1257057,3.92992514 10.8,5.30192625 10.8,6.75 C10.8,11.9690909 15.0309091,16.2 20.25,16.2 C21.6996594,16.2 23.0730794,15.8735806 24.3007699,15.2902321 L24.3,20.4457055 C24.3,25.0619204 18.7171222,27 12.15,27 C5.58287783,27 0,25.0619204 0,20.4457055 L0,9.25429447 C0,4.79456141 5.2107929,2.83447266 11.4857292,2.70670994 Z M20.25,0 C23.9779221,0 27,3.02207794 27,6.75 C27,10.4779221 23.9779221,13.5 20.25,13.5 C16.5220779,13.5 13.5,10.4779221 13.5,6.75 C13.5,3.02207794 16.5220779,0 20.25,0 Z M21.6,4.05 L20.4317308,4.05 C20.3365385,4.59915254 19.7394231,5.05677966 18.9,5.06510015 L18.9,5.93875193 L20.2413462,5.93875193 L20.2413462,9.45 L21.6,9.45 L21.6,4.05 Z" id="Mask"></path>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -26,18 +26,21 @@ $(document).ready(function() {
}
});
$.ajax({
url: "ajax.php",
data: {
page: "include/ajax/general_tactical_view.ajax",
method: "getEventsStatusGraph",
class: "Events"
},
type: "POST",
success: function(data) {
$("#events-status-validate").html(data);
}
});
// Prevent that graphs use same name.
setTimeout(() => {
$.ajax({
url: "ajax.php",
data: {
page: "include/ajax/general_tactical_view.ajax",
method: "getEventsStatusGraph",
class: "Events"
},
type: "POST",
success: function(data) {
$("#events-status-validate").html(data);
}
});
}, 100);
$.ajax({
url: "ajax.php",

View File

@ -56,7 +56,7 @@ class Agents extends Element
return html_print_div(
[
'content' => $total,
'content' => format_numeric($total, 0),
'class' => 'text-l',
'style' => 'margin: 0px 10px 10px 10px;',
],
@ -107,7 +107,7 @@ class Agents extends Element
$total = db_get_value_sql($sql);
return html_print_div(
[
'content' => $total,
'content' => format_numeric($total, 0),
'class' => 'text-l',
'style' => 'margin: 0px 10px 10px 10px;',
],

View File

@ -66,7 +66,7 @@ class Alerts extends Element
$total = alerts_get_alerts(0, '', 'fired', -1, 'AR', true);
return html_print_div(
[
'content' => $total,
'content' => format_numeric($total, 0),
'class' => 'text-l',
'id' => 'currently-triggered',
'style' => 'margin: 0px 10px 10px 10px;',
@ -86,7 +86,7 @@ class Alerts extends Element
$total = alerts_get_alerts(0, '', 'all', -1, 'AR', true);
return html_print_div(
[
'content' => $total,
'content' => format_numeric($total, 0),
'class' => 'text-l',
'id' => 'active-correlation',
'style' => 'margin: 0px 10px 10px 10px;',

View File

@ -52,7 +52,7 @@ class Configurations extends Element
$text = '<span class="subtitle">'.__('Groups').'</span>';
$number = html_print_div(
[
'content' => $total,
'content' => format_numeric($total, 0),
'class' => 'text-l text_center',
'style' => '',
],
@ -76,7 +76,7 @@ class Configurations extends Element
$text = '<span class="subtitle">'.__('Modules').'</span>';
$number = html_print_div(
[
'content' => $total,
'content' => format_numeric($total, 0),
'class' => 'text-l text_center',
'style' => '',
],
@ -103,7 +103,7 @@ class Configurations extends Element
$text = '<span class="subtitle">'.__('Policies').'</span>';
$number = html_print_div(
[
'content' => $totalPolicies,
'content' => format_numeric($totalPolicies, 0),
'class' => 'text-l text_center',
'style' => '',
],
@ -139,7 +139,7 @@ class Configurations extends Element
$text = '<span class="subtitle">'.__('Remote plugins').'</span>';
$number = html_print_div(
[
'content' => $totalPLugins,
'content' => format_numeric($totalPLugins, 0),
'class' => 'text-l text_center',
'style' => '',
],
@ -166,7 +166,7 @@ class Configurations extends Element
$text = '<span class="subtitle">'.__('Module templates').'</span>';
$number = html_print_div(
[
'content' => $countModuleTemplates,
'content' => format_numeric($countModuleTemplates, 0),
'class' => 'text-l text_center',
'style' => '',
],
@ -190,7 +190,7 @@ class Configurations extends Element
$text = '<span class="subtitle">'.__('Not-init modules').'</span>';
$number = html_print_div(
[
'content' => $total,
'content' => format_numeric($total, 0),
'class' => 'text-l text_center',
'style' => '',
],
@ -214,7 +214,31 @@ class Configurations extends Element
$text = '<span class="subtitle">'.__('Unknown agents').'</span>';
$number = html_print_div(
[
'content' => $total,
'content' => format_numeric($total, 0),
'class' => 'text-l text_center',
'style' => '',
],
true
);
$output = $image.$text.$number;
return $output;
}
/**
* Returns the html of total events.
*
* @return string
*/
public function getTotalEvents():string
{
$data = $this->valueMonitoring('last_events_24h');
$total = $data[0]['datos'];
$image = html_print_image('images/system_event.svg', true);
$text = '<span class="subtitle">'.__('Events in last 24 hrs').'</span>';
$number = html_print_div(
[
'content' => format_numeric($total, 0),
'class' => 'text-l text_center',
'style' => '',
],

View File

@ -127,7 +127,7 @@ class Database extends Element
public function getDataRecords():string
{
$data = $this->valueMonitoring('mysql_size_of_data');
$value = round($data[0]['datos'], 2).' MB';
$value = format_numeric($data[0]['datos'], 2).' MB';
return html_print_div(
[
'content' => $value,
@ -148,7 +148,7 @@ class Database extends Element
public function getEvents():string
{
$data = $this->valueMonitoring('last_events_24h');
$value = round($data[0]['datos']);
$value = format_numeric($data[0]['datos']);
return html_print_div(
[
'content' => $value,
@ -169,7 +169,7 @@ class Database extends Element
public function getStringRecords():string
{
$data = $this->valueMonitoring('total_string_data');
$value = round($data[0]['datos']);
$value = format_numeric($data[0]['datos']);
return html_print_div(
[
'content' => $value,
@ -231,15 +231,15 @@ class Database extends Element
$graph_area = html_print_div(
[
'content' => line_graph($data, $options),
'class' => 'w100p h100p',
'style' => 'max-height: 83px;',
'class' => 'w100p h100p centered',
'style' => 'max-height: 83px; max-width: 93%; margin-bottom: 10px;',
],
true
);
$total = html_print_div(
[
'content' => $total,
'content' => format_numeric($total),
'class' => 'text-xl',
],
true
@ -306,15 +306,15 @@ class Database extends Element
$graph_area = html_print_div(
[
'content' => line_graph($data, $options),
'class' => 'w100p h100p',
'style' => 'max-height: 83px;',
'class' => 'w100p h100p centered',
'style' => 'max-height: 83px; max-width: 93%; margin-bottom: 10px;',
],
true
);
$total = html_print_div(
[
'content' => $total,
'content' => format_numeric($total),
'class' => 'text-xl',
],
true

View File

@ -34,7 +34,9 @@ class Events extends Element
*/
public function __construct()
{
global $config;
parent::__construct();
include_once $config['homedir'].'/include/graphs/fgraph.php';
$this->title = __('Events');
$this->ajaxMethods = [
'getEventsGraph',
@ -67,45 +69,43 @@ class Events extends Element
}
$id_groups = implode(',', $id_groups);
$interval24h = (time() - 86400);
$sql = 'SELECT
utimestamp,
DATE_FORMAT(FROM_UNIXTIME(utimestamp), "%Y-%m-%d %H:00:00") AS hour,
COUNT(*) AS number_of_events
FROM tevento
WHERE utimestamp >= '.$interval24h.' AND id_grupo IN ('.$id_groups.')
GROUP BY hour
ORDER BY hour
LIMIT 24;';
$event_view_h = (int) ($config['event_view_hr'] > 24) ? 24 : $config['event_view_hr'];
$time_events = ($event_view_h * 3600);
$intervalh = (time() - $time_events);
$sql = 'SELECT utimestamp from tevento WHERE utimestamp >= '.$intervalh.' ORDER BY utimestamp DESC;';
$rows = db_process_sql($sql);
$graph_values = [];
for ($i = 1; $i <= 24; $i++) {
$timestamp = strtotime('-'.$i.' hours');
$hour = date('d-m-Y H:00:00', $timestamp);
$graph_values[$hour] = [
'y' => 0,
'x' => $hour,
];
$cut_seconds = ($time_events / 24);
$now = time();
$cuts_intervals = [];
for ($i = 0; $i < 24; $i++) {
$cuts_intervals[$now] = 0;
$now -= $cut_seconds;
}
$graph_values = array_reverse($graph_values);
foreach ($rows as $key => $row) {
foreach ($cuts_intervals as $time => $count) {
if ($row['utimestamp'] > $time) {
$cuts_intervals[$time]++;
break;
}
}
}
$cuts_intervals = array_reverse($cuts_intervals, true);
$graph_values = [];
$colors = [];
$max_value = 0;
foreach ($rows as $key => $row) {
if ($max_value < $row['number_of_events']) {
$max_value = $row['number_of_events'];
foreach ($cuts_intervals as $utimestamp => $count) {
if ($max_value < $count) {
$max_value = $count;
}
$graph_values[date('d-m-Y H:00:00', $row['utimestamp'])] = [
'y' => $row['number_of_events'],
'x' => date('d-m-Y H:00:00', $row['utimestamp']),
$graph_values[] = [
'y' => $count,
'x' => date('d-m-Y H:i:s', $utimestamp),
];
}
$graph_values = array_slice($graph_values, -24);
$danger = $max_value;
$ok = ($max_value / 3);
@ -177,10 +177,12 @@ class Events extends Element
}
$id_groups = implode(',', $id_groups);
$interval8h = (time() - 86400);
$event_view_h = (int) ($config['event_view_hr'] > 24) ? 24 : $config['event_view_hr'];
$time_events = ($event_view_h * 3600);
$intervalh = (time() - $time_events);
$sql = 'SELECT criticity, count(*) AS total
FROM tevento
WHERE utimestamp >= '.$interval8h.' AND id_grupo IN ('.$id_groups.')
WHERE utimestamp >= '.$intervalh.' AND id_grupo IN ('.$id_groups.')
group by criticity';
$rows = db_process_sql($sql);
@ -236,6 +238,7 @@ class Events extends Element
}
$options = [
'waterMark' => false,
'labels' => $labels,
'legend' => ['display' => false],
'cutout' => 80,
@ -277,10 +280,12 @@ class Events extends Element
}
$id_groups = implode(',', $id_groups);
$interval8h = (time() - 86400);
$event_view_h = (int) ($config['event_view_hr'] > 24) ? 24 : $config['event_view_hr'];
$time_events = ($event_view_h * 3600);
$intervalh = (time() - $time_events);
$sql = 'SELECT estado, count(*) AS total
FROM tevento
WHERE utimestamp >= '.$interval8h.' AND id_grupo IN ('.$id_groups.')
WHERE utimestamp >= '.$intervalh.' AND id_grupo IN ('.$id_groups.')
group by estado';
$rows = db_process_sql($sql);
@ -315,6 +320,7 @@ class Events extends Element
}
$options = [
'waterMark' => false,
'labels' => $labels,
'legend' => ['display' => false],
'cutout' => 80,
@ -356,10 +362,12 @@ class Events extends Element
}
$id_groups = implode(',', $id_groups);
$interval8h = (time() - 86400);
$event_view_h = (int) ($config['event_view_hr'] > 24) ? 24 : $config['event_view_hr'];
$time_events = ($event_view_h * 3600);
$intervalh = (time() - $time_events);
$sql = 'SELECT criticity, count(*) AS total
FROM tevento
WHERE utimestamp >= '.$interval8h.' AND id_grupo IN ('.$id_groups.')
WHERE utimestamp >= '.$intervalh.' AND id_grupo IN ('.$id_groups.')
group by criticity';
$rows = db_process_sql($sql);

View File

@ -145,7 +145,7 @@ class LogStorage extends Element
{
if ($this->isEnabled() === true) {
$data = $this->valueMonitoring('Total sources');
$value = round($data[0]['datos']);
$value = format_numeric($data[0]['datos']);
} else {
$value = __('N/A');
}
@ -171,7 +171,7 @@ class LogStorage extends Element
{
if ($this->isEnabled() === true) {
$data = $this->valueMonitoring('Total lines of data');
$value = round($data[0]['datos']);
$value = format_numeric($data[0]['datos']);
} else {
$value = __('N/A');
}
@ -199,7 +199,7 @@ class LogStorage extends Element
$date = $data[0]['datos'];
if ($date > 0 && $this->isEnabled() === true) {
$interval = (time() - strtotime($date));
$days = round($interval / 86400);
$days = format_numeric(($interval / 86400), 0);
} else {
$days = 'N/A';
}

View File

@ -137,12 +137,12 @@ class Overview extends Element
);
}
$output = $image_status.$text;
$output = '<a href="index.php?sec=gservers&sec2=godmode/servers/modificar_server" class="flex_center">'.$image_status.$text.'</a>';
return html_print_div(
[
'content' => $output,
'class' => 'flex_center margin-top-5',
'class' => 'margin-top-5',
'id' => 'status-servers',
],
true

View File

@ -34,8 +34,10 @@ class ScheduledDowntime extends Element
*/
public function __construct()
{
global $config;
parent::__construct();
ui_require_javascript_file('pandora_planned_downtimes');
include_once $config['homedir'].'/include/functions_reporting.php';
$this->title = __('Scheduled Downtime');
$this->ajaxMethods = ['getScheduleDowntime'];
}
@ -257,8 +259,7 @@ class ScheduledDowntime extends Element
{
global $config;
$read_permisson = (bool) check_acl($config['id_user'], 0, 'AR');
$manage_permisson = (bool) check_acl($config['id_user'], 0, 'AW');
if ($read_permisson === true && $manage_permisson === true) {
if ($read_permisson === true) {
return true;
} else {
return false;

View File

@ -27,286 +27,7 @@
*/
// Begin.
global $config;
use PandoraFMS\TacticalView\GeneralTacticalView;
require_once 'include/functions_events.php';
require_once 'include/functions_servers.php';
require_once 'include/functions_reporting.php';
require_once 'include/functions_tactical.php';
require_once $config['homedir'].'/include/functions_graph.php';
check_login();
if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'], 0, 'AW')) {
db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION,
'Trying to access Agent view (Grouped)'
);
include 'general/noaccess.php';
return;
}
ui_require_css_file('tactical');
$is_admin = check_acl($config['id_user'], 0, 'PM');
$user_strict = (bool) db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
$force_refresh = get_parameter('force_refresh', '');
$refresh = get_parameter('refr', 0);
if ($force_refresh == 1) {
db_process_sql('UPDATE tgroup_stat SET utimestamp = 0');
}
$updated_time = '';
if ($config['realtimestats'] == 0) {
$updated_time = "<a href='index.php?sec=estado&sec2=operation/agentes/tactical&force_refresh=1'>";
$updated_time .= __('Last update').' : '.ui_print_timestamp(db_get_sql('SELECT min(utimestamp) FROM tgroup_stat'), true);
$updated_time .= '</a>';
} else {
// $updated_info = __("Updated at realtime");
$updated_info = '';
}
// Header.
ui_print_standard_header(
__('Tactical view'),
'',
false,
'',
false,
(array) $updated_time,
[
[
'link' => '',
'label' => __('Monitoring'),
],
[
'link' => '',
'label' => __('Views'),
],
]
);
// Currently this function makes loading this page is impossible. Change
// and create new function.
$all_data = tactical_status_modules_agents($config['id_user'], false, 'AR');
$data = [];
$data['monitor_not_init'] = (int) $all_data['_monitors_not_init_'];
$data['monitor_unknown'] = (int) $all_data['_monitors_unknown_'];
$data['monitor_ok'] = (int) $all_data['_monitors_ok_'];
$data['monitor_warning'] = (int) $all_data['_monitors_warning_'];
$data['monitor_critical'] = (int) $all_data['_monitors_critical_'];
$data['monitor_not_normal'] = (int) $all_data['_monitor_not_normal_'];
$data['monitor_alerts'] = (int) $all_data['_monitors_alerts_'];
$data['monitor_alerts_fired'] = (int) $all_data['_monitors_alerts_fired_'];
$data['monitor_total'] = (int) $all_data['_monitor_total_'];
$data['total_agents'] = (int) $all_data['_total_agents_'];
$data['monitor_checks'] = (int) $all_data['_monitor_checks_'];
// Percentages
if (!empty($all_data)) {
if ($data['monitor_not_normal'] > 0 && $data['monitor_checks'] > 0) {
$data['monitor_health'] = format_numeric((100 - ($data['monitor_not_normal'] / ($data['monitor_checks'] / 100))), 1);
} else {
$data['monitor_health'] = 100;
}
if ($data['monitor_not_init'] > 0 && $data['monitor_checks'] > 0) {
$data['module_sanity'] = format_numeric((100 - ($data['monitor_not_init'] / ($data['monitor_checks'] / 100))), 1);
} else {
$data['module_sanity'] = 100;
}
if (isset($data['alerts'])) {
if ($data['monitor_alerts_fired'] > 0 && $data['alerts'] > 0) {
$data['alert_level'] = format_numeric((100 - ($data['monitor_alerts_fired'] / ($data['alerts'] / 100))), 1);
} else {
$data['alert_level'] = 100;
}
} else {
$data['alert_level'] = 100;
$data['alerts'] = 0;
}
$data['monitor_bad'] = ($data['monitor_critical'] + $data['monitor_warning']);
if ($data['monitor_bad'] > 0 && $data['monitor_checks'] > 0) {
$data['global_health'] = format_numeric((100 - ($data['monitor_bad'] / ($data['monitor_checks'] / 100))), 1);
} else {
$data['global_health'] = 100;
}
$data['server_sanity'] = format_numeric((100 - $data['module_sanity']), 1);
}
echo '<table border=0 class="w100p"><tr>';
echo '<td class="tactical_left_column" id="leftcolumn">';
// ---------------------------------------------------------------------
// The status horizontal bars (Global health, Monitor sanity...
// ---------------------------------------------------------------------
$bg_color = 'background-color: #222';
if ($config['style'] !== 'pandora_black' && !is_metaconsole()) {
$bg_color = 'background-color: #fff';
}
$table = new stdClass();
$table->width = '100%';
$table->class = 'info_table no-td-borders';
$table->cellpadding = 2;
$table->cellspacing = 2;
$table->border = 0;
$table->head = [];
$table->data = [];
$table->style = [$bg_color];
$stats = reporting_get_stats_indicators($data, 120, 10, false);
$statusTacticalTable = new stdClass();
$statusTacticalTable->width = '100%';
$statusTacticalTable->id = 'statusTacticalTable';
$statusTacticalTable->class = 'status_tactical tactical_table bg_white';
$statusTacticalTable->data = [];
foreach ($stats as $key => $stat) {
$statusTacticalTable->cellstyle['line_'.$key][0] = 'width: 40%;';
$statusTacticalTable->style['line_'.$key][1] = 'width: 60%;';
$statusTacticalTable->data['line_'.$key][0] = '<span>'.$stat['title'].'</span>';
$statusTacticalTable->data['line_'.$key][1] = $stat['graph'];
}
$status = html_print_table($statusTacticalTable, true);
$table->rowclass = [];
$table->rowclass[0] = 'w100p';
$table->rowclass[1] = 'w100p';
$table->rowclass[2] = 'w100p';
$table->rowclass[3] = 'w100p';
$table->rowclass[4] = 'w100p';
$table->data[0][0] = $status;
// ---------------------------------------------------------------------
// Monitor checks
// ---------------------------------------------------------------------
$data_agents = [
__('Critical') => $data['monitor_critical'],
__('Warning') => $data['monitor_warning'],
__('Normal') => $data['monitor_ok'],
__('Unknown') => $data['monitor_unknown'],
__('Not init') => $data['monitor_not_init'],
];
$table->data[1][0] = reporting_get_stats_alerts($data);
$table->rowclass[1] = 'w100p';
$table->data[2][0] = reporting_get_stats_modules_status($data, 180, 100, false, $data_agents);
$table->data[3][0] = reporting_get_stats_agents_monitors($data);
$table->rowclass[] = '';
// ---------------------------------------------------------------------
// Server performance
// ---------------------------------------------------------------------
if ($is_admin) {
$table->data[4][0] = reporting_get_stats_servers();
$table->rowclass[] = '';
}
ui_toggle(
html_print_table($table, true),
__('Report of State'),
'',
'',
false
);
echo '</td>';
// Left column
echo '<td class="w75p pdd_t_0px" id="rightcolumn">';
// ---------------------------------------------------------------------
// Last events information
// ---------------------------------------------------------------------
if (check_acl($config['id_user'], 0, 'ER')) {
$tags_condition = tags_get_acl_tags(false, 0, 'ER', 'event_condition');
$event_filter = 'estado<>1';
if (!empty($tags_condition)) {
$event_filter .= " AND ($tags_condition)";
}
if ($config['event_view_hr']) {
$event_filter .= ' AND utimestamp > (UNIX_TIMESTAMP(NOW()) - '.($config['event_view_hr'] * SECONDS_1HOUR).')';
}
$events = events_print_event_table($event_filter, 10, '100%', true, 0, true);
ui_toggle(
$events,
__('Latest events'),
'',
'',
false
);
}
// ---------------------------------------------------------------------
// Server information
// ---------------------------------------------------------------------
if ($is_admin) {
$tiny = true;
include $config['homedir'].'/godmode/servers/servers.build_table.php';
}
$out = '<table cellpadding=0 cellspacing=0 class="databox pies" width=100%><tr><td style="width:50%;">';
$out .= '<fieldset class="databox tactical_set" id="total_event_graph">';
$out .= '<legend>'.__('Event graph').'</legend>';
$out .= html_print_image('images/spinner.gif', true, ['id' => 'spinner_total_event_graph']);
$out .= '</fieldset>';
$out .= '</td><td style="width:50%;">';
$out .= '<fieldset class="databox tactical_set" id="graphic_event_group">
<legend>'.__('Event graph by agent').'</legend>'.html_print_image('images/spinner.gif', true, ['id' => 'spinner_graphic_event_group']).'</fieldset>';
$out .= '</td></tr></table>';
ui_toggle(
$out,
__('Event graphs'),
'',
'',
false
);
echo '</td>';
echo '</tr></table>';
?>
<script type="text/javascript">
$(document).ready(function () {
var parameters = {};
parameters["page"] = "include/ajax/events";
parameters["total_event_graph"] = 1;
$.ajax({type: "GET",url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",data: parameters,
success: function(data) {
$("#spinner_total_event_graph").hide();
$("#total_event_graph").append(data);
}
});
delete parameters["total_event_graph"];
parameters["graphic_event_group"] = 1;
$.ajax({type: "GET",url: "<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",data: parameters,
success: function(data) {
$("#spinner_graphic_event_group").hide();
$("#graphic_event_group").append(data);
}
});
});
$('.tactical_table .alert_module_background_state').replaceWith(function(){
return $("<div />").addClass($(this).attr('class')).data($(this).data());
});
</script>
$tacticalView = new GeneralTacticalView();
$tacticalView->render();

View File

@ -1,3 +1,4 @@
<?php global $config; ?>
<div id="welcome-message">
<?php echo $welcome; ?>
<span class="subtitle-welcome-message"><?php echo __('This is the latest data in your tactical view'); ?></span>
@ -262,7 +263,7 @@
<div class="row">
<div class="col-8 br-r">
<div class="subtitle link padding10 padding2">
<?php echo __('Number of events per hour (24 hrs)'); ?></b> <a href="index.php?sec=eventos&sec2=operation/events/events&filter[event_view_hr]=24&filter[tag_with]=WyIwIl0=&filter[tag_without]=WyIwIl0="><?php echo __('Info'); ?></a>
<?php echo __('Number of events per hour ('.$config['event_view_hr'].' hrs)'); ?></b> <a href="index.php?sec=eventos&sec2=operation/events/events&filter[event_view_hr]=24&filter[tag_with]=WyIwIl0=&filter[tag_without]=WyIwIl0="><?php echo __('Info'); ?></a>
</div>
<div id="events-last-24"><?php echo $Events->loading(); ?></div>
<div class="row br-t h100p">
@ -288,7 +289,7 @@
</div>
<div class="col-4">
<div class="subtitle link padding10 padding2">
<?php echo __('Active events (8 hrs)'); ?></b> <a href="index.php?sec=eventos&sec2=operation/events/events"><?php echo __('Info'); ?></a>
<?php echo __('Active events ('.$config['event_view_hr'].' hrs)'); ?></b> <a href="index.php?sec=eventos&sec2=operation/events/events"><?php echo __('Info'); ?></a>
</div>
<?php echo $Events->getDataTableEvents(); ?>
</div>
@ -364,9 +365,12 @@
<a href="index.php?sec=view&sec2=operation/agentes/estado_agente&status=5" class="col-4 flex flex-column center pdd_20px br-r">
<?php echo $Configurations->getNotInitModules(); ?>
</a>
<a href="index.php?sec=view&sec2=operation/agentes/estado_agente&status=3" class="col-4 flex flex-column center pdd_20px">
<a href="index.php?sec=view&sec2=operation/agentes/estado_agente&status=3" class="col-4 flex flex-column center pdd_20px br-r">
<?php echo $Configurations->getTotalUnknowAgents(); ?>
</a>
<a href="index.php?sec=eventos&sec2=operation/events/events" class="col-4 flex flex-column center pdd_20px">
<?php echo $Configurations->getTotalEvents(); ?>
</a>
</div>
</div>
<?php if ($ScheduledDowntime->checkAcl() === true) : ?>