2016-10-14 11:27:54 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2009 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-11-18 13:01:13 +01:00
|
|
|
if (! isset($_SESSION['id_usuario'])) {
|
2016-10-14 11:27:54 +02:00
|
|
|
session_start();
|
|
|
|
//session_write_close();
|
|
|
|
}
|
|
|
|
|
2016-11-18 13:01:13 +01:00
|
|
|
require_once ('../../include/config.php');
|
2016-10-14 11:27:54 +02:00
|
|
|
require_once ($config['homedir'] . '/include/auth/mysql.php');
|
|
|
|
require_once ($config['homedir'] . '/include/functions.php');
|
|
|
|
require_once ($config['homedir'] . '/include/functions_db.php');
|
|
|
|
require_once ($config['homedir'] . '/include/functions_reporting.php');
|
|
|
|
require_once ($config['homedir'] . '/include/functions_graph.php');
|
|
|
|
require_once ($config['homedir'] . '/include/functions_modules.php');
|
|
|
|
require_once ($config['homedir'] . '/include/functions_agents.php');
|
|
|
|
require_once ($config['homedir'] . '/include/functions_tags.php');
|
2018-08-02 14:32:12 +02:00
|
|
|
enterprise_include_once('include/functions_agents.php');
|
2016-10-14 11:27:54 +02:00
|
|
|
|
|
|
|
check_login ();
|
|
|
|
|
|
|
|
$user_language = get_user_language ($config['id_user']);
|
|
|
|
if (file_exists ('../../include/languages/'.$user_language.'.mo')) {
|
|
|
|
$l10n = new gettext_reader (new CachedFileReader ('../../include/languages/'.$user_language.'.mo'));
|
|
|
|
$l10n->load_tables();
|
|
|
|
}
|
|
|
|
|
|
|
|
$id = get_parameter('id');
|
2018-08-02 13:02:33 +02:00
|
|
|
$id_node = get_parameter("id_node", 0);
|
|
|
|
|
|
|
|
// Get the data
|
|
|
|
if ($id_node > 0) {
|
2018-08-02 13:42:39 +02:00
|
|
|
$connection = metaconsole_get_connection_by_id($id_node);
|
2018-08-02 13:02:33 +02:00
|
|
|
if (metaconsole_load_external_db($connection) != NOERR) {
|
2018-08-02 14:32:12 +02:00
|
|
|
ui_print_error_message(__('Cannot connect with node to display the module data.'));
|
2018-08-02 13:02:33 +02:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$row_module = modules_get_agentmodule($id);
|
2018-10-30 16:12:48 +01:00
|
|
|
|
|
|
|
// Retrieve data
|
|
|
|
$utimestamp = get_parameter("timestamp", '');
|
|
|
|
if($utimestamp == '') {
|
|
|
|
// Retrieve last data
|
|
|
|
$row_state = db_get_row('tagente_estado', 'id_agente_modulo', $id);
|
|
|
|
$last_timestamp = $row_state['timestamp'];
|
|
|
|
} else {
|
|
|
|
// Retrieve target data
|
|
|
|
$state = db_get_row('tagente_estado', 'id_agente_modulo', $id, array('id_agente'));
|
|
|
|
$row_state = db_get_row_filter('tagente_datos_string', array('id_agente_modulo' => $id, 'utimestamp' => $utimestamp));
|
|
|
|
$row_state['id_agente'] = $state['id_agente'];
|
|
|
|
$last_timestamp = date("Y-m-d H:i:s", $row_state['utimestamp']);
|
|
|
|
}
|
2018-08-02 14:32:12 +02:00
|
|
|
|
2018-08-02 13:02:33 +02:00
|
|
|
// Build the info
|
|
|
|
$label = get_parameter ("label", io_safe_output($row_module['module_name']));
|
|
|
|
$last_data = io_safe_output($row_state["datos"]);
|
|
|
|
$refresh = (int) get_parameter ("refr", $row_state['current_interval']);
|
|
|
|
|
2018-08-02 14:32:12 +02:00
|
|
|
// ACL check
|
|
|
|
$all_groups = agents_get_all_groups_agent ($row_state['id_agente']);
|
|
|
|
if (!check_acl_one_of_groups($config['id_user'], $all_groups, "AR")) {
|
|
|
|
require ($config['homedir'] . "/general/noaccess.php");
|
|
|
|
exit;
|
|
|
|
}
|
2016-10-14 11:27:54 +02:00
|
|
|
?>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<?php
|
|
|
|
// Parsing the refresh before sending any header
|
|
|
|
if ($refresh > 0) {
|
|
|
|
$query = ui_get_url_refresh (false);
|
|
|
|
echo '<meta http-equiv="refresh" content="'.$refresh.'; URL='.$query.'" />';
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
2018-05-11 15:17:53 +02:00
|
|
|
<title><?php echo __("%s Snapshot data view for module (%s)", get_product_name(), $label); ?></title>
|
2016-10-14 11:27:54 +02:00
|
|
|
<script type='text/javascript' src='../../include/javascript/jquery-1.7.1.js'></script>
|
|
|
|
</head>
|
|
|
|
<body style='background:#000; color: #ccc;'>
|
|
|
|
<?php
|
2016-12-07 17:08:32 +01:00
|
|
|
echo "<h2 style='text-align:center;' id='title_snapshot_view'>";
|
2018-08-02 13:02:33 +02:00
|
|
|
echo __("Current data at %s", $last_timestamp);
|
2016-10-14 11:27:54 +02:00
|
|
|
echo "</h2>";
|
2018-03-12 15:17:59 +01:00
|
|
|
if (is_image_data($last_data)) {
|
|
|
|
echo '<center><img src="' . $last_data . '" alt="image" style="width:100%"/></center>';
|
2016-10-14 11:27:54 +02:00
|
|
|
}
|
|
|
|
else {
|
2018-07-27 14:07:02 +02:00
|
|
|
$last_data = preg_replace ('/</', '<', $last_data);
|
|
|
|
$last_data = preg_replace ('/>/', '>', $last_data);
|
|
|
|
$last_data = preg_replace ('/\n/i','<br>',$last_data);
|
|
|
|
$last_data = preg_replace ('/\s/i',' ',$last_data);
|
|
|
|
echo "<div id='result_div' style='width: 100%; height: 100%; padding: 10px; font-size: 14px; line-height: 16px; font-family: mono,monospace; text-align: left'>";
|
2018-03-12 15:17:59 +01:00
|
|
|
echo $last_data;
|
2016-10-14 11:27:54 +02:00
|
|
|
echo "</div>";
|
|
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
|
|
function getScrollbarWidth() {
|
2018-07-27 14:07:02 +02:00
|
|
|
var div = $('<div style=""></div>');
|
2016-10-14 11:27:54 +02:00
|
|
|
$('body').append(div);
|
|
|
|
var w1 = $('div', div).innerWidth();
|
|
|
|
div.css('overflow-y', 'auto');
|
|
|
|
var w2 = $('div', div).innerWidth();
|
|
|
|
$(div).remove();
|
2018-03-12 15:17:59 +01:00
|
|
|
|
2016-10-14 11:27:54 +02:00
|
|
|
return (w1 - w2);
|
|
|
|
}
|
2018-03-12 15:17:59 +01:00
|
|
|
|
2016-10-14 11:27:54 +02:00
|
|
|
$(document).ready(function() {
|
|
|
|
width = $("#result_div").css("width");
|
|
|
|
width = width.replace("px", "");
|
|
|
|
width = parseInt(width);
|
|
|
|
$("#result_div").css("width", (width - getScrollbarWidth()) + "px");
|
2018-03-12 15:17:59 +01:00
|
|
|
|
2016-10-14 11:27:54 +02:00
|
|
|
height = $("#result_div").css("height");
|
|
|
|
height = height.replace("px", "");
|
|
|
|
height = parseInt(height);
|
|
|
|
$("#result_div").css("height", (height - getScrollbarWidth() - $("#title_snapshot_view").height() - 16) + "px");
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</body>
|
|
|
|
</html>
|