2012-12-09 Sancho Lerena <slerena@artica.es>

Ported new feature (Command Snapshot) from 4.0.3 code.

        *  include/javascript/pandora.js: Added new javascript function
        to open a generic URL with custom width / height.

        * operation/agentes/snapshot_view.php: New feature for command
        snapshot rendering.

        * operation/agentes/datos_agente.php,
        operation/agentes/estado_monitores.php: Changes for new feature
        command snapshot monitoring.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7242 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2012-12-09 22:31:29 +00:00
parent 8286587bcb
commit 74634b8676
6 changed files with 234 additions and 101 deletions

View File

@ -1,3 +1,18 @@
2012-12-09 Sancho Lerena <slerena@artica.es>
Ported new feature (Command Snapshot) from 4.0.3 code.
* include/javascript/pandora.js: Added new javascript function
to open a generic URL with custom width / height.
* operation/agentes/snapshot_view.php: New feature for command
snapshot rendering.
* operation/agentes/datos_agente.php,
operation/agentes/estado_monitores.php: Changes for new feature
command snapshot monitoring.
2012-12-07 Sergio Martin <sergio.martin@artica.es>
* include/functions_categories.php: Add categories

View File

@ -16,6 +16,12 @@ function winopeng (url, wid) {
status = wid;
}
function winopeng_var (url, wid, width, height) {
open (url, wid,"width="+width+",height="+height+",status=no,toolbar=no,menubar=no,scrollbar=yes");
// WARNING !! Internet Explorer DOESNT SUPPORT "-" CARACTERS IN WINDOW HANDLE VARIABLE
status = wid;
}
function open_help (help_id) {
open ("general/pandora_help.php?id="+help_id, "pandorahelp", "width=650,height=500,status=0,toolbar=0,menubar=0,scrollbars=1,location=0");
}

View File

@ -233,7 +233,29 @@ foreach ($result as $row) {
$data = array ();
foreach($columns as $col => $attr) {
if ($attr[1] != "modules_format_data")
$data[] = $attr[1] ($row[$attr[0]]);
// Its a single-data, multiline data (data snapshot) ?
elseif (preg_match ("/[\n]+/i", $row[$attr[0]])){
// Detect string data with \n and convert to <br>'s
$datos = preg_replace ('/\n/i','<br>',$row[$attr[0]]);
$datos = preg_replace ('/\s/i','&nbsp;',$datos);
// Because this *SHIT* of print_table monster, I cannot format properly this cells
// so, eat this, motherfucker :))
$datos = "<span style='font-family: lucida console'>".$datos."</span>";
// I dont why, but using index (value) method, data is automatically converted to html entities ¿?
$data[$attr[1]]=$datos;
} else {
// Just a string of alphanumerical data... just do print
$data[$attr[1]]=$row[$attr[0]];
}
}
array_push ($table->data, $data);

View File

@ -439,6 +439,24 @@ foreach ($modules as $module) {
}
else {
$module_value = io_safe_output($module["datos"]);
// There are carriage returns here ?
// If carriage returns present... then is a "Snapshot" data (full command output)
if (preg_match ("/[\n]+/i", io_safe_output($module["datos"]))){
$handle = "snapshot"."_".$module["id_agente_modulo"];
$url = 'include/procesos.php?agente='.$module["id_agente_modulo"];
$win_handle=dechex(crc32($handle));
$link ="winopeng_var('operation/agentes/snapshot_view.php?id=".$module["id_agente_modulo"]."&refr=".$module["current_interval"]."&label=".$module["nombre"]."','".$win_handle."', 700,480)";
$salida = '<a href="javascript:'.$link.'">' . html_print_image("images/default_list.png", true, array("border" => '0', "alt" => "", "title" => __("Snapshot view"))) . '</a> &nbsp;&nbsp;';
// $link ="winopeng('operation/agentes/snapshot_view.php?id=".$module["id_agente_modulo"]."',$win_handle)";
// $salida = '<a href="javascript:'.$link.'">' . html_print_image("images/default_list.png", true, array("border" => '0', "alt" => "")) . '</a> &nbsp;&nbsp;';
} else {
$sub_string = substr(io_safe_output($module["datos"]),0, 12);
if ($module_value == $sub_string) {
@ -452,6 +470,7 @@ foreach ($modules as $module) {
}
}
}
}
$data[6] = ui_print_module_warn_value ($module["max_warning"], $module["min_warning"], $module["str_warning"], $module["max_critical"], $module["min_critical"], $module["str_critical"]);

View File

@ -0,0 +1,71 @@
<?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.
// Global & session management
require_once ('../../include/config.php');
require_once ('../../include/auth/mysql.php');
if (! isset($_SESSION['id_usuario'])) {
session_start();
session_write_close();
}
require_once ($config['homedir'] . '/include/functions.php');
require_once ($config['homedir'] . '/include/functions_db.php');
require_once ($config['homedir'] . '/include/functions_ui.php');
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');
$label = get_parameter ("label");
// TODO - Put ACL here
// Parsing the refresh before sending any header
$refresh = (int) get_parameter ("refr", -1);
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" />
<title>Pandora FMS Snapshot data view for module (<?php echo $label; ?>)</title>
<body style='background:#000; color: #ccc;'>
<?php
$row = db_get_row_sql("SELECT * FROM tagente_estado WHERE id_agente_modulo = $id");
echo "<h2>";
echo __("Current data at");
echo " ";
echo $row["timestamp"];
echo "</h2>";
$datos = io_safe_output($row["datos"]);
$datos = preg_replace ('/\n/i','<br>',$datos);
$datos = preg_replace ('/\s/i','&nbsp;',$datos);
echo "<div style='padding: 10px; font-size: 14px; line-height: 16px; font-family: mono; text-align: left'>";
echo $datos;
echo "</div>";