WIP first tasks
Former-commit-id: 4fbdab2389d5727c44693b129baa4ceadc6934ae
This commit is contained in:
parent
ab453fde68
commit
d89e3993e7
|
@ -1,26 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Extension to self monitor Pandora FMS Console
|
||||
*
|
||||
* @category Main page
|
||||
* @package Pandora FMS
|
||||
* @subpackage Introduction
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||
* Please see http://pandorafms.org for full contribution list
|
||||
* 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
// 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; 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.
|
||||
require_once 'include/config.php';
|
||||
|
||||
// This solves problems in enterprise load
|
||||
// This solves problems in enterprise load.
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
/*
|
||||
Call all extensions login function */
|
||||
// extensions_call_login_function ();
|
||||
require_once 'include/functions_reporting.php';
|
||||
require_once 'include/functions_tactical.php';
|
||||
require_once $config['homedir'].'/include/functions_graph.php';
|
||||
|
@ -29,8 +42,18 @@ if (tags_has_user_acl_tags()) {
|
|||
ui_print_tags_warning();
|
||||
}
|
||||
|
||||
$user_strict = (bool) db_get_value('strict_acl', 'tusuario', 'id_user', $config['id_user']);
|
||||
$all_data = tactical_status_modules_agents($config['id_user'], $user_strict, 'AR', $user_strict);
|
||||
$user_strict = (bool) db_get_value(
|
||||
'strict_acl',
|
||||
'tusuario',
|
||||
'id_user',
|
||||
$config['id_user']
|
||||
);
|
||||
$all_data = tactical_status_modules_agents(
|
||||
$config['id_user'],
|
||||
$user_strict,
|
||||
'AR',
|
||||
$user_strict
|
||||
);
|
||||
$data = [];
|
||||
|
||||
$data['monitor_not_init'] = (int) $all_data['_monitors_not_init_'];
|
||||
|
@ -79,6 +102,8 @@ if (!empty($all_data)) {
|
|||
|
||||
$data['server_sanity'] = format_numeric((100 - $data['module_sanity']), 1);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<table border="0" width="100%">
|
||||
<tr>
|
||||
|
@ -88,7 +113,7 @@ if (!empty($all_data)) {
|
|||
|
||||
<?php
|
||||
//
|
||||
// Overview Table
|
||||
// Overview Table.
|
||||
//
|
||||
$table = new stdClass();
|
||||
$table->class = 'databox';
|
||||
|
@ -101,12 +126,12 @@ if (!empty($all_data)) {
|
|||
$table->head[0] = '<span>'.__('%s Overview', get_product_name()).'</span>';
|
||||
$table->head_colspan[0] = 4;
|
||||
|
||||
// Indicators
|
||||
// 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 .= '<tr><td><b>'.$stat['title'].'</b></td><td>'.$stat['graph'].'</td></tr>';
|
||||
}
|
||||
|
||||
$status .= '</table>';
|
||||
|
@ -115,25 +140,25 @@ if (!empty($all_data)) {
|
|||
|
||||
$table->data[] = $tdata;
|
||||
|
||||
// Alerts
|
||||
// Alerts.
|
||||
$tdata = [];
|
||||
$tdata[0] = reporting_get_stats_alerts($data);
|
||||
$table->rowclass[] = '';
|
||||
$table->data[] = $tdata;
|
||||
|
||||
// Modules by status
|
||||
// Modules by status.
|
||||
$tdata = [];
|
||||
$tdata[0] = reporting_get_stats_modules_status($data, 180, 100);
|
||||
$table->rowclass[] = '';
|
||||
$table->data[] = $tdata;
|
||||
|
||||
// Total agents and modules
|
||||
// Total agents and modules.
|
||||
$tdata = [];
|
||||
$tdata[0] = reporting_get_stats_agents_monitors($data);
|
||||
$table->rowclass[] = '';
|
||||
$table->data[] = $tdata;
|
||||
|
||||
// Users
|
||||
// Users.
|
||||
if (users_is_admin()) {
|
||||
$tdata = [];
|
||||
$tdata[0] = reporting_get_stats_users($data);
|
||||
|
@ -160,7 +185,7 @@ if (!empty($all_data)) {
|
|||
|
||||
|
||||
if (!empty($news)) {
|
||||
// NEWS BOARD/////////////////////////////
|
||||
// NEWS BOARD.
|
||||
echo '<div id="news_board">';
|
||||
|
||||
echo '<table cellpadding="0" width=100% cellspacing="0" class="databox filters">';
|
||||
|
@ -184,20 +209,72 @@ if (!empty($all_data)) {
|
|||
|
||||
echo '</table>';
|
||||
echo '</div>';
|
||||
// News board
|
||||
// News board.
|
||||
echo '<br><br>';
|
||||
|
||||
// END OF NEWS BOARD/////////////////////////////
|
||||
// END OF NEWS BOARD.
|
||||
}
|
||||
|
||||
// LAST ACTIVITY/////////////////////////////
|
||||
// Show last activity from this user
|
||||
$nots = messages_get_overview('utimestamp', 'DESC', false);
|
||||
if (!empty($nots)) {
|
||||
// Notifications board.
|
||||
echo '<div id="notifications_board">';
|
||||
|
||||
echo '<table cellpadding="0" width=100% cellspacing="0" class="databox filters">';
|
||||
echo '<tr><th style="text-align:center;"><span >'.__('Pending notifications').'</span></th></tr>';
|
||||
if ($config['prominent_time'] == 'timestamp') {
|
||||
$comparation_suffix = '';
|
||||
} else {
|
||||
$comparation_suffix = __('ago');
|
||||
}
|
||||
|
||||
foreach ($nots as $msg) {
|
||||
$conversation = io_safe_output(
|
||||
messages_get_conversation($msg)
|
||||
);
|
||||
|
||||
if (is_array($conversation)) {
|
||||
$text = array_pop($conversation)['message'];
|
||||
} else {
|
||||
// Skip empty message.
|
||||
continue;
|
||||
}
|
||||
|
||||
$url = ui_get_full_url(
|
||||
'index.php?sec=message_list&sec2=operation/messages/message_edit&read_message=1&id_message='.$msg['id_mensaje']
|
||||
);
|
||||
if ($msg['url'] != '') {
|
||||
$url = $msg['url'];
|
||||
}
|
||||
|
||||
echo '<tr><th class="green_title">'.$msg['subject'].'</th></tr>';
|
||||
echo '<tr><td><a href="'.$url.'">';
|
||||
if ($msg['id_usuario_origen'] != '') {
|
||||
echo '<b>'.get_user_fullname($msg['id_usuario_origen']).'</b> ';
|
||||
}
|
||||
|
||||
echo '<i>'.ui_print_timestamp($msg['timestamp'], true).'</i> '.$comparation_suffix.'</a></td></tr>';
|
||||
echo '<tr><td class="datos">';
|
||||
echo nl2br($text);
|
||||
echo '</td></tr>';
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<br><br>';
|
||||
|
||||
// EO Notifications board.
|
||||
}
|
||||
|
||||
// LAST ACTIVITY.
|
||||
// Show last activity from this user.
|
||||
echo '<div id="activity">';
|
||||
|
||||
$table = new stdClass();
|
||||
$table->class = 'databox data';
|
||||
$table->width = '100%';
|
||||
// Don't specify px
|
||||
// Don't specify px.
|
||||
$table->data = [];
|
||||
$table->size = [];
|
||||
$table->size[0] = '5%';
|
||||
|
@ -212,38 +289,14 @@ if (!empty($all_data)) {
|
|||
$table->head[3] = __('Source IP');
|
||||
$table->head[4] = __('Comments');
|
||||
$table->title = '<span>'.__('This is your last activity performed on the %s console', get_product_name()).'</span>';
|
||||
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
$sql = sprintf(
|
||||
'SELECT id_usuario,accion, ip_origen,descripcion,utimestamp
|
||||
$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']
|
||||
);
|
||||
break;
|
||||
$config['id_user']
|
||||
);
|
||||
|
||||
case 'postgresql':
|
||||
$sql = sprintf(
|
||||
"SELECT \"id_usuario\", accion, \"ip_origen\", descripcion, utimestamp
|
||||
FROM tsesion
|
||||
WHERE (\"utimestamp\" > ceil(date_part('epoch', CURRENT_TIMESTAMP)) - ".SECONDS_1WEEK.")
|
||||
AND \"id_usuario\" = '%s' ORDER BY \"utimestamp\" DESC LIMIT 10",
|
||||
$config['id_user']
|
||||
);
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
$sql = sprintf(
|
||||
"SELECT id_usuario, accion, ip_origen, descripcion, utimestamp
|
||||
FROM tsesion
|
||||
WHERE ((utimestamp > ceil((sysdate - to_date('19700101000000','YYYYMMDDHH24MISS')) * (".SECONDS_1DAY.')) - '.SECONDS_1WEEK.")
|
||||
AND id_usuario = '%s') AND rownum <= 10 ORDER BY utimestamp DESC",
|
||||
$config['id_user']
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
$sessions = db_get_all_rows_sql($sql);
|
||||
|
||||
|
@ -253,24 +306,17 @@ if (!empty($all_data)) {
|
|||
|
||||
foreach ($sessions as $session) {
|
||||
$data = [];
|
||||
$session_id_usuario = $session['id_usuario'];
|
||||
$session_ip_origen = $session['ip_origen'];
|
||||
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
case 'oracle':
|
||||
$session_id_usuario = $session['id_usuario'];
|
||||
$session_ip_origen = $session['ip_origen'];
|
||||
break;
|
||||
|
||||
case 'postgresql':
|
||||
$session_id_usuario = $session['id_usuario'];
|
||||
$session_ip_origen = $session['ip_origen'];
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$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[2] = ui_print_help_tip(
|
||||
date($config['date_format'], $session['utimestamp']),
|
||||
true
|
||||
).human_time_comparation($session['utimestamp'], 'tiny');
|
||||
$data[3] = $session_ip_origen;
|
||||
$description = str_replace([',', ', '], ', ', $session['descripcion']);
|
||||
if (strlen($description) > 100) {
|
||||
|
@ -287,8 +333,7 @@ if (!empty($all_data)) {
|
|||
unset($table);
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
// activity
|
||||
// END OF LAST ACTIVIYY/////////////////////////////
|
||||
// END OF LAST ACTIVIYY.
|
||||
?>
|
||||
|
||||
|
||||
|
|
|
@ -2115,7 +2115,7 @@ class ConsoleSupervisor
|
|||
if ($config['cron_last_run'] == 0
|
||||
|| (get_system_time() - $config['cron_last_run']) > 3600
|
||||
) {
|
||||
$message_conf_cron = __('DiscoveryConsoleTasks is not running properly');
|
||||
$message_conf_cron = __('DiscoveryConsoleTasks is not running properly.').' ';
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
|
||||
$message_conf_cron .= __('Discovery relies on a proper setup of cron, the time-based scheduling service');
|
||||
$message_conf_cron .= '. '.__('Please, add the following line to your crontab file:');
|
||||
|
|
|
@ -582,6 +582,56 @@ function messages_get_overview_sent(
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a message interpreted as a conversation.
|
||||
*
|
||||
* @param mixed $data Complete message or message id.
|
||||
*
|
||||
* @return mixed False if fails. A string array with the conversation.
|
||||
*/
|
||||
function messages_get_conversation($data)
|
||||
{
|
||||
if (is_array($data)) {
|
||||
$message = $data;
|
||||
} else {
|
||||
$message = messages_get_message($data);
|
||||
}
|
||||
|
||||
if (!isset($message) || !is_array($message)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$conversation = [];
|
||||
$target_str = $message['mensaje'];
|
||||
|
||||
while (preg_match_all(
|
||||
'/(.*)On(.*)wrote:(.*)/',
|
||||
$target_str,
|
||||
$decoded,
|
||||
PREG_PATTERN_ORDER
|
||||
) !== false && empty($target_str) !== true) {
|
||||
if (empty($decoded[2]) !== true) {
|
||||
array_push(
|
||||
$conversation,
|
||||
[
|
||||
'message' => array_pop($decoded)[0],
|
||||
'date' => array_pop($decoded)[0],
|
||||
]
|
||||
);
|
||||
} else {
|
||||
array_push(
|
||||
$conversation,
|
||||
['message' => $target_str]
|
||||
);
|
||||
}
|
||||
|
||||
$target_str = $decoded[1][0];
|
||||
}
|
||||
|
||||
return $conversation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the URL of a message. If field in db is null, it returs a link to
|
||||
* messages view.
|
||||
|
|
|
@ -114,32 +114,7 @@ if ($read_message) {
|
|||
|
||||
echo '<h2>Subject: '.$message['subject'].'</h2>';
|
||||
|
||||
$conversation = [];
|
||||
$target_str = $message['mensaje'];
|
||||
|
||||
while (preg_match_all(
|
||||
'/(.*)On(.*)wrote:(.*)/',
|
||||
$target_str,
|
||||
$decoded,
|
||||
PREG_PATTERN_ORDER
|
||||
) !== false && empty($target_str) !== true) {
|
||||
if (empty($decoded[2]) !== true) {
|
||||
array_push(
|
||||
$conversation,
|
||||
[
|
||||
'message' => array_pop($decoded)[0],
|
||||
'date' => array_pop($decoded)[0],
|
||||
]
|
||||
);
|
||||
} else {
|
||||
array_push(
|
||||
$conversation,
|
||||
['message' => $target_str]
|
||||
);
|
||||
}
|
||||
|
||||
$target_str = $decoded[1][0];
|
||||
}
|
||||
$conversation = messages_get_conversation($message);
|
||||
|
||||
ui_require_css_file('message_edit');
|
||||
foreach ($conversation as $row) {
|
||||
|
|
Loading…
Reference in New Issue