2008-06-17 Esteban Sanchez <estebans@artica.es>

* ajax.php: Added to repository. AJAX interface for Pandora. A new
	time is coming...

	* pandoradb.sql: Added id_group to treport. A report is now assigned
	to a group of agents. Changes in treport_content to add an order
	field, drop sla fields and use an enum for the type. NOTE: This will
	break all your current defined reports, update under your
	responsabillity. Added table treport_content_sla_combined to define
	SLAs in the SLA types reports.

	* godmode/reporting/graph_builder.php: Use Pandora functions. Adde
	javascript code to display the module icon when changing from the
	dropdown menu.

	* godmode/reporting/reporting_builder.php: Almost complet rewritten to
	use Pandora HTML functions. Style correction.

	* include/functions.php: Added new report types. Style correction.

	* include/functions_db.php: Use Pandora database functions to get
	simple values. Added functions get_agents_in_group(),
	get_modules_in_agent(), get_simple_alerts_in_agent(),
	get_combined_alerts_in_agent(), get_alerts_in_agent(),
	get_monitor_downs_in_period(),
	get_monitor_last_down_timestamp_in_period(),
	get_alert_fires_in_period(),
	get_alert_last_fire_timestamp_in_period(). Deleted debug output and
	fixed calling to an inexistent function in
	return_moduledata_sum_value().

	* include/functions_html.php: Tab style correction. Thanks to Ramon
	for the advice. Fixed some errors on print_table that was causing not
	to work fine if rowclass or colspan was defined.

	* include/functions_reporting.php: Adde date support to
	return_module_SLA(), event_reporting(). Added alert_reporting(),
	monitor_health_reporting(), general_group_reporting() and
	agents_detailed_reporting() to implement new report types. Style
	correction.

	* include/javascript/pandora.js: Added html_entity_decode() function
	to decode some AJAX results.

	* javascript/jquery.js: Added to repository. jQuery version 1.2.4a

	* include/javascript/jquery.timeentry.js: jQuery plugin to manage time
	inputs.

	* include/javascript/jquery.ui.datepicker.js: jQuery plugin to manage
	date inputs in a dropdown calendar.

	* include/languages/date_*.js, include/languages/time_*.js: Added to
	repository. Translation of date and time strings for the new calendar
	javascript support.

	* include/languages/language_en.php: Added new strings relatives to
	reports.

	* include/languages/language_de.php,
	include/languages/language_fr.php, include/languages/language_gl.php,
	include/languages/language_pt_br.php: Fixed a variable name.

	* godmode/groups/group_list.php: Avoid the use of an extra indentation
	by returning if no success on comprueba_login().

	* include/styles/pandora.css: Add some classes. Tab style correction.

	* operation/agentes/ver_agente.php: Added AJAX support to agent
	operations.

	* operation/reporting/graph_viewer.php: Period dropdown selection
	improved and printed with Pandora functions.

	* operation/reporting/reporting_viewer.php: Massive rewritten.
	Implemented date and time support, added new report types, use Pandora
	functions...

	* reporting/fgraph.php: Documentation fix. Added a new graphic to show
	monitors health.

	* godmode/agentes/agent_manager.php,
	operation/reporting/custom_reporting.php: Style correction.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@869 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2008-06-17 14:30:44 +00:00
parent f41b26f14c
commit 00b5a1eaec
39 changed files with 3590 additions and 1034 deletions

View File

@ -1,3 +1,88 @@
2008-06-17 Esteban Sanchez <estebans@artica.es>
* ajax.php: Added to repository. AJAX interface for Pandora. A new
time is coming...
* pandoradb.sql: Added id_group to treport. A report is now assigned
to a group of agents. Changes in treport_content to add an order
field, drop sla fields and use an enum for the type. NOTE: This will
break all your current defined reports, update under your
responsabillity. Added table treport_content_sla_combined to define
SLAs in the SLA types reports.
* godmode/reporting/graph_builder.php: Use Pandora functions. Adde
javascript code to display the module icon when changing from the
dropdown menu.
* godmode/reporting/reporting_builder.php: Almost complet rewritten to
use Pandora HTML functions. Style correction.
* include/functions.php: Added new report types. Style correction.
* include/functions_db.php: Use Pandora database functions to get
simple values. Added functions get_agents_in_group(),
get_modules_in_agent(), get_simple_alerts_in_agent(),
get_combined_alerts_in_agent(), get_alerts_in_agent(),
get_monitor_downs_in_period(),
get_monitor_last_down_timestamp_in_period(),
get_alert_fires_in_period(),
get_alert_last_fire_timestamp_in_period(). Deleted debug output and
fixed calling to an inexistent function in
return_moduledata_sum_value().
* include/functions_html.php: Tab style correction. Thanks to Ramon
for the advice. Fixed some errors on print_table that was causing not
to work fine if rowclass or colspan was defined.
* include/functions_reporting.php: Adde date support to
return_module_SLA(), event_reporting(). Added alert_reporting(),
monitor_health_reporting(), general_group_reporting() and
agents_detailed_reporting() to implement new report types. Style
correction.
* include/javascript/pandora.js: Added html_entity_decode() function
to decode some AJAX results.
* javascript/jquery.js: Added to repository. jQuery version 1.2.4a
* include/javascript/jquery.timeentry.js: jQuery plugin to manage time
inputs.
* include/javascript/jquery.ui.datepicker.js: jQuery plugin to manage
date inputs in a dropdown calendar.
* include/languages/date_*.js, include/languages/time_*.js: Added to
repository. Translation of date and time strings for the new calendar
javascript support.
* include/languages/language_en.php: Added new strings relatives to
reports.
* include/languages/language_de.php,
include/languages/language_fr.php, include/languages/language_gl.php,
include/languages/language_pt_br.php: Fixed a variable name.
* godmode/groups/group_list.php: Avoid the use of an extra indentation
by returning if no success on comprueba_login().
* include/styles/pandora.css: Add some classes. Tab style correction.
* operation/agentes/ver_agente.php: Added AJAX support to agent
operations.
* operation/reporting/graph_viewer.php: Period dropdown selection
improved and printed with Pandora functions.
* operation/reporting/reporting_viewer.php: Massive rewritten.
Implemented date and time support, added new report types, use Pandora
functions...
* reporting/fgraph.php: Documentation fix. Added a new graphic to show
monitors health.
* godmode/agentes/agent_manager.php,
operation/reporting/custom_reporting.php: Style correction.
2008-06-16 Sancho Lerena <slerena@gmail.com>
* pandoradb_data.sql: Updated some new config tokens (graph colors),

57
pandora_console/ajax.php Normal file
View File

@ -0,0 +1,57 @@
<?php
// Pandora FMS - the Free Monitoring System
// ========================================
// Copyright (c) 2008 Artica Soluciones Tecnológicas, http://www.artica.es
// Please see http://pandora.sourceforge.net 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.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Pandora FMS uses icons from famfamfam, licensed under CC Atr. 2.5
// Silk icon set 1.3 (cc) Mark James, http://www.famfamfam.com/lab/icons/silk/
// Pandora FMS uses Pear Image::Graph code
if ((! file_exists("include/config.php")) || (! is_readable("include/config.php"))) {
exit;
}
require ('include/config.php');
// Check for correct language file presence
if (file_exists ('include/languages/language_'.$config['language'].'.php')) {
include 'include/languages/language_'.$config['language'].'.php';
} else {
include "include/languages/language_en.php";
}
require ('include/functions.php');
require ('include/functions_db.php');
// Real start
session_start();
// Check user
check_login ();
define ('AJAX', true);
$page = (string) get_parameter ('page');
$page .= '.php';
session_write_close ();
if (file_exists ($page)) {
$id_user = $_SESSION["id_usuario"];
require ($page);
} else {
echo "<br><b class='error'>Sorry! I can't find the page $page!</b>";
}
?>

View File

@ -28,7 +28,7 @@ if (give_acl($id_user, 0, "AW")!=1) {
audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access agent manager");
require ("general/noaccess.php");
exit;
};
}
echo "<h2>".$lang_label["agent_conf"];
if (isset($_GET["create_agent"])){

View File

@ -24,111 +24,128 @@
// Load global vars
require("include/config.php");
if (comprueba_login() == 0)
$id_user = $_SESSION["id_usuario"];
if (give_acl($id_user, 0, "PM")==1) {
if (isset($_POST["create_g"])){ // Create group
$nombre = entrada_limpia($_POST["nombre"]);
$icon = entrada_limpia($_POST["icon"]);
$parent = entrada_limpia($_POST["parent"]);
$disabled = entrada_limpia($_POST["disabled"]);
$sql_insert="INSERT INTO tgrupo (nombre, icon, parent, disabled)
VALUES ('$nombre', '$icon', '$parent', $disabled) ";
$result=mysql_query($sql_insert);
if (! $result)
echo "<h3 class='error'>".$lang_label["create_group_no"]."</h3>";
else {
echo "<h3 class='suc'>".$lang_label["create_group_ok"]."</h3>";
$id_grupo = mysql_insert_id();
}
}
if (isset($_POST["update_g"])){ // if modified any parameter
$nombre = entrada_limpia($_POST["nombre"]);
$id_grupo = entrada_limpia($_POST["id_grupo"]);
$icon = entrada_limpia($_POST["icon"]);
$disabled = entrada_limpia($_POST["disabled"]);
$parent = entrada_limpia($_POST["parent"]);
$sql_update ="UPDATE tgrupo
SET nombre = '$nombre', icon = '$icon', disabled = $disabled, parent = '$parent'
WHERE id_grupo = '$id_grupo'";
$result=mysql_query($sql_update);
if (! $result)
echo "<h3 class='error'>".$lang_label["modify_group_no"]."</h3>";
else
echo "<h3 class='suc'>".$lang_label["modify_group_ok"]."</h3>";
}
if (isset($_GET["delete_g"])){ // if delete
$id_borrar_modulo = entrada_limpia($_GET["id_grupo"]);
// First delete from tagente_modulo
$sql_delete= "DELETE FROM tgrupo WHERE id_grupo = ".$id_borrar_modulo;
$result=mysql_query($sql_delete);
if (! $result)
echo "<h3 class='error'>".$lang_label["delete_group_no"]."</h3>";
else
echo "<h3 class='suc'>".$lang_label["delete_group_ok"]."</h3>";
}
echo "<h2>".$lang_label["group_management"]." &gt; ";
echo $lang_label["definedgroups"]."</h2>";
echo "<table cellpadding=4 cellspacing=4 width='400' class='databox'>";
echo "<th>".$lang_label["icon"]."</th>";
echo "<th>".$lang_label["group_name"]."</th>";
echo "<th>".$lang_label["parent"]."</th>";
echo "<th>".$lang_label["alerts"]."</th>";
echo "<th>".$lang_label["delete"]."</th>";
$sql1='SELECT * FROM tgrupo ORDER BY nombre';
$result=mysql_query($sql1);
$color=0;
while ($row=mysql_fetch_array($result)){
if ($color == 1){
$tdcolor = "datos";
$color = 0;
}
else {
$tdcolor = "datos2";
$color = 1;
}
if ($row["id_grupo"] != 1){
echo "<tr><td class='$tdcolor' align='center'>";
echo "<img src='images/groups_small/".$row["icon"].".png' border='0'>";
echo "</td>";
echo "<td class='$tdcolor'>";
echo "<b><a href='index.php?sec=gagente&sec2=godmode/groups/configure_group&id_grupo=".$row["id_grupo"]."'>".$row["nombre"]."</a>";
echo "</b></td>";
echo "<td class='$tdcolor'>";
echo dame_nombre_grupo ($row["parent"]);
echo "</td>";
// Disabled?
echo "<td class='$tdcolor' align='center'>";
if ($row["disabled"]==1)
echo "<img src='images/flag_red.png'> ".$lang_label["disabled"];
else
echo "<img src='images/flag_green.png'> ".$lang_label["enabled"];
echo "</td>";
echo "<td class='$tdcolor' align='center'>";
echo "<a href='index.php?sec=gagente&sec2=godmode/groups/group_list&id_grupo=".$row["id_grupo"]."&delete_g=".$row["id_grupo"]."'";
echo ' onClick="if (!confirm(\' '.$lang_label["are_you_sure"].'\')) return false;">';
echo "<img border='0' src='images/cross.png'></a></td></tr>";
}
}
echo "</table>";
echo "<table cellpadding=4 cellspacing=4 width='400'>";
echo "<tr><td align='right'>";
echo "<form method=post action='index.php?sec=gagente&
sec2=godmode/groups/configure_group&create_g=1'>";
echo "<input type='submit' class='sub next' name='crt' value='".$lang_label["create_group"]."'>";
echo "</form></td></tr></table>";
} // Fin pagina
else {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Group Management");
if (comprueba_login()) {
audit_db ($id_user,$REMOTE_ADDR, "ACL Violation", "Trying to access Group Management");
require ("general/noaccess.php");
}
return;
}
$id_user = $_SESSION["id_usuario"];
if (! give_acl($id_user, 0, "PM")) {
audit_db ($id_user, $REMOTE_ADDR, "ACL Violation", "Trying to access Group Management");
require ("general/noaccess.php");
return;
}
if (defined ('AJAX')) {
$get_group_json = (bool) get_parameter ('get_group_json');
if ($get_group_json) {
$id_group = (int) get_parameter ('id_group');
$group = get_db_row ('tgrupo', 'id_grupo', $id_group);
echo json_encode ($group);
exit ();
}
exit ();
}
if (isset($_POST["create_g"])) { // Create group
$nombre = entrada_limpia($_POST["nombre"]);
$icon = entrada_limpia($_POST["icon"]);
$parent = entrada_limpia($_POST["parent"]);
$disabled = entrada_limpia($_POST["disabled"]);
$sql_insert="INSERT INTO tgrupo (nombre, icon, parent, disabled)
VALUES ('$nombre', '$icon', '$parent', $disabled) ";
$result=mysql_query($sql_insert);
if (! $result)
echo "<h3 class='error'>".$lang_label["create_group_no"]."</h3>";
else {
echo "<h3 class='suc'>".$lang_label["create_group_ok"]."</h3>";
$id_grupo = mysql_insert_id();
}
}
if (isset($_POST["update_g"])){ // if modified any parameter
$nombre = entrada_limpia($_POST["nombre"]);
$id_grupo = entrada_limpia($_POST["id_grupo"]);
$icon = entrada_limpia($_POST["icon"]);
$disabled = entrada_limpia($_POST["disabled"]);
$parent = entrada_limpia($_POST["parent"]);
$sql_update ="UPDATE tgrupo
SET nombre = '$nombre', icon = '$icon', disabled = $disabled, parent = '$parent'
WHERE id_grupo = '$id_grupo'";
$result=mysql_query($sql_update);
if (! $result)
echo "<h3 class='error'>".$lang_label["modify_group_no"]."</h3>";
else
echo "<h3 class='suc'>".$lang_label["modify_group_ok"]."</h3>";
}
if (isset($_GET["delete_g"])){ // if delete
$id_borrar_modulo = entrada_limpia($_GET["id_grupo"]);
// First delete from tagente_modulo
$sql_delete= "DELETE FROM tgrupo WHERE id_grupo = ".$id_borrar_modulo;
$result=mysql_query($sql_delete);
if (! $result)
echo "<h3 class='error'>".$lang_label["delete_group_no"]."</h3>";
else
echo "<h3 class='suc'>".$lang_label["delete_group_ok"]."</h3>";
}
echo "<h2>".$lang_label["group_management"]." &gt; ";
echo $lang_label["definedgroups"]."</h2>";
echo "<table cellpadding=4 cellspacing=4 width='400' class='databox'>";
echo "<th>".$lang_label["icon"]."</th>";
echo "<th>".$lang_label["group_name"]."</th>";
echo "<th>".$lang_label["parent"]."</th>";
echo "<th>".$lang_label["alerts"]."</th>";
echo "<th>".$lang_label["delete"]."</th>";
$sql1='SELECT * FROM tgrupo ORDER BY nombre';
$result=mysql_query($sql1);
$color=0;
while ($row=mysql_fetch_array($result)){
if ($color == 1){
$tdcolor = "datos";
$color = 0;
}
else {
$tdcolor = "datos2";
$color = 1;
}
if ($row["id_grupo"] != 1){
echo "<tr><td class='$tdcolor' align='center'>";
echo "<img src='images/groups_small/".$row["icon"].".png' border='0'>";
echo "</td>";
echo "<td class='$tdcolor'>";
echo "<b><a href='index.php?sec=gagente&sec2=godmode/groups/configure_group&id_grupo=".$row["id_grupo"]."'>".$row["nombre"]."</a>";
echo "</b></td>";
echo "<td class='$tdcolor'>";
echo dame_nombre_grupo ($row["parent"]);
echo "</td>";
// Disabled?
echo "<td class='$tdcolor' align='center'>";
if ($row["disabled"]==1)
echo "<img src='images/flag_red.png'> ".$lang_label["disabled"];
else
echo "<img src='images/flag_green.png'> ".$lang_label["enabled"];
echo "</td>";
echo "<td class='$tdcolor' align='center'>";
echo "<a href='index.php?sec=gagente&sec2=godmode/groups/group_list&id_grupo=".$row["id_grupo"]."&delete_g=".$row["id_grupo"]."'";
echo ' onClick="if (!confirm(\' '.$lang_label["are_you_sure"].'\')) return false;">';
echo "<img border='0' src='images/cross.png'></a></td></tr>";
}
}
echo "</table>";
echo "<table cellpadding=4 cellspacing=4 width='400'>";
echo "<tr><td align='right'>";
echo "<form method=post action='index.php?sec=gagente&
sec2=godmode/groups/configure_group&create_g=1'>";
echo "<input type='submit' class='sub next' name='crt' value='".$lang_label["create_group"]."'>";
echo "</form></td></tr></table>";
?>

View File

@ -28,6 +28,8 @@ $factor = 1;
$render=1; // by default
$stacked = 0;
$add_module = (bool) get_parameter ('add_module');
// Login check
$id_usuario=$_SESSION["id_usuario"];
global $REMOTE_ADDR;
@ -141,7 +143,7 @@ if (isset($_GET["delete_module"] )) {
}
}
if ( (isset($_GET["add_module"]))){
if ($add_module) {
$id_agent = $_POST["id_agent"];
$id_module = $_POST["id_module"];
if (isset($_POST["factor"]))
@ -262,14 +264,14 @@ if (($render == 1) && (isset($modules))) {
// SOURCE AGENT TABLE/FORM
// -----------------------
if ( (!isset($_GET["add_module"]))){
if ($add_module) {
echo $lang_label["graph_builder"]."</h2>";
} else {
echo "<h3>".$lang_label["graph_builder"]."</h3>";
}
echo "<table width='500' cellpadding=4 cellpadding=4 class='databox_color'>";
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/graph_builder&get_agent=1'>";
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/graph_builder'>";
print_input_hidden ('add_module', 1);
if (isset($period))
echo "<input type='hidden' name='period' value='$period'>";
@ -278,26 +280,15 @@ echo "<td class='datos'><b>".$lang_label["source_agent"]."</td>";
echo "</b>";
// Show combo with agents
echo "<td class='datos' colspan=2><select name='id_agent' style='width:180px;'>";
if ($id_agent != 0)
echo "<option value='$id_agent'>".dame_nombre_agente($id_agent);
$sql1='SELECT * FROM tagente ORDER BY nombre';
$result=mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
if ( $id_agent != $row["id_agente"])
echo "<option value=".$row["id_agente"].">".$row["nombre"]."</option>";
}
echo '</select>';
echo "<td class='datos' colspan=2>";
print_select_from_sql ('SELECT id_agente, nombre FROM tagente ORDER BY nombre', 'id_agent', $id_agent, '', '--', 0);
if (isset($chunkdata))
echo "<input type='hidden' name='chunk' value='$chunkdata'>";
echo "<td class='datos' colspan=1 align='right'><input type=submit name='update_agent' class='sub upd' value='".$lang_label["get_info"]."'>";
echo "</form>";
// -----------------------
// SOURCE MODULE FORM
// -----------------------
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/graph_builder&add_module=1'>";
if (isset($chunkdata))
echo "<input type='hidden' name='chunk' value='$chunkdata'>";
@ -307,7 +298,7 @@ if (isset($id_agent))
echo "<tr><td class='datos2'>";
echo "<b>".$lang_label["modules"]."</b>";
echo "<td class='datos2' colspan=3>";
echo "<select name='id_module' size=1 style='width:180px;'>";
echo "<select id='id_module' name='id_module' size=1 style='width:180px;'>";
echo "<option value=-1> -- </option>";
if ($id_agent != 0){
// Populate Module/Agent combo
@ -506,3 +497,43 @@ if (isset($module_array)){
}
?>
<script type="text/javascript" src="include/javascript/jquery.js"></script>
<script language="javascript" type="text/javascript">
function agent_changed () {
var id_agent = this.value;
$('#id_module').fadeOut ('normal', function () {
$('#id_module').empty ();
var inputs = [];
inputs.push ("id_agent=" + id_agent);
inputs.push ("get_agent_modules_json=1");
inputs.push ("page=operation/agentes/ver_agente");
jQuery.ajax ({
data: inputs.join ("&"),
type: 'GET',
url: action="ajax.php",
timeout: 10000,
dataType: 'json',
success: function (data) {
$('#id_module').append ($('<option></option>').attr ('value', 0).text ("--"));
jQuery.each (data, function (i, val) {
if (val['descripcion'] == "") {
s = html_entity_decode (val['nombre']);
} else {
s = html_entity_decode (val['descripcion']);
}
$('#id_module').append ($('<option></option>').attr ('value', val['id_agente_modulo']).text (s));
});
$('#id_module').fadeIn ('normal');
}
});
});
}
$(document).ready (function () {
$('#id_agent').change (agent_changed);
});
</script>

View File

@ -1,4 +1,4 @@
<?PHP
<?php
// Pandora FMS - the Free monitoring system
// ========================================
@ -33,424 +33,592 @@ if ((give_acl($id_user,0,"AW") != 1 ) AND (dame_admin($id_user)!=1)) {
exit;
}
if (defined ('AJAX')) {
$get_report_type_data_source = (bool) get_parameter ('get_report_type_data_source');
if ($get_report_type_data_source) {
$id_report_type = (string) get_parameter ('id_report_type');
echo get_report_type_data_source ($id_report_type);
exit ();
}
exit ();
}
$form_report_name = "";
$form_report_private=0;
$form_report_description = "";
$createmode = 1;
$edit_report = (bool) get_parameter ('edit_report');
$create_report = (bool) get_parameter ('create_report');
$delete_report = (int) get_parameter ('delete_report');
$update_report = (int) get_parameter ('update_report');
$delete_report_content = (bool) get_parameter ('delete_report_content');
$report_name = (string) get_parameter ('report_name');
$report_description = (string) get_parameter ('report_description');
$report_private = (bool) get_parameter ('report_private', 0);
$id_report = (int) get_parameter ('id_report');
$report_id_group = (int) get_parameter ('report_id_group');
$id_agent = (int) get_parameter ('id_agent');
$id_group = (int) get_parameter ('id_group');
$add_content = (bool) get_parameter ('add_content');
$edit_sla_report_content = (bool) get_parameter ('edit_sla_report_content');
$content_up = (bool) get_parameter ('content_up');
$content_down = (bool) get_parameter ('content_down');
if (isset($_GET["get_agent"])) {
$id_agent = $_POST["id_agent"];
}
// Delete module SQL code
if (isset($_GET["delete"])){
$id_content = $_GET["delete"];
$sql = "DELETE FROM treport_content WHERE id_rc = $id_content";
if ($res=mysql_query($sql))
$result = "<h3 class='suc'>".$lang_label["delete_ok"]."</h3>";
if ($delete_report_content) {
$id_report_content = (int) get_parameter ('id_report_content');
$sql = sprintf ('DELETE FROM treport_content WHERE id_rc = %d', $id_report_content);
$result = mysql_query ($sql);
if ($result)
echo "<h3 class='suc'>".lang_string ('delete_ok')."</h3>";
else
$result = "<h3 class='error'>".$lang_label["delete_no"]."</h3>";
echo $result;
echo "<h3 class='error'>".lang_string ('delete_no')."</h3>";
}
// Delete module SQL code
if (isset($_GET["delete_report"])){
$id = $_GET["delete_report"];
$sql = "DELETE FROM treport_content WHERE id_report = $id";
$sql2 = "DELETE FROM treport WHERE id_report = $id";
$res=mysql_query($sql);
$res2=mysql_query($sql2);
// Move content up
if ($content_up) {
$id_report_content = (int) get_parameter ('id_report_content');
$order = get_db_value ('`order`', 'treport_content', 'id_rc', $id_report_content);
/* Set the previous element order to the current of the content we want to change */
$sql = sprintf ('UPDATE treport_content SET `order` = `order` + 1 WHERE id_report = %d AND `order` = %d',
$id_report, $order - 1);
$result = mysql_query ($sql);
$sql = sprintf ('UPDATE treport_content SET `order` = `order` - 1 WHERE id_rc = %d', $id_report_content);
$result = mysql_query ($sql);
}
// Move content down
if ($content_down) {
$id_report_content = (int) get_parameter ('id_report_content');
$order = get_db_value ('`order`', 'treport_content', 'id_rc', $id_report_content);
/* Set the previous element order to the current of the content we want to change */
$sql = sprintf ('UPDATE treport_content SET `order` = `order` - 1 WHERE id_report = %d AND `order` = %d',
$id_report, $order + 1);
$result = mysql_query ($sql);
$sql = sprintf ('UPDATE treport_content SET `order` = `order` + 1 WHERE id_rc = %d', $id_report_content);
$result = mysql_query ($sql);
}
// Delete report SQL code
if ($delete_report) {
$sql = sprintf ('DELETE FROM treport_content WHERE id_report = %d', $id_report);
$sql2 = sprintf ('DELETE FROM treport WHERE id_report = %d', $id_report);
$res = mysql_query ($sql);
$res2 = mysql_query ($sql2);
if ($res AND $res2)
$result = "<h3 class=suc>".$lang_label["delete_reporting_ok"]."</h3>";
echo "<h3 class=suc>".lang_string ('delete_reporting_ok')."</h3>";
else
$result = "<h3 class=error>".$lang_label["delete_reporting_no"]."</h3>";
echo $result;
}
// Create new report. First step
if (isset($_GET["create_report"])){
$createmode = 2;
echo "<h3 class=error>".lang_string ('delete_reporting_no')."</h3>";
$id_report = 0;
}
// Add module SQL code
if (isset($_GET["add_module"])){
if (isset($_POST["id_report"]))
$id_report = $_POST["id_report"];
else {
if ($add_content) {
if (! $id_report) {
audit_db($id_user,$REMOTE_ADDR, "Hack attempt","Parameter trash in report builder");
include ("general/noaccess.php");
exit;
exit ();
}
$my_id_agent = entrada_limpia($_POST["id_agent"]);
$my_id_module = entrada_limpia($_POST["id_module"]);
$my_period = entrada_limpia($_POST["period"]);
$my_type = entrada_limpia($_POST["type"]);
// event reporting (use agent not module)
if ($my_type == 3){
$my_id_module = $my_id_agent;
}
$my_cg = entrada_limpia($_POST["id_custom_graph"]);
$my_slamax = entrada_limpia($_POST["sla_max"]);
$my_slamin = entrada_limpia($_POST["sla_min"]);
$my_slalimit = entrada_limpia($_POST["sla_limit"]);
$id_agent = (int) get_parameter ('id_agent');
$id_agent_module = (int) get_parameter ('id_module');
$period = (int) get_parameter ('period');
$type = (string) get_parameter ('type');
$id_custom_graph = (int) get_parameter ('id_custom_graph');
$sql = "INSERT INTO treport_content (id_report, id_gs, id_agent_module, type, sla_max, sla_min, sla_limit, period) VALUES ('$id_report', '$my_cg', '$my_id_module', '$my_type', '$my_slamax', '$my_slamin', '$my_slalimit', '$my_period')";
if ($res=mysql_query($sql))
$result = "<h3 class=suc>".$lang_label["create_reporting_ok"]."</h3>";
else
$result = "<h3 class=error>".$lang_label["create_reporting_no"]."</h3>";
echo $result;
}
$order = (int) get_db_value ('COUNT(*)', 'treport_content', 'id_report', $id_report);
// Create item SQL code
if (isset($_POST["createmode"])){
$createmode = $_POST["createmode"];
$form_report_name = entrada_limpia($_POST["report_name"]);
$form_report_description = entrada_limpia($_POST["report_description"]);
if (isset($_POST["report_private"]))
$form_report_private = entrada_limpia($_POST["report_private"]);
else
$form_report_private = 0;
// INSERT REPORT DATA
if ($createmode == 1){
$form_id_user = $id_user;
$sql = "INSERT INTO treport (name, description, id_user, private) VALUES ('$form_report_name', '$form_report_description', '$form_id_user', '$form_report_private')";
if ($res=mysql_query($sql))
$result = "<h3 class=suc>".$lang_label["create_reporting_ok"]."</h3>";
else
$result = "<h3 class=error>".$lang_label["create_reporting_no"]."</h3>";
$id_report = mysql_insert_id();
// UPDATE REPORT DATA
$sql = sprintf ('INSERT INTO treport_content (id_report, id_gs, id_agent_module,
`order`, id_agent, type, period)
VALUES (%d, %s, %s, %d, %s, "%s", %d)',
$id_report, $id_custom_graph ? $id_custom_graph : "NULL",
$id_agent_module ? $id_agent_module : "NULL",
$order, $id_agent ? $id_agent : "NULL",
$type, $period * 3600);
if ($result = mysql_query($sql)) {
echo "<h3 class=suc>".lang_string ('create_reporting_ok')."</h3>";
$id_agent = 0;
$id_agent_module = 0;
$report_id_group = 0;
$period = 0;
$type = 0;
$id_custom_graph = 0;
$sla_max = 0;
$sla_min = 0;
$sla_limit = 0;
} else {
$form_id_report = entrada_limpia($_POST["id_report"]);
$id_report = $form_id_report;
$sql = "UPDATE treport SET name = '$form_report_name', description = '$form_report_description', private = '$form_report_private' WHERE id_report = $form_id_report";
if ($res=mysql_query($sql))
$result = "<h3 class=suc>".$lang_label["modify_ok"]."</h3>";
else
$result = "<h3 class=error>".$lang_label["modify_no"]."</h3>";
}
echo $result;
if ($id_report != ""){
$_GET["id"]=$id_report;
$createmode=0;
echo "<h3 class=error>".lang_string ('create_reporting_no')."</h3>";
/* Do not unset so the values are kept in the form */
}
}
// GET DATA OF REPORT
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ($createmode==2 OR isset($_GET["id"]) OR (isset($_POST["id_report"]))) {
if (isset($_GET["id"]))
$id_report = $_GET["id"];
elseif (isset($_POST["id_report"]))
$id_report = $_POST["id_report"];
// Create report
if ($create_report) {
$form_id_user = $id_user;
$sql = sprintf ('INSERT INTO treport (name, description, id_user, private, id_group)
VALUES ("%s", "%s", %d, %d, %d)',
$report_name, $report_description, $form_id_user, $report_private, $report_id_group);
$result = mysql_query ($sql);
if ($result)
echo "<h3 class=suc>".lang_string ('create_reporting_ok')."</h3>";
else
$id_report = -1;
echo "<h3 class=error>".lang_string ('create_reporting_no')."</h3>";
$id_report = mysql_insert_id ();
}
// Update report
if ($update_report) {
$sql = sprintf ('UPDATE treport SET name = "%s",
description = "%s", private = %d, id_group = %d
WHERE id_report = %d',
$report_name, $report_description,
$report_private, $report_id_group, $id_report);
$result = mysql_query ($sql);
if ($result)
echo "<h3 class=suc>".lang_string ('modify_ok')."</h3>";
else
echo "<h3 class=error>".lang_string ('modify_no')."</h3>";
}
if ($id_report) {
$report = get_db_row ('treport', 'id_report', (int) $id_report);
$report_name = $report["name"];
$report_description = $report["description"];
$report_private = $report["private"];
$report_id_user = $report["id_user"];
$report_id_group = $report['id_group'];
}
if ($edit_sla_report_content) {
/* Edit SLA report form */
$add_sla = (bool) get_parameter ('add_sla');
$delete_sla = (bool) get_parameter ('delete_sla');
$id_report_content = (int) get_parameter ('id_report_content');
$id_module = (int) get_parameter ('id_module');
$sla_max = '';
$sla_min = '';
$sla_limit = '';
if ($add_sla) {
$sla_max = (int) get_parameter ('sla_max');
$sla_min = (int) get_parameter ('sla_min');
$sla_limit = (int) get_parameter ('sla_limit');
$sql = sprintf ('INSERT INTO treport_content_sla_combined (id_report_content,
id_agent_module, sla_max, sla_min, sla_limit) VALUES (%d, %d, %d, %d, %d)',
$id_report_content, $id_module, $sla_max, $sla_min, $sla_limit);
if ($id_module) {
$result = mysql_query ($sql);
if ($result)
echo "<h3 class=suc>".lang_string ('add_sla_ok')."</h3>";
else
echo "<h3 class=error>".lang_string ('add_sla_no')."</h3>";
} else {
echo "<h3 class=error>".lang_string ('sla_module_is_null')."</h3>";
}
}
if ($delete_sla) {
$id_sla = (int) get_parameter ('id_sla');
$sql = sprintf ('DELETE FROM treport_content_sla_combined WHERE id = %d', $id_sla);
echo $sql;
$result = mysql_query ($sql);
if ($result)
echo "<h3 class=suc>".lang_string ('delete_sla_ok')."</h3>";
else
echo "<h3 class=error>".lang_string ('delete_sla_no')."</h3>";
}
$report_content = get_db_row ('treport_content', 'id_rc', $id_report_content);
/* Show all SLAs defined in the report content */
echo '<h2>'.lang_string ('reporting')." &gt; ";
echo lang_string ('custom_reporting_builder')." &gt; ";
echo '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&edit_report=1&id_report='.
$id_report.'">'.$report['name'].'</a></h2>';
echo '<h2>'.lang_string ('defined_slas')."</h2>";
$table->id = 'table-sla-list';
$table->width = '500px';
$table->align = array ();
$table->align[5] = 'center';
$table->data = array ();
$table->head = array ();
$table->head[0] = lang_string ('agent');
$table->head[1] = lang_string ('module');
$table->head[2] = lang_string ('sla_min');
$table->head[3] = lang_string ('sla_max');
$table->head[4] = lang_string ('sla_limit');
$table->head[5] = lang_string ('delete');
$slas = get_db_all_rows_field_filter ('treport_content_sla_combined', 'id_report_content', $id_report_content);
foreach ($slas as $sla) {
$data = array ();
$data[0] = dame_nombre_agente_agentemodulo ($sla['id_agent_module']);
$data[1] = dame_nombre_modulo_agentemodulo ($sla['id_agent_module']);
$data[2] = $sla['sla_min'];
$data[3] = $sla['sla_max'];
$data[4] = $sla['sla_limit'].'%';
$data[5] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id_report='.
$id_report.'&edit_sla_report_content=1&delete_sla=1&id_report_content='.
$id_report_content.'&id_sla='.$sla['id'].'"><img src="images/cross.png"></a>';
array_push ($table->data, $data);
}
if (sizeof ($slas)) {
print_table ($table);
}
echo "<h2>".lang_string ('sla_construction')."</h2>";
$table->id = 'table-add-sla';
$table->width = '500px';
$table->data = array ();
$table->style = array ();
$table->size = array ();
$table->size[0] = '150px';
$table->head = array ();
$table->style[0] = 'font-weight: bold';
$sql = sprintf ('SELECT id_agente, nombre FROM tagente WHERE id_grupo = %d ORDER BY nombre', $report_id_group);
$table->data[0][0] = lang_string ('agent');
$table->data[0][1] = print_select_from_sql ($sql, 'id_agent', 0, '', '--', 0, true);
$table->data[1][0] = lang_string ('module');
$table->data[1][1] = print_select (array (), 'id_module', 0, '', '--', 0, true);
$table->data[2][0] = lang_string ('sla_min');
$table->data[2][1] = print_input_text ('sla_min', $sla_min, '', 5, 10, true);
$table->data[3][0] = lang_string ('sla_max');
$table->data[3][1] = print_input_text ('sla_max', $sla_max, '', 5, 10, true);
$table->data[4][0] = lang_string ('sla_limit');
$table->data[4][1] = print_input_text ('sla_limit', $sla_limit, '', 5, 10, true);
echo '<form method="post" action="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id_report='.
$id_report.'&edit_sla_report_content=1&id_report_content='.$id_report_content.'">';
print_table ($table);
print_input_hidden ('add_sla', 1);
print_input_hidden ('edit_sla_report_content', 1);
print_input_hidden ('id_report_content', $id_report_content);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
print_submit_button (lang_string ('create'), 'add', false, 'class="sub wand"');
echo '</div>';
echo '</form>';
} else if ($edit_report || $id_report) {
/* Edit and creation report form */
if (isset($_POST["id_agent"]))
$id_agent = $_POST["id_agent"];
else
$id_agent = 0;
if ($createmode != 2){
$createmode = 0;
$sql = "SELECT * FROM treport WHERE id_report = $id_report";
$res=mysql_query($sql);
if ($row = mysql_fetch_array($res)){
$form_report_name = $row["name"];
$form_report_description = $row["description"];
$form_report_private = $row["private"];
$form_id_user = $row["id_user"];
}
} else {
$form_report_name = "";
$form_report_description = "";
$form_report_private = 0;
$form_id_user = $id_user;
$createmode = 1;
}
echo "<h2>".$lang_label["reporting"]." &gt; ";
echo $lang_label["custom_reporting_builder"]."</h2>";
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder'>";
echo "<input type='hidden' name=createmode value='$createmode'>";
if ($createmode == 0){
echo "<input type='hidden' name=id_report value='$id_report'>";
}
echo "<table width=500 cellspacing=4 cellpading=4 class='databox_color'>";
echo "<tr><td class='datos2'>";
echo $lang_label["report_name"]."</td>";
echo "<td class='datos2'>";
echo "<input type=text size=35 name='report_name' value='$form_report_name'>";
echo "<tr><td class='datos'>";
echo $lang_label["private"]."</td>";
echo "<td class='datos'>";
if ($form_report_private == 1)
echo "<input type=checkbox name='report_private' value=1 CHECKED>";
else
echo "<input type=checkbox name='report_private' value=1>";
echo "</td></tr>";
echo "<tr><td class='datos2' valign='top'>";
echo $lang_label["description"]."</td>";
echo "<td class='datos2'>";
echo "<textarea name='report_description' cols=40 rows=3>";
echo $form_report_description;
echo "</textarea>";
echo "</td></tr>";
echo "</table>";
echo "<h2>".lang_string ('reporting')." &gt; ";
echo lang_string ('custom_reporting_builder')."</h2>";
$table->id = 'table-edit-report';
$table->width = '500px';
$table->data = array ();
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->data[0][0] = lang_string ('report_name');
$table->data[0][1] = print_input_text ('report_name', $report_name, '', 35, 150, true);
$table->data[1][0] = lang_string ('group');
$table->data[1][1] = print_select_from_sql ('SELECT id_grupo, nombre FROM tgrupo ORDER BY nombre',
'report_id_group', $report_id_group, '', '--', 0, true);
$table->data[1][1] .= '<span id="icon_preview">';
if ($report_id_group) {
$table->data[1][1] .= '<img src="images/groups_small/'.dame_grupo_icono ($report_id_group).'.png" />';
}
$table->data[1][1] .= '</span>';
$table->data[2][0] = lang_string ('private');
$table->data[2][1] = print_checkbox ('report_private', 1, $report_private, true);
$table->data[3][0] = lang_string ('description');
$table->data[3][1] = print_textarea ('report_description', 3, 40, $report_description, '', true);
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder'>";
print_table ($table);
// Button
echo "<table width=500 cellspacing=4 cellpading=4'>";
echo "<tr><td align='right'>";
if ($createmode == 0)
echo "<input type='submit' class='sub next' value='".$lang_label["update"]."'>";
else
echo "<input type='submit' class='sub wand' value='".$lang_label["create"]."'>";
echo "</td></tr>";
echo "</table>";
echo '<div class="action-buttons" style="width: '.$table->width.'">';
print_input_hidden ('edit_report', 1);
if ($id_report) {
print_input_hidden ('id_report', $id_report);
print_input_hidden ('update_report', 1);
print_submit_button (lang_string ('update'), 'submit', false, 'class="sub next"');
} else {
print_input_hidden ('create_report', 1);
print_submit_button (lang_string ('create'), 'submit', false, 'class="sub wand"');
}
echo "</div>";
echo "</form>";
if ($createmode == 0){
if ($id_report) {
// Part 2 - Add new items to report
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo "<h2>".$lang_label["reporting_item_add"]."</h2>";
// Show combo with agents
// ----------------------
echo "<h2>".lang_string ('reporting_item_add')."</h2>";
echo "<table width='500' cellpadding=4 cellpadding=4 class='databox_color'>";
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&get_agent=1'>";
echo "<input type='hidden' name=id_report value='$id_report'>";
/* We're reusing some $table attributes */
$table->id = 'table-add-item';
$table->rowstyle = array ();
$table->rowstyle[2] = 'display: none';
$table->rowstyle[3] = 'display: none';
$table->rowstyle[4] = 'display: none';
$table->size = array ();
$table->size[0] = '200px';
$table->data = array ();
$table->data[0][0] = lang_string ('reporting_type');
$types = get_report_types ();
asort ($types);
$table->data[0][1] = print_select ($types, 'type', -1, '', '--', -1, true);
$table->data[1][0] = lang_string ('period');
$periods = array ();
$periods[1] = lang_string ('hour');
$periods[2] = '2 '.lang_string ('hours');
$periods[3] = '3 '.lang_string ('hours');
$periods[6] = '6 '.lang_string ('hours');
$periods[12] = '12 '.lang_string ('hours');
$periods[24] = lang_string ('last_day');
$periods[48] = lang_string ('two_days');
$periods[360] = lang_string ('last_week');
$periods[720] = lang_string ('last_month');
$periods[4320] = lang_string ('six_months');
$table->data[1][1] = print_select ($periods, 'period', 0, '', '--', 0, true);
$table->data[2][0] = lang_string ('source_agent');
$sql = sprintf ('SELECT id_agente, nombre FROM tagente WHERE id_grupo = %d ORDER BY nombre', $report_id_group);
$table->data[2][1] = print_select_from_sql ($sql, 'id_agent', $id_agent, '', '--', 0, true);
echo "<tr>";
echo "<td class='datos'><b>".$lang_label["source_agent"]."</b></td>";
echo "<td class='datos' colspan=2><select name='id_agent' style='width:180px;'>";
if ($id_agent != 0)
echo "<option value='$id_agent'>".dame_nombre_agente($id_agent);
$sql1='SELECT * FROM tagente order by nombre';
$result=mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
if ( $id_agent != $row["id_agente"])
echo "<option value=".$row["id_agente"].">".$row["nombre"]."</option>";
$table->data[3][0] = lang_string ('module');
$modules = array ();
if ($id_agent) {
$sql = sprintf ('SELECT * FROM tagente_modulo WHERE id_agente = %d ORDER BY nombre', $id_agent);
$modules = get_db_all_rows_sqlfree ($sql);
}
echo '</select></td>';
echo "<td class='datos' colspan='1' align='right'>
<input type=submit name='update_agent' class='sub upd' value='".$lang_label["get_info"]."'>";
echo "</td></form>";
// Modules combo
// -----------------------
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&add_module=1'>";
echo "<input type='hidden' name=id_report value='$id_report'>";
if (isset($id_agent))
echo "<input type='hidden' name='id_agent' value='$id_agent'>";
echo "<tr><td class='datos2'>";
echo "<b>".$lang_label["modules"]."</b>";
echo "</td>";
echo "<td class='datos2' colspan=3>";
echo "<select name='id_module' size=1 style='width:180px;'>";
echo "<option value=-1> -- </option>";
if ($id_agent != 0){
// Populate Module/Agent combo
$sql1="SELECT * FROM tagente_modulo WHERE id_agente = ".$id_agent. " ORDER BY nombre";
$result = mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
echo "<option value=".$row["id_agente_modulo"].">".$row["nombre"]."</option>";
}
}
echo "</select></td></tr>";
// Component type
echo "<tr><td class='datos'>";
echo "<b>".$lang_label["reporting_type"]."</b></td>";
echo "<td class='datos' colspan=3>";
echo "<select name='type' size=1 style='width:180px;'>";
echo "<option value=0>".$lang_label["simple_graph"]."</option>";
echo "<option value=1>".$lang_label["custom_graph"]."</option>";
echo "<option value=2>".$lang_label["SLA"]."</option>";
echo "<option value=3>".$lang_label["event_report"]."</option>";
echo "<option value=4>".$lang_label["alert_report"]."</option>";
echo "<option value=5>".$lang_label["monitor_report"]."</option>";
echo "<option value=6>".$lang_label["avg_value"]."</option>";
echo "<option value=7>".$lang_label["max_value"]."</option>";
echo "<option value=8>".$lang_label["min_value"]."</option>";
echo "</select></td></tr>";
// Custom graph
// -----------------------
echo "<tr><td class='datos2'>";
echo "<b>".$lang_name["custom_graph_name"]."</b></td>";
echo "<td class='datos2' colspan=3>";
echo "<select name='id_custom_graph' size=1 style='width:180px;'>";
echo "<option value='-1'>".$row["N/A"]."</option>";
$sql1="SELECT * FROM tgraph";
$result = mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
echo "<option value=".$row["id_graph"].">".$row["name"]."</option>";
}
echo "</select>";
// Period
echo "<tr><td class='datos'>";
echo "<b>".$lang_label["period"]."</b></td>";
echo "<td class='datos' colspan=3>";
echo "<select name='period'>";
echo "<option value=3600>"."Hour</option>";
echo "<option value=7200>"."2 Hours</option>";
echo "<option value=10800>"."3 Hours</option>";
echo "<option value=21600>"."6 Hours</option>";
echo "<option value=43200>"."12 Hours</option>";
echo "<option value=86400>"."Last day</option>";
echo "<option value=172800>"."Two days</option>";
echo "<option value=604800>"."Last Week</option>";
echo "<option value=1296000>"."15 days</option>";
echo "<option value=2592000>"."Last Month</option>";
echo "<option value=5184000>"."Two Month</option>";
echo "<option value=15552000>"."Six Months</option>";
echo "</select></td></tr>";
// SLA Max
echo "<tr><td class='datos2'>";
echo "<b>".$lang_label["sla_max"]."</b></td>";
echo "<td class='datos2'>";
echo "<input type=text size=6 name='sla_max'></td>";
// SLA Min
echo "<td class='datos2'>";
echo "<b>".$lang_label["sla_min"]."</b></td>";
echo "<td class='datos2'>";
echo "<input type=text size=6 name='sla_min'></td>";
$table->data[3][1] = print_select ($modules, 'id_module', 0, '', '--', 0, true);
// SLA limit
echo "<tr><td class='datos'>";
echo "<b>".$lang_label["sla_limit"]."</b></td>";
echo "<td class='datos'>";
echo "<input type='text' size='6' name='sla_limit'></td>";
echo "</tr></table>";
$table->data[4][0] = lang_string ('custom_graph_name');
$table->data[4][1] = print_select_from_sql ('SELECT id_graph, name FROM tgraph',
'id_custom_graph', 0, '', '--', 0, true);
echo "<table width='500' cellspacing='4' cellpading='4'>";
echo "<tr><td align='right'>";
echo "<input type='submit' class='sub wand' value='".$lang_label["add"]."'>";
echo "</td></tr>";
echo "</table>";
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder'>";
print_table ($table);
echo '<div class="action-buttons" style="width: '.$table->width.'">';
print_input_hidden ('add_content', 1);
print_input_hidden ('id_report', $id_report);
print_submit_button (lang_string ('add'), 'add', false, 'class="sub wand"');
echo "</div>";
echo "</form>";
// Part 3 - List of already assigned report items
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo "<h2>".$lang_label["report_items"]."</h2>";
echo "<table width=500 cellspacing=4 cellpadding=4 class='databox'>";
echo "<tr>
<th>".$lang_label["type"]."</th>
<th>".$lang_label["agent_name"]."</th>
<th>".$lang_label["module_name"]."</th>
<th>".$lang_label["period"]."</th>
<th>".$lang_label["delete"]."</th>";
$sql = "SELECT * FROM treport_content WHERE id_report = $id_report";
$res=mysql_query($sql);
$color = 0;
while ($row = mysql_fetch_array($res)){
// Calculate table line color
if ($color == 1){
$tdcolor = "datos";
$color = 0;
}
else {
$tdcolor = "datos2";
$color = 1;
}
$id_rc = $row["id_rc"];
$type = $row["type"];
switch ($type){
case "0": $type_desc = "Graph"; break;
case "1": $type_desc = "User graph"; break;
case "2": $type_desc = "SLA"; break;
case "3": $type_desc = "Event report"; break;
case "4": $type_desc = "Alert report"; break;
case "5": $type_desc = "Monitor report"; break;
case "6": $type_desc = "Avg.Value"; break;
case "7": $type_desc = "Max.Value"; break;
case "8": $type_desc = "Min.Value"; break;
}
$period = $row["period"];
$id_am = $row["id_agent_module"];
$name = "N/A";
$agent_name = "N/A";
if ($id_am != ""){
$agent_name = dame_nombre_agente_agentemodulo ($id_am);
$module_name = dame_nombre_modulo_agentemodulo ($id_am);
}
echo "<tr>";
echo "<td class='$tdcolor'>".$type_desc."</td>";
echo "<td class='$tdcolor'>".$agent_name."</td>";
echo "<td class='$tdcolor'>".$module_name."</td>";
echo "<td class='$tdcolor'>".$period."</td>";
echo "<td class='$tdcolor' align='center'>";
if ($form_id_user == $id_user){
echo "<a href='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id=$id_report&delete=$id_rc'><img src='images/cross.png'></a>";
}
echo "</td></tr>";
echo "<h2>".lang_string ('report_items')."</h2>";
$table->id = 'table-assigned-reports';
$table->data = array ();
$table->head = array ();
$table->size = array ();
$table->rowstyle = array ();
$table->head[0] = lang_string ('order');
$table->head[1] = lang_string ('type');
$table->head[2] = lang_string ('period');
$table->head[3] = lang_string ('Options');
$table->align = array ();
$table->align[0] = 'center';
$table->align[3] = 'center';
if ($report_id_user == $config['id_user']) {
$table->align[4] = 'center';
$table->head[4] = lang_string ('delete');
}
echo "</table>";
$sql = sprintf ('SELECT * FROM treport_content WHERE id_report = %d ORDER BY `order`', $id_report);
$report_contents = get_db_all_rows_sqlfree ($sql);
if (sizeof ($report_contents)) {
$first_id = $report_contents[0]['id_rc'];
$last_id = $report_contents[sizeof ($report_contents) - 1]['id_rc'];
}
foreach ($report_contents as $report_content) {
$data = array ();
$data[0] = '';
if ($first_id != $report_content['id_rc']) {
$data[0] .= '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&edit_report=1&id_report='.
$id_report.'&content_up=1&id_report_content='.$report_content['id_rc'].
'"><img src="images/up.png" title="'.lang_string ('up').'"></a>';
}
if ($last_id != $report_content['id_rc']) {
$data[0] .= '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&edit_report=1&id_report='.
$id_report.'&content_down=1&id_report_content='.$report_content['id_rc'].
'"><img src="images/down.png" title="'.lang_string ('down').'"></a>';
}
$data[1] = get_report_name ($report_content['type']);
$data[2] = human_time_description ($report_content['period']);
$data[3] = '';
if ($report_content['type'] == 'SLA') {
$data[3] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id_report='.$id_report.'&edit_sla_report_content=1&id_report_content='.$report_content['id_rc'].'"><img src="images/setup.png"></a>';
}
if ($report_id_user == $config['id_user']) {
$data[4] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id_report='.$id_report.'&delete_report_content=1&id_report_content='.$report_content['id_rc'].'"><img src="images/cross.png"></a>';
}
array_push ($table->data, $data);
}
print_table ($table);
}
} else {
// Report item editor / add
// Report LIST
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo "<h2>".$lang_label["reporting"]." &gt; ";
echo $lang_label["custom_reporting"]."</h2>";
echo "<h2>".lang_string ('reporting')." &gt; ";
echo lang_string ('custom_reporting')."</h2>";
$sql="SELECT * FROM treport";
$res=mysql_query($sql);
if (mysql_num_rows($res)) {
echo "<table width='600' cellpadding=4 cellpadding=4 class='databox'>";
echo "<tr>
<th>".$lang_label["report_name"]."</th>
<th>".$lang_label["description"]."</th>
<th>".$lang_label["Manage"]."</th>
<th>".$lang_label["delete"]."</th>";
$color=1;
while ($row = mysql_fetch_array($res)){
if (($row["private"]==0) || ($row["id_user"] == $id_user)){
// Calculate table line color
if ($color == 1){
$tdcolor = "datos";
$color = 0;
}
else {
$tdcolor = "datos2";
$color = 1;
}
echo "<tr>";
echo "<td valign='top' class='$tdcolor'>".$row["name"];
echo "<td class='$tdcolor'>".$row["description"];
$id_report = $row["id_report"];
echo "<td valign='middle' class='$tdcolor' align='center'>
<a href='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id=$id_report'>
<img src='images/setup.png'></a></td>";
echo "<td valign='middle' class='$tdcolor' align='center'>
<a href='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&delete_report=$id_report'>
<img src='images/cross.png'></a></td>";
$reports = get_db_all_rows_in_table ('treport');
$sql = "SELECT * FROM treport";
$res = mysql_query($sql);
$table->width = '0px';
if (sizeof ($reports)) {
$table->id = 'report_list';
$table->width = '600px';
$table->head = array ();
$table->align = array ();
$table->align[2] = 'center';
$table->data = array ();
$table->head[0] = lang_string ('report_name');
$table->head[1] = lang_string ('description');
$table->head[2] = lang_string ('delete');
foreach ($reports as $report) {
if ($report["private"] || $report["id_user"] != $id_user)
continue;
$data = array ();
$data[0] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&edit_report=1&id_report='.
$report['id_report'].'">'.$report['name'].'</a>';
$data[1] = $report['description'];
$data[2] = '<a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&delete_report=1&id_report='.
$report['id_report'].'"><img src="images/cross.png"></a>';
array_push ($table->data, $data);
}
print_table ($table);
} else {
echo "<div class='nf'>".lang_string ('no_reporting_def')."</div>";
}
echo "</table>";
echo "<table width=600 cellpadding=4 cellpadding=4>";
} else {
echo "<div class='nf'>".$lang_label["no_reporting_def"]."</div>";
echo "<table>";
}
echo "<form method=post action='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&create_report=1'>";
echo "<tr><td align='right'>";
echo "<input type=submit class='sub next' value='".$lang_label["add"]."'>";
echo '<form method="post" action="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder">';
echo '<div class="action-buttons" style="width: '.$table->width.'">';
print_input_hidden ('edit_report', 1);
print_submit_button (lang_string ('add'), 'create', false, 'class="sub next"');
echo "</div>";
echo "</form>";
echo "</table>";
}
?>
<script type="text/javascript" src="include/javascript/jquery.js"></script>
<script language="javascript" type="text/javascript">
function refresh_table () {
$('##table-add-item > tbody > tr:odd td').removeClass('datos2').addClass('datos');
$('##table-add-item > tbody > tr:even td').removeClass('datos').addClass('datos2');
}
function agent_changed () {
var id_agent = this.value;
$('#id_module').fadeOut ('normal', function () {
$('#id_module').empty ();
var inputs = [];
inputs.push ("id_agent=" + id_agent);
inputs.push ("get_agent_modules_json=1");
inputs.push ("page=operation/agentes/ver_agente");
jQuery.ajax ({
data: inputs.join ("&"),
type: 'GET',
url: action="ajax.php",
timeout: 10000,
dataType: 'json',
success: function (data) {
$('#id_module').append ($('<option></option>').attr ('value', 0).text ("--"));
jQuery.each (data, function (i, val) {
if (val['descripcion'] == "") {
s = html_entity_decode (val['nombre']);
} else {
s = html_entity_decode (val['descripcion']);
}
$('#id_module').append ($('<option></option>').attr ('value', val['id_agente_modulo']).text (s));
});
$('#id_module').fadeIn ('normal');
}
});
});
}
var previous_report_type;
function report_type_changed () {
var inputs = [];
inputs.push ("get_report_type_data_source=1");
inputs.push ("id_report_type=" + this.value);
inputs.push ("page=godmode/reporting/reporting_builder");
jQuery.ajax ({
data: inputs.join ("&"),
type: 'GET',
url: action="ajax.php",
timeout: 10000,
success: function (report_type) {
module_inputs = '#table-add-item-2, #table-add-item-3';
custom_graph_inputs = '#table-add-item-4';
if (previous_report_type != report_type) {
$('#id_module').empty ().append ($('<option></option>').attr ('value', 0).text ("--"));
$('#id_agent').attr ('value', '0');
$('#id_group').attr ('value', '0');
switch (report_type) {
case 'module':
$(custom_graph_inputs).fadeOut ('normal', function () {
$(module_inputs).fadeIn ('normal');
});
break;
case 'custom-graph':
$(module_inputs).fadeOut ('normal', function () {
$(custom_graph_inputs).fadeIn ('normal');
});
break;
case 'sla':
case 'agent-group':
$(module_inputs).fadeOut ('normal');
$(custom_graph_inputs).fadeOut ('normal');
break;
default:
}
}
previous_report_type = report_type;
}
});
}
function group_changed () {
var inputs = [];
inputs.push ("get_group_json=1");
inputs.push ("id_group=" + this.value);
inputs.push ("page=godmode/groups/group_list");
jQuery.ajax ({
data: inputs.join ("&"),
type: 'GET',
url: action="ajax.php",
timeout: 10000,
dataType: 'json',
success: function (data) {
var data_ = data;
$('#icon_preview').fadeOut ('normal', function () {
$('#icon_preview').empty ();
if (data_ != null) {
$('#icon_preview').append ($('<img />').attr ('src', 'images/groups_small/'+data['icon']+'.png'));
}
$('#icon_preview').fadeIn ();
});
}
});
}
$(document).ready (function () {
$('#id_agent').change (agent_changed);
$('#type').change (report_type_changed);
$('#id_group').change (group_changed);
});
</script>

View File

@ -771,11 +771,11 @@ function show_alert_row_edit ($row2, $tdcolor = "datos", $id_tipo_modulo = 1, $c
return $string;
}
function show_alert_show_view ($data, $tdcolor = "datos", $combined = 0){
function show_alert_show_view ($data, $tdcolor = "datos", $combined = 0) {
global $config;
global $lang_label;
if ($combined == 0){
if ($combined == 0) {
$module_name = get_db_sql ("SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = ".$data["id_agente_modulo"]);
$agent_name = get_db_sql ("SELECT tagente.nombre FROM tagente_modulo, tagente WHERE tagente_modulo.id_agente = tagente.id_agente AND tagente_modulo.id_agente_modulo = ".$data["id_agente_modulo"]);
$id_agente = get_db_sql ("SELECT id_agente FROM tagente_modulo WHERE id_agente_modulo = ".$data["id_agente_modulo"]);
@ -912,6 +912,8 @@ function get_report_types () {
$types['min_value'] = lang_string ('min_value');
$types['sumatory'] = lang_string ('sumatory');
$types['general_group_report'] = lang_string ('general_group_report');
$types['monitor_health'] = lang_string ('monitor_health');
$types['agents_detailed'] = lang_string ('agents_detailed');
return $types;
}
@ -963,6 +965,10 @@ function get_report_type_data_source ($type) {
case 'monitor_report':
case 11:
case 'general_group_report':
case 12:
case 'monitor_health':
case 13:
case 'agents_detailed':
return 'agent-group';
}
return 'unknown';
@ -973,7 +979,7 @@ function get_report_type_data_source ($type) {
*
* @param $module_name Module name to check.
*
* @return true if the module is of type "date"
* @return true if the module is of type "data"
*/
function is_module_data ($module_name) {
$result = ereg ("^(.*_data)$", $module_name);

View File

@ -148,7 +148,67 @@ function give_disabled_group ($id_group) {
return (bool) get_db_value ('disabled', 'tgrupo', 'id_grupo', (int) $id_group);
}
/**
* Get all the agents in a group.
*
* @param $id_group Group id to get all agents.
*
* @return An array with all agents in the group.
*/
function get_agents_in_group ($id_group) {
return get_db_all_rows_field_filter ('tagente', 'id_grupo', (int) $id_group);
}
/**
* Get all the modules in an agent.
*
* @param $id_agent Agent id to get all modules.
*
* @return An array with all modules in the agent.
*/
function get_modules_in_agent ($id_agent) {
return get_db_all_rows_field_filter ('tagente_modulo', 'id_agente', (int) $id_agent);
}
/**
* Get all the simple alerts of an agent.
*
* @param $id_agent Agent id to get all simple alerts.
*
* @return An array with all simple alerts defined for an agent.
*/
function get_simple_alerts_in_agent ($id_agent) {
$sql = sprintf ('SELECT talerta_agente_modulo.*
FROM talerta_agente_modulo, tagente_modulo
WHERE talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo
AND tagente_modulo.id_agente = %d', $id_agent);
return get_db_all_rows_sqlfree ($sql);
}
/**
* Get all the combined alerts of an agent.
*
* @param $id_agent Agent id to get all combined alerts.
*
* @return An array with all combined alerts defined for an agent.
*/
function get_combined_alerts_in_agent ($id_agent) {
return get_db_all_rows_field_filter ('talerta_agente_modulo', 'id_agent', (int) $id_agent);
}
/**
* Get all the alerts of an agent, simple and combined.
*
* @param $id_agent Agent id to get all alerts.
*
* @return An array with all alerts defined for an agent.
*/
function get_alerts_in_agent ($id_agent) {
$simple_alerts = get_simple_alerts_in_agent ($id_agent);
$combined_alerts = get_combined_alerts_in_agent ($id_agent);
return array_merge ($simple_alerts, $combined_alerts);
}
// ---------------------------------------------------------------
// Returns group given ID
@ -201,29 +261,16 @@ function dame_agente_modulo_id ($id_agente, $id_tipomodulo, $nombre) {
// Returns event description given it's id
// ---------------------------------------------------------------
function return_event_description ($id_event){
require("config.php");
$query1="SELECT evento FROM tevento WHERE id_evento = $id_event";
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup[0];
else
$pro = "";
return $pro;
function return_event_description ($id_event) {
return (string) get_db_value ('evento', 'tevento', 'id_evento', (int) $id_event);
}
// ---------------------------------------------------------------
// Return ID_Group from an event given as id_event
// ---------------------------------------------------------------
function gime_idgroup_from_idevent($id_event){
require("config.php");
$query1="SELECT * FROM tevento WHERE id_evento = ".$id_event;
$pro = -1;
if ($resq1=mysql_query($query1))
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup["id_grupo"];
return $pro;
function gime_idgroup_from_idevent ($id_event) {
return (int) get_db_value ('id_grupo', 'tevento', 'id_evento', (int) $id_event);
}
@ -231,15 +278,8 @@ function gime_idgroup_from_idevent($id_event){
// Return module id given name of module type
// ---------------------------------------------------------------
function dame_module_id($nombre){
require("config.php");
$query1="SELECT * FROM ttipo_modulo WHERE nombre = '".$nombre."'";
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup["id_tipo"];
else
$pro = "";
return $pro;
function dame_module_id ($nombre){
return (int) get_db_value ('id_tipo', 'ttipo_modulo', 'nombre', $nombre);
}
@ -247,106 +287,56 @@ function dame_module_id($nombre){
// Returns agent name when given its ID
// ---------------------------------------------------------------
function dame_nombre_agente ($id){
require("config.php");
$query1="SELECT * FROM tagente WHERE id_agente = ".$id;
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup["nombre"];
else
$pro = "";
return $pro;
function dame_nombre_agente ($id_agente) {
return (string) get_db_value ('nombre', 'tagente', 'id_agente', (int) $id_agente);
}
// ---------------------------------------------------------------
// Returns password (HASH) given user_id
// ---------------------------------------------------------------
function dame_password($id_usuario){
require("config.php");
$query1="SELECT * FROM tusuario WHERE id_usuario= '".$id_usuario."'";
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup["password"];
else
$pro = "";
return $pro;
function dame_password ($id_usuario) {
return (string) get_db_value ('password', 'tusuario', 'id_usuario', (int) $id_usuario);
}
// ---------------------------------------------------------------
// Returns name of an alert given ID
// ---------------------------------------------------------------
function dame_nombre_alerta($id){
require("config.php");
$query1="SELECT * FROM talerta WHERE id_alerta = ".$id;
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup["nombre"];
else
$pro = "";
return $pro;
function dame_nombre_alerta ($id_alert) {
return (string) get_db_value ('nombre', 'talerta', 'id_alerta', (int) $id_alert);
}
// ---------------------------------------------------------------
// Returns name of a modules group
// ---------------------------------------------------------------
function dame_nombre_grupomodulo($id){
require("config.php");
$query1="SELECT * FROM tmodule_group WHERE id_mg = ".$id;
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup["name"];
else
$pro = "";
return $pro;
function dame_nombre_grupomodulo ($id_module_group) {
return (string) get_db_value ('name', 'tmodule_group', 'id_mg', (int) $id_module_group);
}
// ---------------------------------------------------------------
// Returns name of a export server
// ---------------------------------------------------------------
function dame_nombre_servidorexportacion($id){
require("config.php");
$query1="SELECT id, name FROM tserver_export WHERE id = ".$id;
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup["name"];
else
$pro = "";
return $pro;
function dame_nombre_servidorexportacion ($id_server) {
return (string) get_db_value ('name', 'tserver_export', 'id', (int) $id_server);
}
// ---------------------------------------------------------------
// Returns name of a plugin module
// ---------------------------------------------------------------
function dame_nombre_pluginid($id){
require("config.php");
$query1="SELECT id, name FROM tplugin WHERE id = ".$id;
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup["name"];
else
$pro = "";
return $pro;
function dame_nombre_pluginid ($id_plugin) {
return (string) get_db_value ('name', 'tplugin', 'id', (int) $id_plugin);
}
// ---------------------------------------------------------------
// Returns id of a moduletype
// ---------------------------------------------------------------
function giveme_module_type($id){
require("config.php");
$query1="SELECT id_tipo, nombre FROM ttipo_modulo WHERE id_tipo = ".$id;
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup["nombre"];
else
$pro = "";
return $pro;
function giveme_module_type ($id_type) {
return (string) get_db_value ('nombre', 'ttipo_modulo', 'id_tipo', (int) $id_type);
}
// ---------------------------------------------------------------
@ -364,7 +354,7 @@ function dame_nombre_agente_agentemodulo ($id_agente_modulo) {
// Return agent module name, given a ID of agente_module table
// ---------------------------------------------------------------
function dame_nombre_modulo_agentemodulo ($id_agente_modulo) {
return get_db_value ('nombre', 'tagente_modulo', 'id_agente_modulo', $id_agente_modulo);
return (string) get_db_value ('nombre', 'tagente_modulo', 'id_agente_modulo', (int) $id_agente_modulo);
}
@ -372,46 +362,112 @@ function dame_nombre_modulo_agentemodulo ($id_agente_modulo) {
// Return agent module, given a ID of agente_module table
// ---------------------------------------------------------------
function dame_id_tipo_modulo_agentemodulo($id_agente_modulo){
require("config.php");
$query1="SELECT * FROM tagente_modulo WHERE id_agente_modulo = ".$id_agente_modulo;
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro = $rowdup["id_tipo_modulo"];
else
$pro = "";
return $pro;
function dame_id_tipo_modulo_agentemodulo ($id_agente_modulo) {
return (int) get_db_value ('id_tipo_modulo', 'tagente_modulo', 'id_agente_modulo', (int) $id_agente_modulo);
}
// ---------------------------------------------------------------
// Returns name of the user when given ID
// ---------------------------------------------------------------
function dame_nombre_real($id){
require("config.php");
$query1="SELECT * FROM tusuario WHERE id_usuario = '".$id."'";
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup["nombre_real"];
else
$pro = "";
return $pro;
function dame_nombre_real ($id_user) {
return (string) get_db_value ('nombre_real', 'tusuario', 'id_usuario', (int) $id_user);
}
/**
* Get all the times a monitor went down during a period.
*
* @param $id_agent_module Agent module of the monitor.
* @param $period Period timed to check from date
* @param $date Date to check (now by default)
*
* @return The number of times a monitor went down.
*/
function get_monitor_downs_in_period ($id_agent_module, $period, $date = 0) {
if (!$date)
$date = time ();
$datelimit = $date - $period;
$sql = sprintf ('SELECT COUNT(*) FROM tevento WHERE
event_type = "monitor_down"
AND id_agentmodule = %d
AND utimestamp > %d AND utimestamp <= %d',
$id_agent_module, $datelimit, $date);
$down = get_db_sql ($sql);
return $down;
}
/**
* Get the last time a monitor went down during a period.
*
* @param $id_agent_module Agent module of the monitor.
* @param $period Period timed to check from date
* @param $date Date to check (now by default)
*
* @return The last time a monitor went down.
*/
function get_monitor_last_down_timestamp_in_period ($id_agent_module, $period, $date = 0) {
if (!$date)
$date = time ();
$datelimit = $date - $period;
$sql = sprintf ('SELECT MAX(timestamp) FROM tevento WHERE
event_type = "monitor_down"
AND id_agentmodule = %d
AND utimestamp > %d AND utimestamp <= %d',
$id_agent_module, $datelimit, $date);
$timestamp = get_db_sql ($sql);
return $timestamp;
}
/**
* Get all the times an alerts fired during a period.
*
* @param $id_agent_module Agent module of the alert.
* @param $period Period timed to check from date
* @param $date Date to check (now by default)
*
* @return The number of times an alert fired.
*/
function get_alert_fires_in_period ($id_agent_module, $period, $date = 0) {
if (!$date)
$date = time ();
$datelimit = $date - $period;
$sql = sprintf ('SELECT COUNT(*) FROM tevento WHERE
event_type = "alert_fired"
AND id_agentmodule = %d
AND utimestamp > %d AND utimestamp <= %d',
$id_agent_module, $datelimit, $date);
$down = get_db_sql ($sql);
return (int) $down;
}
/**
* Get the last time an alert fired during a period.
*
* @param $id_agent_module Agent module of the monitor.
* @param $period Period timed to check from date
* @param $date Date to check (now by default)
*
* @return The last time an alert fired.
*/
function get_alert_last_fire_timestamp_in_period ($id_agent_module, $period, $date = 0) {
if (!$date)
$date = time ();
$datelimit = $date - $period;
$sql = sprintf ('SELECT MAX(timestamp) FROM tevento WHERE
event_type = "alert_fired"
AND id_agentmodule = %d
AND utimestamp > %d AND utimestamp <= %d',
$id_agent_module, $datelimit, $date);
$timestamp = get_db_sql ($sql);
return $timestamp;
}
// ---------------------------------------------------------------
// This function returns ID of user who has created incident
// ---------------------------------------------------------------
function give_incident_author($id){
require("include/config.php");
$query1="SELECT * FROM tincidencia WHERE id_incidencia = '".$id."'";
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup["id_usuario"];
else
$pro = "";
return $pro;
function give_incident_author ($id_incident) {
return (string) get_db_value ('id_usuario', 'tincidencia', 'id_incidencia', (int) $id_incident);
}
// ---------------------------------------------------------------
@ -1146,6 +1202,13 @@ function get_db_sql ($sql, $field = 0){
return NULL;
}
/**
* Get all the result rows using an SQL statement.
*
* @param $sql SQL statement to execute.
*
* @return A matrix with all the values returned from the SQL statement
*/
function get_db_all_rows_sqlfree ($sql) {
global $config;
$retval = array ();
@ -1161,10 +1224,26 @@ function get_db_all_rows_sqlfree ($sql) {
return $retval;
}
/**
* Get all the rows in a table of the database.
*
* @param $table Database table name.
*
* @return A matrix with all the values in the table
*/
function get_db_all_rows_in_table ($table) {
return get_db_all_rows_sqlfree ('SELECT * FROM '.$table);
}
/**
* Get all the rows in a table of the databes filtering from a field.
*
* @param $table Database table name.
* @param $field Field of the table.
* @param $condition Condition the field must have to be selected.
*
* @return A matrix with all the values in the table that matches the condition in the field
*/
function get_db_all_rows_field_filter ($table, $field, $condition) {
if (is_int ($condition)) {
$sql = sprintf ('SELECT * FROM %s WHERE %s = %d', $table, $field, $condition);
@ -1177,6 +1256,15 @@ function get_db_all_rows_field_filter ($table, $field, $condition) {
return get_db_all_rows_sqlfree ($sql);
}
/**
* Get all the rows in a table of the databes filtering from a field.
*
* @param $table Database table name.
* @param $field Field of the table.
* @param $condition Condition the field must have to be selected.
*
* @return A matrix with all the values in the table that matches the condition in the field
*/
function get_db_all_fields_in_table ($table, $field) {
return get_db_all_rows_sqlfree ('SELECT '.$field.' FROM '. $table);
}
@ -1331,7 +1419,7 @@ function return_moduledata_sum_value ($id_agent_module, $period, $date = 0) {
$datelimit = $date - $period; // limit date
$agent_module = get_db_row ('tagente_modulo', 'id_agente_modulo', $id_agent_module);
$module_name = get_db_value ('nombre', 'ttipo_modulo', 'id_tipo', $agent_module['id_tipo_modulo']);
echo $module_name;
if (is_module_data_string ($module_name)) {
return lang_string ('wrong_module_type');
}
@ -1361,7 +1449,7 @@ function return_moduledata_sum_value ($id_agent_module, $period, $date = 0) {
} else {
$times = 1;
}
if (is_module_data_proc ($module_name)) {
if (is_module_proc ($module_name)) {
$previous_data = $data['datos'] * $interval;
} else {
$previous_data = $data['datos'];

View File

@ -31,32 +31,32 @@
function print_select ($fields, $name, $selected = '', $script = '', $nothing = 'select', $nothing_value = '0', $return = false) {
$output = "\n";
$attributes = ($script) ? 'onchange="'. $script .'"' : '';
$output .= '<select id="'.$name.'" name="'.$name.'" '.$attributes.">\n";
$attributes = ($script) ? 'onchange="'. $script .'"' : '';
$output .= '<select id="'.$name.'" name="'.$name.'" '.$attributes.">\n";
if ($nothing != '') {
$output .= ' <option value="'.$nothing_value.'"';
if ($nothing_value == $selected) {
$output .= " selected";
}
$output .= '>'.lang_string ($nothing)."</option>\n";
}
if ($nothing != '') {
$output .= ' <option value="'.$nothing_value.'"';
if ($nothing_value == $selected) {
$output .= " selected";
}
$output .= '>'.lang_string ($nothing)."</option>\n";
}
if (!empty ($fields)) {
foreach ($fields as $value => $label) {
$output .= ' <option value="'. $value .'"';
if ($value == $selected) {
$output .= ' selected';
}
if ($label === '') {
$output .= '>'. $value ."</option>\n";
} else {
$output .= '>'. $label ."</option>\n";
}
}
}
if (!empty ($fields)) {
foreach ($fields as $value => $label) {
$output .= ' <option value="'. $value .'"';
if ($value == $selected) {
$output .= ' selected';
}
if ($label === '') {
$output .= '>'. $value ."</option>\n";
} else {
$output .= '>'. $label ."</option>\n";
}
}
}
$output .= "</select>\n";
$output .= "</select>\n";
if ($return)
return $output;
@ -287,12 +287,12 @@ function print_table ($table, $return = false) {
}
if (isset ($table->rowclass)) {
foreach ($table->rowclass as $key => $class) {
$rowclass[$key] = $st;
$rowclass[$key] = $class;
}
}
if (isset ($table->colspan)) {
foreach ($table->colspan as $keyrow => $colspan) {
foreach ($colspan as $key => $span) {
foreach ($table->colspan as $keyrow => $cspan) {
foreach ($cspan as $key => $span) {
$colspan[$keyrow][$key] = ' colspan="'.$span.'"';
}
}
@ -366,7 +366,7 @@ function print_table ($table, $return = false) {
if (!isset ($size[$key])) {
$size[$key] = '';
}
if (!isset ($colspan[$key])) {
if (!isset ($colspan[$keyrow][$key])) {
$colspan[$keyrow][$key] = '';
}
if (!isset ($align[$key])) {
@ -382,7 +382,7 @@ function print_table ($table, $return = false) {
$style[$key] = '';
}
$output .= '<td id="'.$tableid.'-'.$keyrow.'-'.$key.'" style="'. $style[$key].$valign[$key].$align[$key].$size[$key].$wrap[$key] .'" '.$colspan[$key].' class="datos'.($oddeven ? "" : "2").'">'. $item .'</td>'."\n";
$output .= '<td id="'.$tableid.'-'.$keyrow.'-'.$key.'" style="'. $style[$key].$valign[$key].$align[$key].$size[$key].$wrap[$key] .'" '.$colspan[$keyrow][$key].' class="'.$class.'">'. $item .'</td>'."\n";
}
$output .= '</tr>'."\n";
}

View File

@ -16,38 +16,42 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
function return_module_SLA ($id_agent_module, $period, $min_value, $max_value){
function return_module_SLA ($id_agent_module, $period, $min_value, $max_value, $date = 0) {
require("config.php");
$datelimit = time() - $period; // limit date
$id_agent = give_db_value ("id_agente", "tagente_modulo", "id_agente_modulo", $id_agent_module);
if (! $date)
$date = time ();
$datelimit = $date - $period; // limit date
$id_agent = give_db_value ('id_agente', 'tagente_modulo', 'id_agente_modulo', $id_agent_module);
// Get the whole interval of data
$query1="SELECT * FROM tagente_datos WHERE id_agente = $id_agent AND id_agente_modulo = $id_agent_module AND utimestamp > $datelimit";
$resq1=mysql_query($query1);
$sql = sprintf ('SELECT * FROM tagente_datos
WHERE id_agente = %d AND id_agente_modulo = %d
AND utimestamp > %d AND utimestamp <= %d',
$id_agent, $id_agent_module, $datelimit, $date);
$result = mysql_query ($sql);
$last_data = "";
$total_badtime = 0;
$interval_begin = 0;
$interval_last = 0;
if ($resq1 != 0){
while ($row=mysql_fetch_array($resq1)){
if ( ($row["datos"] > $max_value) OR ($row["datos"] < $min_value)){
if ($interval_begin == 0){
$interval_begin = $row["utimestamp"];
}
} elseif ($interval_begin != 0){
// Here ends interval with data outside valid values,
// Need to add this time to counter
$interval_last = $row["utimestamp"];
$temp_time = $interval_last - $interval_begin;
$total_badtime = $total_badtime + $temp_time;
$interval_begin = 0;
$interval_last = 0;
}
}
} else
if (! $result) {
return 100;
$result = 100 - ($total_badtime / $period ) * 100;
}
while ($row = mysql_fetch_array ($result)) {
if ( ($row["datos"] > $max_value) || ($row["datos"] < $min_value)) {
if ($interval_begin == 0) {
$interval_begin = $row["utimestamp"];
}
} elseif ($interval_begin != 0){
// Here ends interval with data outside valid values,
// Need to add this time to counter
$interval_last = $row["utimestamp"];
$temp_time = $interval_last - $interval_begin;
$total_badtime = $total_badtime + $temp_time;
$interval_begin = 0;
$interval_last = 0;
}
}
$result = 100 - ($total_badtime / $period) * 100;
return $result;
}
@ -165,20 +169,23 @@ function general_stats ( $id_user, $id_group = 0) {
return $data;
}
function event_reporting ($id_agent, $period){
function event_reporting ($id_agent, $period, $date = 0, $return = false) {
require("config.php");
require ("include/languages/language_".$config["language"].".php");
$id_user=$_SESSION["id_usuario"];
$output = '';
$id_user = $_SESSION["id_usuario"];
global $REMOTE_ADDR;
$ahora = date("U");
$mytimestamp = $ahora - $period;
if (! $date)
$date = time ();
$mytimestamp = $date - $period;
echo "<table cellpadding='4' cellspacing='4' width='100%' class='databox'>";
echo "<tr>";
echo "<th>".$lang_label["status"]."</th>";
echo "<th>".$lang_label["event_name"]."</th>";
echo "<th>".$lang_label["id_user"]."</th>";
echo "<th>".$lang_label["timestamp"]."</th>";
$output .= "<table cellpadding='4' cellspacing='4' width='100%' class='databox'>";
$output .= "<tr>";
$output .= "<th>".$lang_label["status"]."</th>";
$output .= "<th>".$lang_label["event_name"]."</th>";
$output .= "<th>".$lang_label["id_user"]."</th>";
$output .= "<th>".$lang_label["timestamp"]."</th>";
$color = 1;
$id_evento = 0;
@ -198,65 +205,312 @@ function event_reporting ($id_agent, $period){
$tdcolor = "datos2";
$color = 1;
}
echo "<tr><td class='$tdcolor' align='center'>";
$output .= "<tr><td class='$tdcolor' align='center'>";
if ($row2["estado"] == 0)
echo "<img src='images/dot_red.png'>";
$output .= "<img src='images/dot_red.png'>";
else
echo "<img src='images/dot_green.png'>";
echo "<td class='$tdcolor'>".$row2["evento"];
echo "<td class='$tdcolor'>";
$output .= "<img src='images/dot_green.png'>";
$output .= "<td class='$tdcolor'>".$row2["evento"];
$output .= "<td class='$tdcolor'>";
if ($row2["estado"] <> 0)
echo substr($row2["id_usuario"],0,8)."<a href='#' class='tip'> <span>".dame_nombre_real($row2["id_usuario"])."</span></a>";
echo "<td class='".$tdcolor."f9'>".$row2["timestamp"];
echo "</td></tr>";
$output .= substr($row2["id_usuario"],0,8)."<a href='#' class='tip'> <span>".dame_nombre_real($row2["id_usuario"])."</span></a>";
$output .= "<td class='".$tdcolor."f9'>".$row2["timestamp"];
$output .= "</td></tr>";
}
}
echo "</table>";
$output .= "</table>";
if (!$return)
echo $output;
return $output;
}
function alert_reporting ($id_agent_module){
global $config;
require ("include/languages/language_".$config["language"].".php");
/**
* Get a report for alerts in a group of agents.
*
* It prints the numbers of alerts defined, fired and not fired in a group.
* It also prints all the alerts that were fired grouped by agents.
*
* @param $id_group Group to get info of the alerts.
* @param $period Period of time of the desired alert report.
* @param $date Beggining date of the report (current date by default).
* @param $return Flag to return or echo the report (by default).
*/
function alert_reporting ($id_group, $period = 0, $date = 0, $return = false) {
if (! $date)
$date = time ();
$datelimit = $date - $period;
$output = '';
$alerts = array ();
$agents = get_agents_in_group ($id_group);
foreach ($agents as $agent) {
$agent_alerts = get_alerts_in_agent ($agent['id_agente']);
$alerts = array_merge ($alerts, $agent_alerts);
}
if (sizeof ($alerts) == 0)
return;
$query_gen='SELECT talerta_agente_modulo.alert_text, talerta_agente_modulo.id_alerta, talerta_agente_modulo.descripcion, talerta_agente_modulo.last_fired, talerta_agente_modulo.times_fired, tagente_modulo.nombre, talerta_agente_modulo.dis_max, talerta_agente_modulo.dis_min, talerta_agente_modulo.max_alerts, talerta_agente_modulo.time_threshold, talerta_agente_modulo.min_alerts, talerta_agente_modulo.id_agente_modulo, tagente_modulo.id_agente_modulo FROM tagente_modulo, talerta_agente_modulo WHERE tagente_modulo.id_agente_modulo = talerta_agente_modulo.id_agente_modulo and talerta_agente_modulo.id_agente_modulo = '.$id_agent_module.' ORDER BY tagente_modulo.nombre';
$result_gen=mysql_query($query_gen);
if (mysql_num_rows ($result_gen)) {
echo "<table cellpadding='4' cellspacing='4' width='100%' border=0 class='databox'>";
echo "<tr>
<th>".$lang_label["status"]."</th>
<th>".$lang_label["description"]."</th>
<th>".$lang_label["time_threshold"]."</th>
<th>".$lang_label["last_fired"]."</th>
<th>".$lang_label["times_fired"]."</th>";
$alerts_fired = array ();
$agents = array ();
foreach ($alerts as $alert) {
$fires = get_alert_fires_in_period ($alert['id_agente_modulo'], $period, $date);
if (! $fires) {
continue;
}
$alerts_fired[$alert['id_aam']] = $fires;
$data = array ();
$color=1;
while ($data=mysql_fetch_array($result_gen)){
if ($color == 1){
$tdcolor = "datos";
$color = 0;
}
else {
$tdcolor = "datos2";
$color = 1;
}
echo "<tr>";
if ($data["times_fired"] <> 0)
echo "<td class='".$tdcolor."' align='center'><img src='images/dot_red.png'></td>";
else
echo "<td class='".$tdcolor."' align='center'><img src='images/dot_green.png'></td>";
echo "<td class='".$tdcolor."'>".$data["descripcion"]."</td>";
echo "<td align='center' class='".$tdcolor."'>".human_time_description($data["time_threshold"]);
if ($data["last_fired"] == "0000-00-00 00:00:00") {
echo "<td align='center' class='".$tdcolor."f9'>".$lang_label["never"]."</td>";
}
else {
echo "<td align='center' class='".$tdcolor."f9'>".human_time_comparation ($data["last_fired"])."</td>";
}
echo "<td align='center' class='".$tdcolor."'>".$data["times_fired"]."</td>";
/* Add alerts fired to $agents_fired_alerts indexed by id_agent */
$id_agent = $alert['id_agent'];
if (!isset ($agents[$id_agent])) {
$agents[$id_agent] = array ();
}
echo '</table>';
array_push ($agents[$id_agent], $alert);
}
$fired_percentage = round (sizeof ($alerts_fired) / sizeof ($alerts) * 100, 2);
$not_fired_percentage = 100 - $fired_percentage;
$output .= '<img src="http://localhost/pandora/reporting/fgraph.php?tipo=alerts_fired_pipe&height=150&width=280&fired='.
$fired_percentage.'&not_fired='.$not_fired_percentage.'" style="float: right; border: 1px solid black">';
$output .= '<strong>'.lang_string ('agents_with_fired_alerts').': '.sizeof ($agents).'</strong><br />';
$output .= '<strong>'.lang_string ('fired_alerts').': '.sizeof ($alerts_fired).'</strong><br />';
$output .= '<strong>'.lang_string ('total_alerts_monitored').': '.sizeof ($alerts).'</strong><br />';
$table->width = '100%';
$table->class = 'databox';
$table->size = array ();
$table->size[0] = '100px';
$table->data = array ();
$table->head = array ();
$table->head[0] = lang_string ('agent');
$table->head[1] = lang_string ('alert_description');
$table->head[2] = lang_string ('times_fired');
$table->head[3] = lang_string ('priority');
foreach ($agents as $alerts) {
$data = array ();
foreach ($alerts as $alert) {
if (! isset ($data[0]))
$data[0] = '<strong>'.dame_nombre_agente_agentemodulo ($alert['id_agente_modulo']).'</strong>';
else
$data[0] = '';
$data[1] = $alert['descripcion'];
$data[2] = $alerts_fired[$alert['id_aam']];
$data[3] = $alert['priority'];
array_push ($table->data, $data);
}
}
$output .= print_table ($table, true);
if (!$return)
echo $output;
return $output;
}
/**
* Get a report for monitors modules in a group of agents.
*
* It prints the numbers of monitors defined, showing those which went up and down, in a group.
* It also prints all the down monitors in the group.
*
* @param $id_group Group to get info of the monitors.
* @param $period Period of time of the desired monitor report.
* @param $date Beggining date of the report (current date by default).
* @param $return Flag to return or echo the report (by default).
*/
function monitor_health_reporting ($id_group, $period = 0, $date = 0, $return = false) {
if (! $date)
$date = time ();
$datelimit = $date - $period;
$output = '';
$sql = sprintf ('SELECT * FROM tagente_modulo, ttipo_modulo, tagente
WHERE id_tipo_modulo = id_tipo
AND tagente.id_agente = tagente_modulo.id_agente
AND ttipo_modulo.nombre like "%%_proc"
AND tagente.id_grupo = %d', $id_group);
$monitors = get_db_all_rows_sqlfree ($sql);
if (sizeof ($monitors) == 0)
return;
$monitors_down = 0;
$agents = array ();
foreach ($monitors as $monitor) {
$down = get_monitor_downs_in_period ($monitor['id_agente_modulo'], $period, $date);
if (! $down) {
continue;
}
$data = array ();
/* Add monitors fired to $agents_fired_alerts indexed by id_agent */
$id_agent = $monitor['id_agente'];
if (!isset ($agents[$id_agent])) {
$agents[$id_agent] = array ();
}
array_push ($agents[$id_agent], $monitor);
$monitors_down++;
}
$down_percentage = round ($monitors_down / sizeof ($monitors) * 100, 2);
$not_down_percentage = 100 - $down_percentage;
$output .= '<img src="http://localhost/pandora/reporting/fgraph.php?tipo=monitors_health_pipe&height=150&width=280&down='.
$down_percentage.'&not_down='.$not_down_percentage.'" style="float: right; border: 1px solid black">';
$output .= '<strong>'.lang_string ('total_monitors').': '.sizeof ($monitors).'</strong><br />';
$output .= '<strong>'.lang_string ('monitors_down_on_period').': '.$monitors_down.'</strong><br />';
$table->width = '100%';
$table->class = 'databox';
$table->size = array ();
$table->size[0] = '100px';
$table->data = array ();
$table->head = array ();
$table->head[0] = lang_string ('agent');
$table->head[1] = lang_string ('alert_description');
foreach ($agents as $monitors) {
$data = array ();
foreach ($monitors as $monitor) {
if (! isset ($data[0]))
$data[0] = '<strong>'.$monitor['nombre'].'</strong>';
else
$data[0] = '';
$data[1] = $monitor['descripcion'];
array_push ($table->data, $data);
}
}
$output .= print_table ($table, true);
if (!$return)
echo $output;
return $output;
}
/**
* Get a general report of a group of agents.
*
* It shows the number of agents and no more things right now.
*
* @param $id_group Group to get the report
* @param $return Flag to return or echo the report (by default).
*/
function general_group_reporting ($id_group, $return = false) {
$output = '';
$agents = give_db_value ('COUNT(*)', 'tagente', 'id_grupo', $id_group);
$output .= '<strong>'.lang_string ('agents_in_group').': '.$agents.'</strong><br />';
if (!$return)
echo $output;
return $output;
}
/**
* Get a detailed report of agents in a group.
*
* It
*
* @param $id_group Group to get the report
* @param $return Flag to return or echo the report (by default).
*/
function agents_detailed_reporting ($id_group, $period = 0, $date = 0, $return = false) {
$output = '';
$agents = give_db_value ('COUNT(*)', 'tagente', 'id_grupo', $id_group);
$table_modules->width = '750px';
$table_alerts->width = '750px';
$table_monitors->width = '750px';
$table_monitors->align = array ();
$table_monitors->align[1] = 'right';
$table_monitors->head = array ();
$table_monitors->head[0] = lang_string ('monitor');
$table_monitors->head[1] = lang_string ('last_failure');
$table_alerts->head = array ();
$table_alerts->head[0] = lang_string ('type');
$table_alerts->head[1] = lang_string ('description');
$table_alerts->head[2] = lang_string ('min');
$table_alerts->head[3] = lang_string ('max');
$table_alerts->head[4] = lang_string ('threshold');
$table_alerts->head[5] = lang_string ('last_fired');
$table_alerts->head[6] = lang_string ('times_fired');
$agents = get_agents_in_group ($id_group);
$n_a_string = lang_string ('N/A').'(*)';
foreach ($agents as $agent) {
$monitors = array ();
$table_modules->data = array ();
$table_modules->head = array ();
$table_alerts->data = array ();
$modules = get_modules_in_agent ($agent['id_agente']);
/* Show modules in agent */
$output .= '<h3>'.lang_string ('agent').' - '.$agent['nombre'].'</h3>';
$output .= '<h4>'.lang_string ('modules').'</h3>';
$data = array ();
foreach ($modules as $module) {
if ($module['descripcion'] != $n_a_string && $module['descripcion'] != '')
$data[0] = $module['descripcion'];
else
$data[0] = $module['nombre'];
$module_name = giveme_module_type ($module['id_tipo_modulo']);
if (is_module_proc ($module_name)) {
array_push ($monitors, $module);
}
array_push ($table_modules->data, $data);
}
$output .= print_table ($table_modules, true);
/* Show alerts in agent */
$alerts = get_alerts_in_agent ($agent['id_agente']);
foreach ($alerts as $alert) {
$fires = get_alert_fires_in_period ($alert['id_agente_modulo'], $period, $date);
if (! $fires) {
continue;
}
$alert_type = get_db_row ('talerta', 'id_alerta', $alert['id_alerta']);
$data = array ();
$data[0] = $alert_type['nombre'];
$data[1] = $alert['descripcion'];
$data[2] = $alert['dis_min'];
$data[3] = $alert['dis_max'];
$data[4] = $alert['time_threshold'];
$data[5] = get_alert_last_fire_timestamp_in_period ($alert['id_agente_modulo'], $period, $date);
$data[6] = $fires;
array_push ($table_alerts->data, $data);
}
if (sizeof ($table_alerts->data)) {
$output .= '<h4>'.lang_string ('alerts').'</h4>';
$output .= print_table ($table_alerts, true);
}
/* Show monitor status in agent (if any) */
if (sizeof ($monitors) == 0) {
continue;
}
$table_monitors->data = array ();
foreach ($monitors as $monitor) {
$downs = get_monitor_downs_in_period ($monitor['id_agente_modulo'], $period, $date);
if (! $downs) {
continue;
}
$data = array ();
if ($monitor['descripcion'] != $n_a_string && $monitor['descripcion'] != '')
$data[0] = $monitor['descripcion'];
else
$data[0] = $monitor['nombre'];
$data[1] = get_monitor_last_down_timestamp_in_period ($monitor['id_agente_modulo'], $period, $date);
array_push ($table_monitors->data, $data);
}
if (sizeof ($table_monitors->data)) {
$output .= '<h4>'.lang_string ('monitors').'</h4>';
$output .= print_table ($table_monitors, true);
}
}
if (!$return)
echo $output;
return $output;
}
?>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -16,4 +16,19 @@ function winopeng(url,wid) {
function pandora_help(help_id) {
nueva_ventana=open("general/pandora_help.php?id="+help_id, "pandorahelp","width=600,height=500,status=no,toolbar=no,menubar=no,scrollbar=yes");
}
}
/**
* Decode HTML entities into characters. Useful when receiving something from AJAX
*
* @param str String to convert
*
* @retval str with entities decoded
*/
function html_entity_decode (str) {
if (! str)
return "";
var ta = document.createElement ("textarea");
ta.innerHTML = str.replace (/</g, "&lt;").replace (/>/g,"&gt;");
return ta.value;
}

View File

@ -0,0 +1,22 @@
/* Inicialització en català per a l'extenció 'calendar' per jQuery. */
/* Writers: (joan.leon@gmail.com). */
jQuery(function($){
$.datepicker.regional['ca'] = {clearText: 'Netejar', clearStatus: '',
closeText: 'Tancar', closeStatus: '',
prevText: '&lt;Ant', prevStatus: '',
nextText: 'Seg&gt;', nextStatus: '',
currentText: 'Avui', currentStatus: '',
monthNames: ['Gener','Febrer','Mar&ccedil;','Abril','Maig','Juny',
'Juliol','Agost','Setembre','Octubre','Novembre','Decembre'],
monthNamesShort: ['Gen','Feb','Mar','Abr','Mai','Jun',
'Jul','Ago','Set','Oct','Nov','Dec'],
monthStatus: '', yearStatus: '',
weekHeader: 'Sm', weekStatus: '',
dayNames: ['Diumenge','Dilluns','Dimarts','Dimecres','Dijous','Divendres','Dissabte'],
dayNamesShort: ['Dug','Dln','Dmt','Dmc','Djs','Dvn','Dsb'],
dayNamesMin: ['Dg','Dl','Dt','Dc','Dj','Dv','Ds'],
dayStatus: 'DD', dateStatus: 'D, M d',
dateFormat: 'yy-mm-dd', firstDay: 1,
initStatus: '', isRTL: false};
$.datepicker.setDefaults($.datepicker.regional['ca']);
});

View File

@ -0,0 +1,22 @@
/* German initialisation for the jQuery UI date picker plugin. */
/* Written by Milian Wolff (mail@milianw.de). */
jQuery(function($){
$.datepicker.regional['de'] = {clearText: 'löschen', clearStatus: 'aktuelles Datum löschen',
closeText: 'schließen', closeStatus: 'ohne Änderungen schließen',
prevText: '&#x3c;zurück', prevStatus: 'letzten Monat zeigen',
nextText: 'Vor&#x3e;', nextStatus: 'nächsten Monat zeigen',
currentText: 'heute', currentStatus: '',
monthNames: ['Januar','Februar','März','April','Mai','Juni',
'Juli','August','September','Oktober','November','Dezember'],
monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
'Jul','Aug','Sep','Okt','Nov','Dez'],
monthStatus: 'anderen Monat anzeigen', yearStatus: 'anderes Jahr anzeigen',
weekHeader: 'Wo', weekStatus: 'Woche des Monats',
dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
dayStatus: 'Setze DD als ersten Wochentag', dateStatus: 'Wähle D, M d',
dateFormat: 'yy-mm-dd', firstDay: 1,
initStatus: 'Wähle ein Datum', isRTL: false};
$.datepicker.setDefaults($.datepicker.regional['de']);
});

View File

@ -0,0 +1 @@
/* There's no need to add nothing here */

View File

@ -0,0 +1,22 @@
/* Inicialización en español para la extensión 'UI date picker' para jQuery. */
/* Traducido por Vester (xvester@gmail.com). */
jQuery(function($){
$.datepicker.regional['es'] = {clearText: 'Limpiar', clearStatus: '',
closeText: 'Cerrar', closeStatus: '',
prevText: '&lt;Ant', prevStatus: '',
nextText: 'Sig&gt;', nextStatus: '',
currentText: 'Hoy', currentStatus: '',
monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
'Jul','Ago','Sep','Oct','Nov','Dic'],
monthStatus: '', yearStatus: '',
weekHeader: 'Sm', weekStatus: '',
dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;dabo'],
dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Juv','Vie','S&aacute;b'],
dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','S&aacute;'],
dayStatus: 'DD', dateStatus: 'D, M d',
dateFormat: 'yy-mm-dd', firstDay: 1,
initStatus: '', isRTL: false};
$.datepicker.setDefaults($.datepicker.regional['es']);
});

View File

@ -0,0 +1,22 @@
/* French initialisation for the jQuery UI date picker plugin. */
/* Written by Keith Wood (kbwood@iprimus.com.au) and Stéphane Nahmani (sholby@sholby.net). */
jQuery(function($){
$.datepicker.regional['fr'] = {clearText: 'Effacer', clearStatus: '',
closeText: 'Fermer', closeStatus: 'Fermer sans modifier',
prevText: '&lt;Préc', prevStatus: 'Voir le mois précédent',
nextText: 'Suiv&gt;', nextStatus: 'Voir le mois suivant',
currentText: 'Courant', currentStatus: 'Voir le mois courant',
monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
monthNamesShort: ['Jan','Fév','Mar','Avr','Mai','Jun',
'Jul','Aoû','Sep','Oct','Nov','Déc'],
monthStatus: 'Voir un autre mois', yearStatus: 'Voir un autre année',
weekHeader: 'Sm', weekStatus: '',
dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
dayNamesMin: ['Di','Lu','Ma','Me','Je','Ve','Sa'],
dayStatus: 'Utiliser DD comme premier jour de la semaine', dateStatus: 'Choisir le DD, MM d',
dateFormat: 'yy-mm-dd', firstDay: 0,
initStatus: 'Choisir la date', isRTL: false};
$.datepicker.setDefaults($.datepicker.regional['fr']);
});

View File

@ -0,0 +1,22 @@
/* Italian initialisation for the jQuery UI date picker plugin. */
/* Written by Apaella (apaella@gmail.com). */
jQuery(function($){
$.datepicker.regional['it'] = {clearText: 'Svuota', clearStatus: '',
closeText: 'Chiudi', closeStatus: '',
prevText: '&lt;Prec', prevStatus: '',
nextText: 'Succ&gt;', nextStatus: '',
currentText: 'Oggi', currentStatus: '',
monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno',
'Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],
monthNamesShort: ['Gen','Feb','Mar','Apr','Mag','Giu',
'Lug','Ago','Set','Ott','Nov','Dic'],
monthStatus: '', yearStatus: '',
weekHeader: 'Sm', weekStatus: '',
dayNames: ['Domenica','Luned&#236','Marted&#236','Mercoled&#236','Gioved&#236','Venerd&#236','Sabato'],
dayNamesShort: ['Dom','Lun','Mar','Mer','Gio','Ven','Sab'],
dayNamesMin: ['Do','Lu','Ma','Me','Gio','Ve','Sa'],
dayStatus: 'DD', dateStatus: 'D, M d',
dateFormat: 'yy-mm-dd', firstDay: 1,
initStatus: '', isRTL: false};
$.datepicker.setDefaults($.datepicker.regional['it']);
});

View File

@ -0,0 +1,22 @@
/* Brazilian initialisation for the jQuery UI date picker plugin. */
/* Written by Leonildo Costa Silva (leocsilva@gmail.com). */
jQuery(function($){
$.datepicker.regional['pt-BR'] = {clearText: 'Limpar', clearStatus: '',
closeText: 'Fechar', closeStatus: '',
prevText: '&lt;Anterior', prevStatus: '',
nextText: 'Pr&oacute;ximo&gt;', nextStatus: '',
currentText: 'Hoje', currentStatus: '',
monthNames: ['Janeiro','Fevereiro','Mar&ccedil;o','Abril','Maio','Junho',
'Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun',
'Jul','Ago','Set','Out','Nov','Dez'],
monthStatus: '', yearStatus: '',
weekHeader: 'Sm', weekStatus: '',
dayNames: ['Domingo','Segunda-feira','Ter&ccedil;a-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sabado'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sab'],
dayNamesMin: ['Dom','Seg','Ter','Qua','Qui','Sex','Sab'],
dayStatus: 'DD', dateStatus: 'D, M d',
dateFormat: 'yy-mm-dd', firstDay: 0,
initStatus: '', isRTL: false};
$.datepicker.setDefaults($.datepicker.regional['pt-BR']);
});

View File

@ -728,7 +728,7 @@ $lang_label["combined_image"]="Kombinierter Abbildungsrender";
$lang_label["redraw"]="Neu zeichnen";
$lang_label["graph_builder_modulelist"]="Modulliste der Grapherzeuger";
$lang_label["seconds"]="Sekunden";
$lang_name["custom_graph_name"]="Anwendungsspezif. Graphenname";
$lang_label["custom_graph_name"]="Anwendungsspezif. Graphenname";
$lang_label["save"]="Sichere";
$lang_label["Manage"]="Verwalte";
$lang_label["group_view_tab"]="Gruppenansicht";

View File

@ -99,6 +99,8 @@ $lang_label["serious"]="Serious";
$lang_label["very_serious"]="Very Serious";
$lang_label["maintenance"]="Maintenance";
$lang_label["date"]="Date";
$lang_label["invalid_date"]="Invalid date selected";
$lang_label["date_older_than_now"]="Selected date is older than current date";
$lang_label["incident_main_view"]="Incident Main view";
$lang_label["all_inc"]="All incidents";
@ -141,6 +143,7 @@ $lang_label["name_type"]="Name / Type";
$lang_label["min_max"]="Min/Max";
$lang_label["detailed_monitoragent_state"]="Monitor detail";
$lang_label["alert_detail"]="Alert detail";
$lang_label["alert_description"]="Alert description";
$lang_label["detailed_alert_view"]="Detailed alert view";
$lang_label["detailed_monitor_view"]="Detailed monitor view";
$lang_label["detailed_full_view"]="Detailed full view";
@ -184,8 +187,6 @@ $lang_label["group_management"]="Group management";
$lang_label["group_name"]="Group name";
$lang_label["user_management"]="User management";
$lang_label["alert_type"]="Alert type";
$lang_label["max_value"]="Max value";
$lang_label["min_value"]="Min value";
$lang_label["time_threshold"]="Time threshold";
$lang_label["assigned_module"]="Assigned module";
@ -294,6 +295,10 @@ $lang_label["days_purge"]="Max. days before purge";
$lang_label["fired"]="Alert fired";
$lang_label["not_fired"]="Alert not fired";
$lang_label["fired_alerts"]="Alerts fired";
$lang_label["not_fired_alerts"]="Alerts not fired";
$lang_label["agents_with_fired_alerts"]="Agents with fired alerts";
$lang_label["total_alerts_monitored"]="Total alerts monitored";
$lang_label["validate_event"]="Validate event";
$lang_label["validated_event"]="Validated event";
$lang_label["not_validated_event"]="Not validated event";
@ -475,7 +480,9 @@ $lang_label["get_data_agent"]="Get data from agent";
$lang_label["purge_data"]="Purge data";
$lang_label["group_detail"]="Group detail";
$lang_label["agents_in_group"]="Number of agents in group";
$lang_label["monitors"]="Monitors";
$lang_label["monitor"]="Monitor";
$lang_label["group_view"]="Agents Group detail";
$lang_label["agents"]="Agents";
$lang_label["down"]="Down";
@ -701,6 +708,7 @@ $lang_label["done"]="Done";
$lang_label["pending"]="Pending";
$lang_label["progress"]="Progress";
$lang_label["task_name"]="Task name";
$lang_label["year"]="year";
$lang_label["days"]="days";
$lang_label["day"]="day";
$lang_label["week"]="week";
@ -709,6 +717,9 @@ $lang_label["month"]="month";
$lang_label["months"]="months";
$lang_label["hours"]="hours";
$lang_label["hour"]="hour";
$lang_label["Month"]="Month";
$lang_label["Year"]="Year";
$lang_label["Day"]="Day";
$lang_label["network_profile"]="Network profile";
$lang_label["manage_recontask"]="Manage recontask";
$lang_label["yes"]="Yes";
@ -721,7 +732,7 @@ $lang_label["combined_image"]="Combined image render";
$lang_label["redraw"]="Redraw";
$lang_label["graph_builder_modulelist"]="Graph builder module list";
$lang_label["seconds"]="Seconds";
$lang_name["custom_graph_name"]="Custom graph name";
$lang_label["custom_graph_name"]="Custom graph name";
$lang_label["save"]="Save";
$lang_label["Manage"]="Manage";
$lang_label["group_view_tab"]="Group view";
@ -791,6 +802,7 @@ $lang_label["manage_reporting"]="Manage reports";
$lang_label["report_items"]="Report items";
$lang_label["period"]="Period";
$lang_label["reporting_item_add"]="Add item to report";
$lang_label["order"]="Order";
$lang_label["template"]="Template";
$lang_label["add_mod_ok"]="Modules successfully added ";
@ -803,11 +815,28 @@ $lang_label["alert_report"]="Alert report";
$lang_label["monitor_report"]="Monitor report";
$lang_label["max_value"]="Max. Value";
$lang_label["min_value"]="Min. Value";
$lang_label["sumatory"]="Sumatory";
$lang_label["general_group_report"]="General group report";
$lang_label["monitor_health"]="Monitor health";
$lang_label["monitors_ok"]="Monitors OK";
$lang_label["monitors_bad"]="Monitors BAD";
$lang_label['total_monitors'] = "Total monitors";
$lang_label['monitors_down_on_period'] = "Monitors down on period";
$lang_label['last_failure'] = "Last failure";
$lang_label["agents_detailed"]="Agents detailed view";
$lang_label["reporting_type"]="Reporting type";
$lang_label["sla_max"]="SLA Max. (value)";
$lang_label["sla_min"]="SLA Min. (value)";
$lang_label["sla_limit"]="SLA Limit (%)";
$lang_label["sla_construction"]="SLA report construction";
$lang_label["add_sla_ok"]="SLA was successfully created";
$lang_label["add_sla_no"]="There was a problem creating SLA";
$lang_label["delete_sla_ok"]="SLA was successfully delete";
$lang_label["delete_sla_no"]="There was a problem deleting SLA";
$lang_label["sla_module_is_null"]="Module is not set";
$lang_label["no_defined_slas"]="There are no SLAs defined";
$lang_label["defined_slas"]="SLAs defined";
$lang_label["up"]="Up";
$lang_label["down"]="Down";
$lang_label["map_builder"]="Map builder";
@ -824,6 +853,7 @@ $lang_label["create_reporting_ok"]="Reporting successfully created";
$lang_label["create_reporting_no"]="There was a problem creating reporting";
$lang_label["delete_reporting_ok"]="Reporting successfully deleted";
$lang_label["delete_reporting_no"]="There was a problem deleting reporting";
$lang_label["wrong_module_type"]="Wrong module type";
$lang_label["hour"]="One hour";
$lang_label["2_hours"]="Two hours";

View File

@ -696,7 +696,7 @@ $lang_label["combined_image"]="Résultat de combination dimages";
$lang_label["redraw"]="Redessiner";
$lang_label["graph_builder_modulelist"]="Liste de modules de construction dun tableau";
$lang_label["seconds"]="Secondes";
$lang_name["custom_graph_name"]="Nom de tableau personnalisé";
$lang_label["custom_graph_name"]="Nom de tableau personnalisé";
$lang_label["save"]="Sauvegarder";
$lang_label["Manage"]="Gérer";
$lang_label["group_view_tab"]="Affichage groupe";
@ -846,4 +846,4 @@ $lang_label["setup_agent"]="Agent de configuration";
global $lang_label;
global $help_label;
?>
?>

View File

@ -722,7 +722,7 @@ $lang_label["combined_image"]="Visualización de imáxenes combinadas";
$lang_label["redraw"]="Redibuxar";
$lang_label["graph_builder_modulelist"]="Lista do creador de imáxenes";
$lang_label["seconds"]="Segundos";
$lang_name["custom_graph_name"]="Nombre de gráfica combinada";
$lang_label["custom_graph_name"]="Nombre de gráfica combinada";
$lang_label["save"]="Gravar";
$lang_label["Manage"]="Xestionar";
$lang_label["group_view_tab"]="Vista de grupo";

View File

@ -637,7 +637,7 @@ $lang_label["combined_image"] = "Visualização de imagens combinadas";
$lang_label["redraw"] = "Redesenhar";
$lang_label["graph_builder_modulelist"] = "Lista do construtor de imagens";
$lang_label["seconds"] = "Segundos";
$lang_name["custom_graph_name"] = "Nome do gráfico customizado";
$lang_label["custom_graph_name"] = "Nome do gráfico customizado";
$lang_label["save"] = "Gravar";
$lang_label["Manage"] = "Gerenciar";
$lang_label["group_view_tab"] = "Visão do grupo";
@ -778,4 +778,4 @@ $lang_label["setup_agent"]="Configuração do agent";
global $lang_label;
global $help_label;
?>
?>

View File

@ -0,0 +1,8 @@
/* http://keith-wood.name/timeEntry.html
Catalonian initialisation for the jQuery time entry extension*/
$(document).ready(function() {
$.timeEntry.regional['ca'] = {show24Hours: true, separator: ':',
ampmPrefix: '', ampmNames: ['AM', 'PM'],
spinnerTexts: ['Ahora', 'Campo anterior', 'Siguiente campo', 'Aumentar', 'Disminuir']};
$.timeEntry.setDefaults($.timeEntry.regional['ca']);
});

View File

@ -0,0 +1,9 @@
/* http://keith-wood.name/timeEntry.html
German initialisation for the jQuery time entry extension
Written by Eyk Schulz (eyk.schulz@gmx.net) */
$(document).ready(function() {
$.timeEntry.regional['de'] = {show24Hours: true, separator: ':',
ampmPrefix: '', ampmNames: ['AM', 'PM'],
spinnerTexts: ['Jetzt', 'vorheriges Feld', 'nächstes Feld', 'hoch', 'runter']};
$.timeEntry.setDefaults($.timeEntry.regional['de']);
});

View File

@ -0,0 +1,9 @@
/* http://keith-wood.name/timeEntry.html
Spanish initialisation for the jQuery time entry extension
Written by diegok (diego@freekeylabs.com). */
$(document).ready(function() {
$.timeEntry.regional['es'] = {show24Hours: true, separator: ':',
ampmPrefix: '', ampmNames: ['AM', 'PM'],
spinnerTexts: ['Ahora', 'Campo anterior', 'Siguiente campo', 'Aumentar', 'Disminuir']};
$.timeEntry.setDefaults($.timeEntry.regional['es']);
});

View File

@ -0,0 +1,9 @@
/* http://keith-wood.name/timeEntry.html
French initialisation for the jQuery time entry extension
Written by Keith Wood (kbwood@iprimus.com.au) June 2007. */
$(document).ready(function() {
$.timeEntry.regional['fr'] = {show24Hours: true, separator: ':',
ampmPrefix: '', ampmNames: ['AM', 'PM'],
spinnerTexts: ['Maintenant', 'Précédent', 'Suivant', 'Augmentez', 'Amoindrissez']};
$.timeEntry.setDefaults($.timeEntry.regional['fr']);
});

View File

@ -0,0 +1,9 @@
/* http://keith-wood.name/timeEntry.html
Italian initialisation for the jQuery time entry extension
Written by Apaella (apaella@gmail.com) June 2007. */
$(document).ready(function() {
$.timeEntry.regional['it'] = {show24Hours: true, separator: ':',
ampmPrefix: '', ampmNames: ['AM', 'PM'],
spinnerTexts: ['Adesso', 'Precedente', 'Successivo', 'Aumenta', 'Diminuisci']};
$.timeEntry.setDefaults($.timeEntry.regional['it']);
});

View File

@ -0,0 +1,9 @@
/* http://keith-wood.name/timeEntry.html
Portuguese initialisation for the jQuery time entry extension
Written by Dino Sane (dino@asttra.com.br). */
$(document).ready(function() {
$.timeEntry.regional['pt'] = {show24Hours: true, separator: ':',
ampmPrefix: '', ampmNames: ['AM', 'PM'],
spinnerTexts: ['Agora', 'Campo anterior', 'Campo Seguinte', 'Aumentar', 'Diminuir']};
$.timeEntry.setDefaults($.timeEntry.regional['pt']);
});

View File

@ -111,9 +111,9 @@ a.white_bold {
}
a.white_grey_bold {
color: #999;
text-decoration: none;
font-weight: bold;
color: #999;
text-decoration: none;
font-weight: bold;
}
a.white {
@ -648,41 +648,48 @@ span#logo_text2 {
border-top: 0px;
}
.action-buttons {
text-align: right;
}
#table-add-item select, #table-add-sla select {
width: 180px;
}
td.datos_green, td.datos_greenf9 {
background-color: #C7EAD5;
padding: 5px 5px 5px 5px;
background-color: #C7EAD5;
padding: 5px 5px 5px 5px;
}
td.datos_red, td.datos_redf9 {
background-color: #FFC0B5;
padding: 5px 5px 5px 5px;
background-color: #FFC0B5;
padding: 5px 5px 5px 5px;
}
td.datos_yellow, td.datos_yellowf9 {
background-color: #F4FFBF;
padding: 5px 5px 5px 5px;
background-color: #F4FFBF;
padding: 5px 5px 5px 5px;
}
td.datos_blue, td.datos_bluef9 {
background-color: #CDE2EA;
padding: 5px 5px 5px 5px;
background-color: #CDE2EA;
padding: 5px 5px 5px 5px;
}
td.datos_grey, td.datos_greyf9 {
background-color: #DCDCDC;
padding: 5px 5px 5px 5px;
background-color: #DCDCDC;
padding: 5px 5px 5px 5px;
}
td.datos_greyf9, td.datos_bluef9, td.datos_greenf9, td.datos_redf9, td.datos_yellowf9 {
font-size: 6.5pt;
font-size: 6.5pt;
}
div#main_pure {
background-color: #fefefe;
text-align: left;
margin-bottom: 25px;
margin-top: 10px;
margin-left: 10px;
margin-right: 10px;
background-color: #fefefe;
text-align: left;
margin-bottom: 25px;
margin-top: 10px;
margin-left: 10px;
margin-right: 10px;
}

View File

@ -18,6 +18,29 @@
// Load global vars
require("include/config.php");
if (defined ('AJAX')) {
$get_agent_json = (bool) get_parameter ('get_agent_json');
$get_agent_modules_json = (bool) get_parameter ('get_agent_modules_json');
if ($get_agent_json) {
$id_agent = (int) get_parameter ('id_agent');
$agent = get_db_row ('tagente', 'id_agente', $id_agent);
echo json_encode ($agent);
exit ();
}
if ($get_agent_modules_json) {
$id_agent = (int) get_parameter ('id_agent');
$agent_modules = get_db_all_rows_field_filter ('tagente_modulo', 'id_agente', $id_agent);
echo json_encode ($agent_modules);
exit ();
}
exit ();
}
if (comprueba_login() == 0) {
$id_agente = get_parameter("id_agente",-1);
if ($id_agente != -1){

View File

@ -1,4 +1,4 @@
<?PHP
<?php
// Pandora FMS - the Free monitoring system
// ========================================

View File

@ -59,12 +59,13 @@ if (isset($_GET["view_graph"])){
$private = $row["private"];
$width = $row["width"];
$height = $row["height"];
$period = $row["period"];
if (isset($_POST["period"]))
$period = $_POST["period"];
$period = (int) get_parameter ('period');
if (! $period)
$period = $row["period"];
else
$period = 3600 * $period;
$events = $row["events"];
$description = $row["description"];
$stacked = $row["stacked"];
$name = $row["name"];
if (($row["private"]==1) && ($row["id_user"] != $id_user)){
audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access to a custom graph not allowed");
@ -89,57 +90,26 @@ if (isset($_GET["view_graph"])){
echo $lang_label["combined_image"]."</h2>";
echo "<table class='databox_frame'>";
echo "<tr><td>";
echo "<img src='reporting/fgraph.php?tipo=combined&height=$height&width=$width&id=$modules&period=$period&stacked=$stacked&weight_l=$weights' border=1 alt=''>";
echo "<img src='reporting/fgraph.php?tipo=combined&height=$height&width=$width&id=$modules&period=$period&weight_l=$weights' border=1 alt=''>";
echo "</td></tr></table>";
switch ($period) {
case 3600: $period_label = $lang_label["hour"];
break;
case 7200: $period_label = $lang_label["2_hours"];
break;
case 21600: $period_label = $lang_label["6_hours"];
break;
case 43200: $period_label = $lang_label["12_Hours"];
break;
case 86400: $period_label = $lang_label["last_day"];
break;
case 172800: $period_label = $lang_label["two_days"];
break;
case 432000: $period_label = $lang_label["five_days"];
break;
case 604800: $period_label = $lang_label["last_week"];
break;
case 1296000: $period_label = $lang_label["15_days"];
break;
case 2592000: $period_label = $lang_label["last_month"];
break;
case 5184000: $period_label = $lang_label["two_month"];
break;
case 15552000: $period_label = $lang_label["six_months"];
break;
default: $period_label = "--";
}
$period_label = human_time_description ($period);
echo "<form method='POST' action='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=$id_graph'>";
echo "<table class='databox_frame'>";
echo "<tr><td class='datos'>";
echo "<b>Period</b>";
echo "<b>".lang_string ('period')."</b>";
echo "<td class='datos'>";
echo "<select name='period'>";
if ($period==0)
echo "<option value=86400>".$period_label;
else
echo "<option value=$period>".$period_label;
echo "<option value=3600>"."Hour";
echo "<option value=21600>"."6 Hours";
echo "<option value=43200>"."12 Hours";
echo "<option value=86400>"."Last day";
echo "<option value=172800>"."Two days";
echo "<option value=604800>"."Last Week";
echo "<option value=1296000>"."15 days";
echo "<option value=2592000>"."Last Month";
echo "<option value=5184000>"."Two Month";
echo "<option value=15552000>"."Six Months";
echo "</select>";
$periods = array ();
$periods[1] = lang_string ('hour');
$periods[2] = '2 '.lang_string ('hours');
$periods[3] = '3 '.lang_string ('hours');
$periods[6] = '6 '.lang_string ('hours');
$periods[12] = '12 '.lang_string ('hours');
$periods[24] = lang_string ('last_day');
$periods[48] = lang_string ('two_days');
$periods[360] = lang_string ('last_week');
$periods[720] = lang_string ('last_month');
$periods[4320] = lang_string ('six_months');
print_select ($periods, 'period', intval ($period / 3600), '', '', 0);
echo "<td class='datos'>";
echo "<input type=submit value='".$lang_label["update"]."' class='sub upd'>";
echo "</table>";

View File

@ -18,221 +18,362 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Login check
$id_user=$_SESSION["id_usuario"];
global $REMOTE_ADDR;
if (comprueba_login() != 0) {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access graph builder");
audit_db ($id_user, $REMOTE_ADDR, "ACL Violation","Trying to access graph builder");
include ("general/noaccess.php");
exit;
}
if ((give_acl($id_user,0,"AR") != 1 ) AND (dame_admin($id_user)!=1)) {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access graph builder");
$id_report = (int) get_parameter ('id');
if (! $id_report) {
audit_db ($id_user, $REMOTE_ADDR, "HACK Attempt","Trying to access graph viewer withoud ID");
include ("general/noaccess.php");
exit;
}
$report = get_db_row ('treport', 'id_report', $id_report);
$id_report = give_parameter_get ( 'id', $default = "");
if ($id_report == ""){
audit_db($id_user,$REMOTE_ADDR, "HACK Attempt","Trying to access graph viewer withoud ID");
if (! give_acl ($id_user, $report['id_group'], "AR") AND ! dame_admin ($id_user)) {
audit_db ($id_user, $REMOTE_ADDR, "ACL Violation","Trying to access graph builder");
include ("general/noaccess.php");
exit;
}
require ("include/functions_reporting.php");
$report_name = give_db_value ("name", "treport", "id_report", $id_report);
$report_description = give_db_value ("description", "treport", "id_report", $id_report);
$report_private= give_db_value ("private", "treport", "id_report", $id_report);
$report_user = give_db_value ("id_user", "treport", "id_report", $id_report);
if (($report_user == $id_user) OR (dame_admin($id_user)==1) OR ($report_private == 0)) {
echo "<h2>".$lang_label["reporting"]." &gt; ";
echo $lang_label["custom_reporting"]." - ";
echo $report_name."</h2>";
echo "<table class='databox' cellpadding= 4 cellspacing=4 width=750>";
echo "<tr>";
echo "<td width=50 align='left'><img src='images/reporting.png' width=32 height=32>";
echo "<td>".$report_description."</td>";
echo "</table>";
echo "<table width=750 cellpadding=4 cellspacing=4 class='databox'>";
$sql = "SELECT * FROM treport_content WHERE id_report = $id_report ORDER by type, id_agent_module DESC";
$res=mysql_query($sql);
while ($row = mysql_fetch_array($res)){
$type = $row["type"];
$sla_max = $row["sla_max"];
$sla_min = $row["sla_min"];
$sla_limit = $row["sla_limit"];
$id_agent_module = $row["id_agent_module"];
$period = $row["period"];
$id_gs = $row["id_gs"];
unset ($modules);
unset ($weights);
$module_name = get_db_sql ("SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = ". $id_agent_module);
$agent_name = dame_nombre_agente_agentemodulo ($id_agent_module);
switch($type){
case 2: // SLA
$sla_result = format_numeric(return_module_SLA ($id_agent_module, $period, $sla_min, $sla_max), 2);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["SLA"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=2 class=datos>";
echo "<font size='0.6em'>";
echo $lang_label["sla_max"]. " : ".$sla_max. "<br>";
echo $lang_label["sla_min"]. " : ".$sla_min. "<br>";
echo $lang_label["sla_limit"]. " : ".$sla_limit. "<br>";
echo "</font>";
echo "<td class=datos valign='middle' align='right' >";
if ($sla_result >= $sla_limit)
echo "<p style='font: bold 3em Arial, Sans-serif; color: #000000;'>";
else
echo "<p style='font: bold 3em Arial, Sans-serif; color: #ff0000;'>";
echo $sla_result. " %";
echo "</p>";
echo "</td></tr>";
break;
case 0: // Simple graph
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["simple_graph"]."</h4>";
echo "<td class='datos3'>";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' valign='top'>";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr><td colspan=3 class='datos' valign='top'>";
echo "<img src='reporting/fgraph.php?tipo=sparse&id=$id_agent_module&height=230&width=720&period=$period&avg_only=1&pure=1' border=0 alt=''>";
echo "</tr>";
break;
case 1: // Custom/Combined graph
$graph = get_db_row ("tgraph", "id_graph", $id_gs);
$sql2="SELECT * FROM tgraph_source WHERE id_graph = $id_gs";
$res2=mysql_query($sql2);
while ( $row2 = mysql_fetch_array($res2)){
$weight = $row2["weight"];
$id_agent_module = $row2["id_agent_module"];
if (!isset($modules)){
$modules = $id_agent_module;
$weights = $weight;
} else {
$modules = $modules.",".$id_agent_module;
$weights = $weights.",".$weight;
}
}
echo "<tr><td class=datos3 >";
echo "<h4>".$lang_label["custom_graph"]."</h4>";
echo "<td class=datos3>";
echo "<h4>".$graph["name"]."</h4>";
$stacked = $graph["stacked"];
echo "<td class=datos3>";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr><td colspan=3 class=datos valign='top' align='right'>";
echo "<img src='reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&height=230&width=720&period=$period&stacked=$stacked&pure=1' border=1 alt=''>";
echo "</tr>";
break;
case 6: // AVG value
$avg_value = format_for_graph(return_moduledata_avg_value ($id_agent_module, $period),2);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["avg_value"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=2 class=datos>";
echo "<td class=datos valign='middle' align='right' >";
echo "<p style='font: bold 3em Arial, Sans-serif; color: #000000;'>";
echo $avg_value;
echo "</p>";
echo "</td></tr>";
break;
case 7: // MAX value
$max_value = format_for_graph(return_moduledata_max_value ($id_agent_module, $period),2);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["max_value"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=2 class=datos>";
echo "<td class=datos valign='middle' align='right' >";
echo "<p style='font: bold 3em Arial, Sans-serif; color: #000000;'>";
echo $max_value;
echo "</p>";
echo "</td></tr>";
break;
case 8: // MIN value
$min_value = format_for_graph(return_moduledata_min_value ($id_agent_module, $period),2);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["min_value"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=2 class=datos>";
echo "<td class=datos valign='middle' align='right' >";
echo "<p style='font: bold 3em Arial, Sans-serif; color: #000000;'>";
echo $min_value;
echo "</p>";
echo "</td></tr>";
break;
case 5: // Monitor report
$monitor_value = $sla_result = format_numeric(return_module_SLA ($id_agent_module, $period, 1, 1), 2);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["monitor_report"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=2 class=datos>";
echo "<td class=datos valign='middle' align='right' >";
echo "<p style='font: bold 3em Arial, Sans-serif; color: #000000;'>";
echo $monitor_value." %"."<img src='images/b_green.png' height=32 width=32>";
echo "</p>";
$monitor_value2 = format_numeric(100 - $monitor_value,2) ;
echo "<p style='font: bold 3em Arial, Sans-serif; color: #ff0000;'>";
echo $monitor_value2." %"."<img src='images/b_red.png' height=32 width=32>";
echo "</p>";
echo "</td></tr>";
break;
case 3: // Event report
$id_agent = dame_agente_id ($agent_name);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["event_report"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=3 class=datos>";
event_reporting ($id_agent, $period);
echo "</td></tr>";
break;
case 4: // Alert report
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["alert_report"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=3 class=datos>";
alert_reporting ($id_agent_module);
echo "</td></tr>";
break;
}
}
echo "</table>";
/* Check if the user can see the graph */
/* FIXME: It will check AR permissions against agent or group of the report */
if ($report['id_user'] != $id_user && ! dame_admin ($id_user) && ! $report['private']) {
return;
}
$date = (string) get_parameter ('date', date ('Y-m-j'));
$time = (string) get_parameter ('time', date ('h:iA'));
echo "<h2>".lang_string ('reporting')." &gt; ";
echo lang_string ('custom_reporting')." - ";
echo $report['name']."</h2>";
$table->width = '750px';
$table->class = 'databox';
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->size = array ();
$table->size[0] = '50px';
$table->data = array ();
$table->data[0][0] = '<img src="images/reporting.png" width="32" height="32">';
if ($report['description'] != '')
$table->data[0][1] = $report['description'];
else
$table->data[0][1] = $report['name'];
$table->data[1][0] = lang_string ('date');
$table->data[1][1] = print_input_text ('date', $date, '', 10, 10, true). ' ';
$table->data[1][1] .= print_input_text ('time', $time, '', 7, 7, true). ' ';
$table->data[1][1] .= print_submit_button (lang_string ('update'), 'date_submit', false, 'class="sub next"', true);
echo '<form method="post" action="">';
print_table ($table);
print_input_hidden ('id_report', $id_report);
echo '</form>';
/* We must add javascript here. Otherwise, the date picker won't
work if the date is not correct because php is returning. */
?>
<link rel="stylesheet" href="include/styles/datepicker.css" type="text/css" media="screen">
<link rel="stylesheet" href="include/styles/timeentry.css" type="text/css" media="screen">
<script type="text/javascript" src="include/javascript/jquery.js"></script>
<script src="include/javascript/jquery.ui.datepicker.js"></script>
<script src="include/languages/date_<?= $config['language'] ?>.js"></script>
<script src="include/languages/time_<?= $config['language'] ?>.js"></script>
<script src="include/javascript/jquery.timeentry.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready (function () {
$("#text-time").timeEntry ({spinnerImage: 'images/time-entry.png', spinnerSize: [20, 20, 0]});
$("#text-date").datepicker ();
$.datepicker.regional["<?= $config['language'] ?>"];
});
</script>
<?php
$datetime = strtotime ($date.' '.$time);
if ($datetime === false || $datetime == -1) {
echo '<h3 class="error">'.lang_string ('invalid_date').'</h3>';
return;
}
/* Date must not be older than now */
if ($datetime > time ()) {
echo '<h3 class="error">'.lang_string ('date_older_than_now').'</h3>';
return;
}
$table->data = array ();
$table->size = array ();
$table->style = array ();
$table->width = '750px';
$table->class = 'databox';
$table->rowclasses = array ();
$group_name = dame_grupo ($report['id_group']);
$sql = sprintf ('SELECT * FROM treport_content WHERE id_report = %d ORDER BY `order`', $id_report);
$contents = get_db_all_rows_sqlfree ($sql);
foreach ($contents as $content) {
unset ($modules);
unset ($weights);
$module_name = get_db_value ('nombre', 'tagente_modulo', 'id_agente_modulo', $content['id_agent_module']);
$agent_name = dame_nombre_agente_agentemodulo ($content['id_agent_module']);
switch ($content["type"]) {
case 1:
case 'simple_graph':
$table->colspan[1][0] = 3;
$data = array ();
$data[0] = '<h4>'.lang_string ('simple_graph').'</h4>';
$data[1] = '<h4>'.$agent_name.' - '.$module_name.'</h4>';
$data[2] = '<h4>'.human_time_description($content['period']).'</h4>';
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
// $n is the number of elements in the array, so it will be the index of the next element
$table->colspan[$n][0] = 3;
$data = array ();
$data[0] = '<img src="reporting/fgraph.php?tipo=sparse&id='.$content['id_agent_module'].'&height=230&width=720&period='.$content['period'].'&date='.$datetime.'&avg_only=1&pure=1" border="0" alt="">';
array_push ($table->data, $data);
break;
case 2:
case 'custom_graph':
$graph = get_db_row ("tgraph", "id_graph", $content['id_gs']);
$sql2 = sprintf ('SELECT * FROM tgraph_source WHERE id_graph = %d', $content['id_gs']);
$res2 = mysql_query($sql2);
while ($content2 = mysql_fetch_array($res2)) {
$weight = $content2["weight"];
$content['id_agent_module'] = $content2["id_agent_module"];
if (!isset($modules)){
$modules = $content['id_agent_module'];
$weights = $weight;
} else {
$modules = $modules.",".$content['id_agent_module'];
$weights = $weights.",".$weight;
}
}
$data = array ();
$data[0] = '<h4>'.lang_string ('custom_graph').'</h4>';
$data[1] = "<h4>".$graph["name"]."</h4>";
$data[2] = "<h4>".human_time_description($content['period'])."</h4>";
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$table->colspan[$n][0] = 3;
$data = array ();
$data[0] = '<img src="reporting/fgraph.php?tipo=combined&id='.$modules.'&weight_l='.$weights.'&height=230&width=720&period='.$content['period'].'&date='.$datetime.'&stacked='.$graph["stacked"].'&pure=1" border="1" alt="">';
array_push ($table->data, $data);
break;
case 3:
case 'SLA':
$data = array ();
$data[0] = '<h4>'.lang_string ('SLA').'</h4>';
$data[1] = '<h4>'.$group_name.'</h4>';
$data[2] = '<h4>'.human_time_description ($content['period']).'</h4>';
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$slas = get_db_all_rows_field_filter ('treport_content_sla_combined', 'id_report_content', $content['id_rc']);
if (sizeof ($slas) == 0) {
$data = array ();
$table->colspan[$n][0] = 3;
$data[0] = lang_string ('no_defined_slas');
array_push ($table->data, $data);
}
foreach ($slas as $sla) {
$data = array ();
$sla_result = format_numeric (return_module_SLA ($sla['id_agent_module'], $content['period'],
$sla['sla_min'], $sla['sla_max'], $datetime));
$table->colspan[$n][0] = 2;
$table->data[0] = '<span style="font-size: 0.6em">';
$table->data[0] .= lang_string ('sla_max')." : ".$sla['sla_max']."<br>";
$table->data[0] .= lang_string ('sla_min')." : ".$sla['sla_min']."<br>";
$table->data[0] .= lang_string ('sla_limit')." : ".$sla['sla_limit']."<br>";
$table->data[0] .= "</span>";
if ($sla_result >= $sla['sla_limit'])
$table->data[1] = "<span style='font: bold 3em Arial, Sans-serif; color: #000000;'>";
else
$table->data[1] = "<span style='font: bold 3em Arial, Sans-serif; color: #ff0000;'>";
$table->data[1] .= $sla_result. " %";
$table->data[1] .= "</span>";
$n = array_push ($table->data, $data);
}
break;
case 4:
case 'event_report':
$id_agent = dame_agente_id ($agent_name);
$data = array ();
$data[0] = "<h4>".lang_string ('event_report')."</h4>";
$data[1] = "<h4>$agent_name - $module_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$table->colspan[$n][0] = 3;
$data = array ();
$data[0] = event_reporting ($id_agent, $content['period'], $datetime, true);
array_push ($table->data, $data);
break;
case 5:
case 'alert_report':
$data = array ();
$data[0] = "<h4>".lang_string ('alert_report')."</h4>";
$data[1] = "<h4>$group_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array ();
$table->colspan[$n][0] = 3;
$data[0] = alert_reporting ($report['id_group'], $content['period'], $datetime, true);
array_push ($table->data, $data);
break;
case 6:
case 'monitor_report':
$data = array ();
$data[0] = "<h4>".lang_string ('monitor_report')."</h4>";
$data[1] = "<h4>$agent_name - $module_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array ();
$monitor_value = $sla_result = format_numeric (return_module_SLA ($content['id_agent_module'], $content['period'], 1, 1, $datetime));
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">';
$data[0] .= $monitor_value.' % <img src="images/b_green.png" height="32" width="32"></p>';
$monitor_value2 = format_numeric (100 - $monitor_value, 2) ;
$data[1] = "<p style='font: bold 3em Arial, Sans-serif; color: #ff0000;'>";
$data[1] .= $monitor_value2.' % <img src="images/b_red.png" height="32" width="32"></p>';
array_push ($table->data, $data);
break;
case 7:
case 'avg_value':
$data = array ();
$data[0] = "<h4>".lang_string ('avg_value')."</h4>";
$data[1] = "<h4>$agent_name - $module_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array ();
$table->colspan[$n][0] = 2;
$value = format_for_graph (return_moduledata_avg_value ($content['id_agent_module'], $content['period'], $datetime));
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
array_push ($table->data, $data);
break;
case 8:
case 'max_value':
$data = array ();
$data[0] = "<h4>".lang_string ('max_value')."</h4>";
$data[1] = "<h4>$agent_name - $module_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array ();
$table->colspan[$n][0] = 2;
$value = format_for_graph (return_moduledata_max_value ($content['id_agent_module'], $content['period'], $datetime));
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
array_push ($table->data, $data);
break;
case 9:
case 'min_value':
$data = array ();
$data[0] = "<h4>".lang_string ('min_value')."</h4>";
$data[1] = "<h4>$agent_name - $module_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array ();
$table->colspan[$n][0] = 2;
$value = format_for_graph (return_moduledata_min_value ($content['id_agent_module'], $content['period'], $datetime));
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
array_push ($table->data, $data);
break;
case 10:
case 'sumatory':
$data = array ();
$data[0] = "<h4>".lang_string ('sumatory')."</h4>";
$data[1] = "<h4>$agent_name - $module_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array ();
$table->colspan[$n][0] = 2;
$value = format_for_graph (return_moduledata_sum_value ($content['id_agent_module'], $content['period'], $datetime));
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
array_push ($table->data, $data);
break;
case 11:
case 'general_group_report':
$data = array ();
$data[0] = "<h4>".lang_string ('group')."</h4>";
$data[1] = "<h4>$group_name</h4>";
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array ();
$table->colspan[$n][0] = 2;
$value = format_for_graph (return_moduledata_sum_value ($content['id_agent_module'], $content['period'], $datetime));
$data[0] = general_group_reporting ($report['id_group'], true);
array_push ($table->data, $data);
break;
case 12:
case 'monitor_health':
$data = array ();
$data[0] = "<h4>".lang_string ('monitor_health')."</h4>";
$data[1] = "<h4>$group_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array ();
$table->colspan[$n][0] = 3;
$data[0] = monitor_health_reporting ($report['id_group'], $content['period'], $datetime, true);
array_push ($table->data, $data);
break;
case 13:
case 'agents_detailed':
$data = array ();
$data[0] = "<h4>".lang_string ('agents_detailed')."</h4>";
$data[1] = "<h4>$group_name</h4>";
$data[2] = "";
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array ();
$table->colspan[$n][0] = 3;
$data[0] = agents_detailed_reporting ($report['id_group'], $content['period'], $datetime, true);
array_push ($table->data, $data);
break;
}
}
print_table ($table);
?>

View File

@ -595,40 +595,39 @@ CREATE TABLE `treport` (
`name` varchar(150) NOT NULL default '',
`description` TEXT NOT NULL,
`private` tinyint(1) UNSIGNED NOT NULL default 0,
PRIMARY KEY(`id_report`)
`id_group` mediumint(8) unsigned NULL default NULL,
PRIMARY KEY(`id_report`),
FOREIGN KEY (`id_group`) REFERENCES tgrupo(`id_grupo`)
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `treport_content` (
`id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`id_report` INTEGER UNSIGNED NOT NULL default 0,
`id_gs` INTEGER UNSIGNED NOT NULL default 0,
`id_agent_module` int(11) NOT NULL default 0,
`type` tinyint(1) UNSIGNED NOT NULL default 0,
`id_gs` INTEGER UNSIGNED NULL default NULL,
`id_agent_module` bigint(14) unsigned NULL default NULL,
`type` enum ('simple_graph', 'custom_graph', 'SLA', 'event_report', 'alert_report', 'monitor_report', 'avg_value', 'max_value', 'min_value', 'sumatory', 'general_group_report', 'monitor_health', 'agents_detailed') default 'simple_graph',
`period` int(11) NOT NULL default 0,
`order` int (11) NOT NULL default 0,
PRIMARY KEY(`id_rc`),
FOREIGN KEY (`id_agent`) REFERENCES tagente(`id_agente`)
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `treport_content_sla_combined` (
`id` INTEGER UNSIGNED NOT NULL auto_increment,
`id_report_content` INTEGER UNSIGNED NOT NULL,
`id_agent_module` bigint(14) unsigned NOT NULL,
`sla_max` int(11) NOT NULL default 0,
`sla_min` int(11) NOT NULL default 0,
`sla_limit` int(11) NOT NULL default 0,
PRIMARY KEY(`id_rc`)
PRIMARY KEY(`id`),
FOREIGN KEY (`id_report_content`) REFERENCES treport_content(`id_rc`)
ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (`id_agent_module`) REFERENCES tagente_modulo(`id_agente_modulo`)
ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET=utf8;
/*
treport_content descripcion
type valid values
0 - Simple graph
1 - User/Combined graph
2 - SLA
3 - Event report
4 - Alert report
5 - Monitor report
6 - Avg. value
7 - Max. value
8 - Min. value
id_gs is for combined graph pprimary key id
*/
CREATE TABLE `tlayout` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,

View File

@ -782,8 +782,8 @@ function graphic_agentaccess ($id_agent, $periodo, $width, $height) {
// $intervalo now stores "ideal" interval }
// interval is the number of rows that will store data. more rows, more resolution
// Para crear las graficas vamos a crear un array de Ax4 elementos, donde
// A es el numero de posiciones diferentes en la grafica (30 para un mes, 7 para una semana, etc)
// Para crear las graficas vamos a crear un array de Ix4 elementos, donde
// I es el numero de posiciones diferentes en la grafica (30 para un mes, 7 para una semana, etc)
// y los 4 valores en el ejeY serian los detallados a continuacion:
// Rellenamos la tabla con un solo select, y los calculos se hacen todos sobre memoria
// esto acelera el tiempo de calculo al maximo, aunque complica el algoritmo :-)
@ -2061,13 +2061,22 @@ if ($graphic_type) {
break;
case "alerts_fired_pipe":
$data = array ();
$data[0] = get_parameter ('fired');
$data[1] = get_parameter ('not_fired');
$data[0] = (float) get_parameter ('fired');
$data[1] = (float) get_parameter ('not_fired');
$legends = array ();
$legends[0] = lang_string ('fired_alerts');
$legends[1] = lang_string ('not_fired_alerts');
generic_pie_graph ($width, $height, $data, $legends);
break;
case 'monitors_health_pipe':
$data = array ();
$data[0] = (float) get_parameter ('down');
$data[1] = (float) get_parameter ('not_down');
$legends = array ();
$legends[0] = lang_string ('monitors_ok');
$legends[1] = lang_string ('monitors_bad');
generic_pie_graph ($width, $height, $data, $legends);
break;
default:
graphic_error ();
}