2006-03-27 05:37:27 +02:00
|
|
|
<?php
|
2019-03-04 20:02:35 +01:00
|
|
|
/**
|
|
|
|
* Extension to self monitor Pandora FMS Console
|
|
|
|
*
|
|
|
|
* @category Main page
|
|
|
|
* @package Pandora FMS
|
|
|
|
* @subpackage Introduction
|
|
|
|
* @version 1.0.0
|
|
|
|
* @license See below
|
|
|
|
*
|
|
|
|
* ______ ___ _______ _______ ________
|
2023-06-08 12:42:10 +02:00
|
|
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
|
|
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
2019-03-04 20:02:35 +01:00
|
|
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
|
|
|
*
|
|
|
|
* ============================================================================
|
2023-06-08 11:53:13 +02:00
|
|
|
* Copyright (c) 2005-2023 Pandora FMS
|
2023-06-08 13:19:01 +02:00
|
|
|
* Please see https://pandorafms.com/community/ for full contribution list
|
2019-03-04 20:02:35 +01:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation for version 2.
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Config functions.
|
2019-01-30 16:18:44 +01:00
|
|
|
require_once 'include/config.php';
|
2008-11-11 15:24:34 +01:00
|
|
|
|
2019-03-04 20:02:35 +01:00
|
|
|
// This solves problems in enterprise load.
|
2009-01-20 21:01:25 +01:00
|
|
|
global $config;
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
check_login();
|
2023-05-23 10:53:08 +02:00
|
|
|
// 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;
|
|
|
|
}
|
2008-08-05 12:47:40 +02:00
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
require_once 'include/functions_reporting.php';
|
|
|
|
require_once 'include/functions_tactical.php';
|
|
|
|
require_once $config['homedir'].'/include/functions_graph.php';
|
2008-11-11 15:24:34 +01:00
|
|
|
|
2014-06-10 16:34:27 +02:00
|
|
|
if (tags_has_user_acl_tags()) {
|
2019-01-30 16:18:44 +01:00
|
|
|
ui_print_tags_warning();
|
2013-01-10 17:00:30 +01:00
|
|
|
}
|
2014-06-10 16:34:27 +02:00
|
|
|
|
2019-03-04 20:02:35 +01:00
|
|
|
$all_data = tactical_status_modules_agents(
|
|
|
|
$config['id_user'],
|
2022-06-06 11:14:09 +02:00
|
|
|
false,
|
|
|
|
'AR'
|
2019-03-04 20:02:35 +01:00
|
|
|
);
|
2019-01-30 16:18:44 +01:00
|
|
|
$data = [];
|
2014-06-10 16:34:27 +02:00
|
|
|
|
2015-11-18 16:31:44 +01:00
|
|
|
$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_'];
|
2021-07-19 13:20:00 +02:00
|
|
|
$data['monitor_total'] = (int) $all_data['_monitor_total_'];
|
|
|
|
|
2015-11-18 16:31:44 +01:00
|
|
|
|
|
|
|
$data['total_agents'] = (int) $all_data['_total_agents_'];
|
|
|
|
|
2019-01-30 16:18:44 +01:00
|
|
|
$data['monitor_checks'] = (int) $all_data['_monitor_checks_'];
|
2015-11-18 16:31:44 +01:00
|
|
|
if (!empty($all_data)) {
|
2019-01-30 16:18:44 +01:00
|
|
|
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);
|
2015-11-18 16:31:44 +01:00
|
|
|
}
|
2019-03-04 20:02:35 +01:00
|
|
|
|
2019-06-04 13:57:55 +02:00
|
|
|
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>';
|
2023-01-10 10:18:37 +01:00
|
|
|
$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';
|
2019-06-04 13:57:55 +02:00
|
|
|
$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 = [];
|
2022-08-30 14:58:19 +02:00
|
|
|
|
|
|
|
$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);
|
2019-06-04 13:57:55 +02:00
|
|
|
$table->rowclass[] = '';
|
|
|
|
$table->data[] = $tdata;
|
|
|
|
|
|
|
|
// Total agents and modules.
|
|
|
|
$tdata = [];
|
|
|
|
$tdata[0] = reporting_get_stats_agents_monitors($data);
|
|
|
|
$table->rowclass[] = '';
|
|
|
|
$table->data[] = $tdata;
|
|
|
|
|
|
|
|
// Users.
|
2020-05-26 13:38:03 +02:00
|
|
|
if (users_is_admin() || check_acl($config['id_user'], 0, 'UM')) {
|
2019-06-04 13:57:55 +02:00
|
|
|
$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.
|
2019-08-12 09:36:16 +02:00
|
|
|
require_once 'general/news_dialog.php';
|
2019-06-04 13:57:55 +02:00
|
|
|
$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');
|
|
|
|
}
|
|
|
|
|
2019-08-12 09:36:16 +02:00
|
|
|
|
2019-06-04 13:57:55 +02:00
|
|
|
$output_news = '<div id="news_board" class="new">';
|
|
|
|
foreach ($news as $article) {
|
2023-05-08 08:49:35 +02:00
|
|
|
$default = false;
|
2019-06-04 13:57:55 +02:00
|
|
|
if ($article['text'] == '&lt;p style="text-align: center; font-size: 13px;"&gt;Hello, congratulations, if you've arrived here you already have an operational monitoring console. Remember that our forums and online documentation are available 24x7 to get you out of any trouble. You can replace this message with a personalized one at Admin tools -&amp;gt; Site news.&lt;/p&gt; ') {
|
2023-05-08 08:49:35 +02:00
|
|
|
$article['subject'] = __('Welcome to Pandora FMS Console');
|
|
|
|
$default = true;
|
2019-06-04 13:57:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$text_bbdd = io_safe_output($article['text']);
|
|
|
|
$text = html_entity_decode($text_bbdd);
|
2023-05-08 08:49:35 +02:00
|
|
|
|
|
|
|
$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>';
|
2019-06-04 13:57:55 +02:00
|
|
|
$output_news .= '<div class="new content">';
|
2023-05-08 08:49:35 +02:00
|
|
|
|
|
|
|
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 {
|
|
|
|
$output_news .= nl2br($text);
|
2019-06-04 13:57:55 +02:00
|
|
|
}
|
|
|
|
|
2023-05-08 08:49:35 +02:00
|
|
|
$output_news .= '</div></div>';
|
2019-06-04 13:57:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$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;
|
2022-05-03 11:36:06 +02:00
|
|
|
$description = io_safe_output(str_replace([',', ', '], ', ', $session['descripcion']));
|
2019-06-04 13:57:55 +02:00
|
|
|
if (strlen($description) > 100) {
|
2022-05-03 11:36:06 +02:00
|
|
|
$data[4] = '<div >'.io_safe_input(substr($description, 0, 150)).'...</div>';
|
2019-06-04 13:57:55 +02:00
|
|
|
} else {
|
2022-05-03 11:36:06 +02:00
|
|
|
$data[4] = '<div >'.io_safe_input($description).'</div>';
|
2019-06-04 13:57:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
array_push($table->data, $data);
|
|
|
|
}
|
|
|
|
|
2022-05-13 12:54:58 +02:00
|
|
|
$activity = html_print_table($table, true);
|
2019-06-04 13:57:55 +02:00
|
|
|
unset($table);
|
|
|
|
|
|
|
|
ui_toggle(
|
|
|
|
$activity,
|
|
|
|
__('Latest activity'),
|
|
|
|
'',
|
|
|
|
'activity',
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
'',
|
|
|
|
'white-box-content padded'
|
|
|
|
);
|
|
|
|
// END OF LAST ACTIVIYY.
|
|
|
|
// Close right panel.
|
|
|
|
echo '</div>';
|
2019-03-04 20:02:35 +01:00
|
|
|
|
2019-06-04 13:57:55 +02:00
|
|
|
// Close welcome panel.
|
|
|
|
echo '</div>';
|