2013-03-15 15:50:47 +01:00
|
|
|
<?php
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2010 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.
|
|
|
|
|
2016-09-28 16:56:05 +02:00
|
|
|
include("../include/functions_tactical.php");
|
2013-03-15 15:50:47 +01:00
|
|
|
include("../include/functions_servers.php");
|
|
|
|
|
|
|
|
class Tactical {
|
|
|
|
private $correct_acl = false;
|
2016-09-28 16:56:05 +02:00
|
|
|
private $acl = "AR";
|
2013-03-15 15:50:47 +01:00
|
|
|
|
|
|
|
function __construct() {
|
|
|
|
$system = System::getInstance();
|
|
|
|
|
2016-09-28 16:56:05 +02:00
|
|
|
if ($system->checkACL($this->acl)) {
|
2013-03-15 15:50:47 +01:00
|
|
|
$this->correct_acl = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$this->correct_acl = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function show() {
|
|
|
|
if (!$this->correct_acl) {
|
|
|
|
$this->show_fail_acl();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$this->show_tactical();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-11 14:03:31 +01:00
|
|
|
public function ajax($parameter2 = false) {
|
|
|
|
$system = System::getInstance();
|
2016-09-28 16:56:05 +02:00
|
|
|
|
2014-02-11 14:03:31 +01:00
|
|
|
if (!$this->correct_acl) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch ($parameter2) {
|
|
|
|
case 'render_status_pie':
|
|
|
|
$links = $system->getRequest('links', '');
|
2018-05-21 15:19:25 +02:00
|
|
|
$links = $system->safeOutput($links);
|
2014-02-11 14:03:31 +01:00
|
|
|
$data = $system->getRequest('data', '');
|
2018-05-21 15:19:25 +02:00
|
|
|
$data = $system->safeOutput($data);
|
2016-09-28 16:56:05 +02:00
|
|
|
$data = str_replace('\\','',$data);
|
|
|
|
$links = str_replace('\\','',$links);
|
2014-02-11 14:03:31 +01:00
|
|
|
$width = $system->getRequest('width', 230);
|
|
|
|
|
|
|
|
$max_width = 399;
|
|
|
|
|
|
|
|
if($width > $max_width) {
|
|
|
|
$width = $max_width;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo reporting_get_stats_modules_status(json_decode($data, true), $width, $width/2, json_decode($links, true));
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-15 15:50:47 +01:00
|
|
|
private function show_fail_acl() {
|
2014-10-15 18:12:51 +02:00
|
|
|
$error['type'] = 'onStart';
|
2013-04-24 14:36:32 +02:00
|
|
|
$error['title_text'] = __('You don\'t have access to this page');
|
2018-05-11 14:24:26 +02:00
|
|
|
$error['content_text'] = System::getDefaultACLFailText();
|
2014-10-15 18:12:51 +02:00
|
|
|
if (class_exists("HomeEnterprise"))
|
|
|
|
$home = new HomeEnterprise();
|
|
|
|
else
|
|
|
|
$home = new Home();
|
2013-04-24 14:36:32 +02:00
|
|
|
$home->show($error);
|
2013-03-15 15:50:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private function show_tactical() {
|
|
|
|
$ui = Ui::getInstance();
|
|
|
|
|
|
|
|
$ui->createPage();
|
2013-11-28 17:54:18 +01:00
|
|
|
$ui->createDefaultHeader(__("Tactical view"),
|
2013-07-03 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/events.php, mobile/operation/module_graph.php,
mobile/operation/modules.php, mobile/operation/networkmaps.php,
mobile/operation/groups.php, mobile/operation/agents.php,
mobile/operation/tactical.php, mobile/operation/networkmap.php,
mobile/operation/alerts.php, mobile/operation/agent.php,
mobile/include/ui.class.php: added the back button in the head and
impoved the source code style to make more easy the merges with
the last branch.
* include/functions_graph.php: fixed PHP notices.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8468 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-07-03 15:59:38 +02:00
|
|
|
$ui->createHeaderButton(
|
|
|
|
array('icon' => 'back',
|
|
|
|
'pos' => 'left',
|
|
|
|
'text' => __('Back'),
|
2013-11-28 17:54:18 +01:00
|
|
|
'href' => 'index.php?page=home')));
|
2013-03-15 15:50:47 +01:00
|
|
|
$ui->showFooter(false);
|
|
|
|
$ui->beginContent();
|
|
|
|
$ui->contentBeginGrid('responsive');
|
2016-09-28 16:56:05 +02:00
|
|
|
//~ $data = reporting_get_group_stats();
|
|
|
|
$all_data = tactical_status_modules_agents($config['id_user'], $user_strict, 'AR', $user_strict);
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
|
|
|
|
$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['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);
|
|
|
|
}
|
|
|
|
|
2013-03-26 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_reporting.php, include/functions_groups.php:
changes for to use in the calls in mobile version.
* mobile/index.php, mobile/operation/events.php,
mobile/operation/modules.php, mobile/operation/events,
mobile/operation/events/events.php, mobile/operation/agents.php,
mobile/operation/tactical.php, mobile/operation/alerts.php,
mobile/include/style/main.css, mobile/include/ui.class.php,
mobile/include/user.class.php: changes and improves in the code
of mobile.
* mobile/operation/agents/*, mobile/operation/servers/*: removed
the old files from version pandora mobile 4.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7891 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-03-26 18:24:10 +01:00
|
|
|
$data['mobile'] = true;
|
|
|
|
|
2014-01-22 18:29:45 +01:00
|
|
|
$formatted_data = reporting_get_stats_indicators($data, 100, 10, false);
|
|
|
|
$formatted_data_untiny = reporting_get_stats_indicators($data, 140, 15, false);
|
2013-07-03 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/events.php, mobile/operation/module_graph.php,
mobile/operation/modules.php, mobile/operation/networkmaps.php,
mobile/operation/groups.php, mobile/operation/agents.php,
mobile/operation/tactical.php, mobile/operation/networkmap.php,
mobile/operation/alerts.php, mobile/operation/agent.php,
mobile/include/ui.class.php: added the back button in the head and
impoved the source code style to make more easy the merges with
the last branch.
* include/functions_graph.php: fixed PHP notices.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8468 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-07-03 15:59:38 +02:00
|
|
|
|
2014-01-22 18:29:45 +01:00
|
|
|
$overview = '<table class="tactical_bars">
|
2013-04-05 12:49:38 +02:00
|
|
|
<tr>
|
|
|
|
<td>' . $formatted_data['server_health']['title'] . '</td>
|
2014-01-22 18:29:45 +01:00
|
|
|
<td class="tiny tactical_bar">' . $formatted_data['server_health']['graph'] . '</td>
|
2014-02-10 12:54:39 +01:00
|
|
|
<td class="untiny tactical_bar">' . $formatted_data_untiny['server_health']['graph'] . '</td>
|
2013-04-05 12:49:38 +02:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>' . $formatted_data['monitor_health']['title'] . '</td>
|
2014-01-22 18:29:45 +01:00
|
|
|
<td class="tiny tactical_bar">' . $formatted_data['monitor_health']['graph'] . '</td>
|
2014-02-10 12:54:39 +01:00
|
|
|
<td class="untiny tactical_bar">' . $formatted_data_untiny['monitor_health']['graph'] . '</td>
|
2013-04-05 12:49:38 +02:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>' . $formatted_data['module_sanity']['title'] . '</td>
|
2014-01-22 18:29:45 +01:00
|
|
|
<td class="tiny tactical_bar">' . $formatted_data['module_sanity']['graph'] . '</td>
|
2014-02-10 12:54:39 +01:00
|
|
|
<td class="untiny tactical_bar">' . $formatted_data_untiny['module_sanity']['graph'] . '</td>
|
2013-04-05 12:49:38 +02:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>' . $formatted_data['alert_level']['title'] . '</td>
|
2014-01-22 18:29:45 +01:00
|
|
|
<td class="tiny tactical_bar">' . $formatted_data['alert_level']['graph'] . '</td>
|
2014-02-10 12:54:39 +01:00
|
|
|
<td class="untiny tactical_bar">' . $formatted_data_untiny['alert_level']['graph'] . '</td>
|
2013-04-05 12:49:38 +02:00
|
|
|
</tr>
|
|
|
|
</table>';
|
2014-01-22 18:29:45 +01:00
|
|
|
|
|
|
|
$agents_monitors = reporting_get_stats_agents_monitors($data);
|
|
|
|
$alerts_stats = reporting_get_stats_alerts($data);
|
|
|
|
|
|
|
|
$overview .= "<br />\n" . $agents_monitors;
|
|
|
|
$overview .= "<br />\n" . $alerts_stats;
|
2013-04-05 12:49:38 +02:00
|
|
|
|
2014-01-22 18:29:45 +01:00
|
|
|
$ui->contentGridAddCell($overview, 'tactical1');
|
|
|
|
|
2013-04-05 12:49:38 +02:00
|
|
|
$links['monitor_critical'] = "index.php?page=modules&status=1";
|
|
|
|
$links['monitor_warning'] = "index.php?page=modules&status=2";
|
|
|
|
$links['monitor_ok'] = "index.php?page=modules&status=0";
|
|
|
|
$links['monitor_unknown'] = "index.php?page=modules&status=3";
|
|
|
|
$links['monitor_not_init'] = "index.php?page=modules&status=5";
|
2014-02-11 14:03:31 +01:00
|
|
|
|
|
|
|
$formatted_data = "<div id='status_pie'></div>";
|
2016-09-28 16:56:05 +02:00
|
|
|
$formatted_data .= html_print_div (array('id' => 'status_pie_links','content' => io_safe_input(json_encode($links)), 'hidden' => '1'), true);
|
|
|
|
$formatted_data .= html_print_div (array('id' => 'status_pie_data','content' => io_safe_input(json_encode($data)), 'hidden' => '1'), true);
|
|
|
|
|
|
|
|
$formatted_data = $formatted_data;
|
2014-01-22 18:29:45 +01:00
|
|
|
$ui->contentGridAddCell($formatted_data, 'tactical2');
|
2013-03-15 15:50:47 +01:00
|
|
|
$ui->contentEndGrid();
|
|
|
|
|
|
|
|
$this->getLastActivity();
|
|
|
|
$ui->contentBeginCollapsible(__('Last activity'));
|
|
|
|
|
|
|
|
$table = new Table();
|
|
|
|
$table->importFromHash($this->getLastActivity());
|
|
|
|
$ui->contentCollapsibleAddItem($table->getHTML());
|
|
|
|
$ui->contentEndCollapsible();
|
2014-02-10 18:03:08 +01:00
|
|
|
$ui->contentAddHtml("<script type=\"text/javascript\">
|
2015-06-08 11:05:19 +02:00
|
|
|
$(document).ready(function() {
|
2014-02-10 18:03:08 +01:00
|
|
|
function set_same_heigth() {
|
|
|
|
//Set same height to boxes
|
|
|
|
var max_height = 0;
|
2014-02-11 14:03:31 +01:00
|
|
|
if ($('#tactical1').height() > $('#tactical2 .tactical_set').height()) {
|
2014-02-10 18:03:08 +01:00
|
|
|
max_height = $('#tactical1').height();
|
2014-02-11 14:03:31 +01:00
|
|
|
$('#tactical2 .tactical_set').height(max_height);
|
2014-02-10 18:03:08 +01:00
|
|
|
}
|
|
|
|
else {
|
2014-02-11 14:03:31 +01:00
|
|
|
max_height = $('#tactical2 .tactical_set').height();
|
2017-02-13 16:06:17 +01:00
|
|
|
//~ $('#tactical1').height(max_height);
|
2014-02-10 18:03:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-11 14:03:31 +01:00
|
|
|
function ajax_load_status_pie() {
|
|
|
|
$('#status_pie').html('<div style=\"text-align: center\"> " . __('Loading...') . "<br /><img src=\"images/ajax-loader.gif\" /></div>');
|
|
|
|
|
|
|
|
var pie_width = $('#tactical2').width() * 0.9;
|
|
|
|
|
|
|
|
postvars = {};
|
|
|
|
postvars[\"action\"] = \"ajax\";
|
|
|
|
postvars[\"parameter1\"] = \"tactical\";
|
|
|
|
postvars[\"parameter2\"] = \"render_status_pie\";
|
2016-09-28 16:56:05 +02:00
|
|
|
postvars[\"links\"] = $('#status_pie_links').text();
|
|
|
|
postvars[\"data\"] = $('#status_pie_data').text();
|
2014-02-11 14:03:31 +01:00
|
|
|
postvars[\"width\"] = pie_width;
|
|
|
|
$.post(\"index.php\",
|
|
|
|
postvars,
|
|
|
|
function (data) {
|
|
|
|
$('#status_pie').html(data);
|
|
|
|
set_same_heigth();
|
|
|
|
},
|
|
|
|
\"html\");
|
|
|
|
}
|
|
|
|
|
2014-02-10 18:03:08 +01:00
|
|
|
// Detect orientation change to refresh dinamic content
|
|
|
|
$(window).on({
|
|
|
|
orientationchange: function(e) {
|
2014-02-11 14:03:31 +01:00
|
|
|
// Refresh events bar
|
|
|
|
ajax_load_status_pie();
|
|
|
|
|
2014-02-10 18:03:08 +01:00
|
|
|
// Keep same height on boxes
|
|
|
|
if ($('.ui-block-b').css('float') == 'none') {
|
|
|
|
$('#tactical1').height('auto');
|
|
|
|
$('#tactical2').height('auto');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
set_same_heigth();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if ($('.ui-block-b').css('float') != 'none') {
|
|
|
|
set_same_heigth();
|
|
|
|
}
|
2014-02-11 14:03:31 +01:00
|
|
|
|
|
|
|
ajax_load_status_pie();
|
2014-02-10 18:03:08 +01:00
|
|
|
});
|
|
|
|
</script>");
|
2013-03-15 15:50:47 +01:00
|
|
|
$ui->endContent();
|
|
|
|
$ui->showPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getLastActivity() {
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
switch ($config["dbtype"]) {
|
|
|
|
case "mysql":
|
|
|
|
$sql = sprintf ("SELECT id_usuario,accion,fecha,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;
|
|
|
|
case "postgresql":
|
|
|
|
$sql = sprintf ("SELECT \"id_usuario\", accion, fecha, \"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, fecha, 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);
|
|
|
|
|
|
|
|
if ($sessions === false)
|
2015-06-08 13:13:09 +02:00
|
|
|
$sessions = array ();
|
2013-03-15 15:50:47 +01:00
|
|
|
|
|
|
|
$return = array();
|
|
|
|
foreach ($sessions as $session) {
|
|
|
|
$data = array();
|
|
|
|
|
|
|
|
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[__("Action")] = ui_print_session_action_icon ($session['accion'], true);
|
2014-01-22 18:29:45 +01:00
|
|
|
$data[__("User")] = $session_id_usuario;
|
|
|
|
$data[__("Date")] = human_time_comparation($session['utimestamp'], 'tiny');
|
2013-03-15 15:50:47 +01:00
|
|
|
$data[__("Source IP")] = $session_ip_origen;
|
|
|
|
$data[__("Description")] = io_safe_output ($session['descripcion']);
|
|
|
|
|
|
|
|
$return[] = $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|