2008-07-02 Esteban Sanchez <estebans@artica.es>

* general/logon_ok.php: Style correction.

	* include/languages/language_en.php: Added a couple of strings.
	
	* include/styles/pandora.css: Container div has now variable width, so
	Pandora console is wider now.

	* include/config.php: Replaced default values from last commit. Change
	homeurl variable, which now points to base url directory.

	* include/config_process.php: Style correction. Use pandora functions
	and indent the code properly.

	* reporting/fgraph.php, include/functions.php, ajax.php: Use
	require_once instead of require which speeds up the code parsing.
	
	* index.php: Use require_once instead of require which speeds up the
	code parsing. Add all GET and POST variables when refreshing a page.
	Style corrections. Use $_SERVER instead getenv.

	* include/functions_db.php: Avoid including config.php and use global
	instead. Replaced some id_user with the respective variable holds in
	config array. Replaced SQL syntax, removed an undeclared variable and
	renamed to english in event_insert(). Renamed
	return_moduledata_*_value() to get_agent_module_value_*(). Fixed an
	error in the sumatory when the module is incremental.

	* include/functions_reporting.php: Renamed return_module_SLA() to
	get_agent_module_sla().

	* include/functions_reporting_pdf.php: Tabs and blankspaces
	correction. Style correction. Added new reports rendering, and fixed
	images references. Removed old and deprecated functions.

	* operation/agentes/networkmap.php: Style correction.

	* operation/agentes/sla_view.php, reporting/stat_win.php: Use renamed
	functions.

	* operation/reporting/reporting_viewer.php: Table reports width are
	now wider. Fixed some colspan problems. Generate custom graph ids
	better. Added agent and module name to SLAs. Style correction in the
	use of rowclass structure since now each content has its own table.

	* operation/reporting/custom_reporting.php: Removed unused variable
	for PDF reporting generation link.

	* operation/reporting/reporting_viewer_pdf.php: Rewrite the code to
	make style corrections and use pandora functions.

	* operation/menu.php: Tabs and blankspaces correction.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@916 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Esteban Sanchez 2008-07-02 12:30:56 +00:00
parent 5da9c1aa90
commit bcd04b2130
20 changed files with 1059 additions and 927 deletions

View File

@ -1,3 +1,57 @@
2008-07-02 Esteban Sanchez <estebans@artica.es>
* general/logon_ok.php: Style correction.
* include/languages/language_en.php: Added a couple of strings.
* include/styles/pandora.css: Container div has now variable width, so
Pandora console is wider now.
* include/config.php: Replaced default values from last commit. Change
homeurl variable, which now points to base url directory.
* include/config_process.php: Style correction. Use pandora functions
and indent the code properly.
* reporting/fgraph.php, include/functions.php, ajax.php: Use
require_once instead of require which speeds up the code parsing.
* index.php: Use require_once instead of require which speeds up the
code parsing. Add all GET and POST variables when refreshing a page.
Style corrections. Use $_SERVER instead getenv.
* include/functions_db.php: Avoid including config.php and use global
instead. Replaced some id_user with the respective variable holds in
config array. Replaced SQL syntax, removed an undeclared variable and
renamed to english in event_insert(). Renamed
return_moduledata_*_value() to get_agent_module_value_*(). Fixed an
error in the sumatory when the module is incremental.
* include/functions_reporting.php: Renamed return_module_SLA() to
get_agent_module_sla().
* include/functions_reporting_pdf.php: Tabs and blankspaces
correction. Style correction. Added new reports rendering, and fixed
images references. Removed old and deprecated functions.
* operation/agentes/networkmap.php: Style correction.
* operation/agentes/sla_view.php, reporting/stat_win.php: Use renamed
functions.
* operation/reporting/reporting_viewer.php: Table reports width are
now wider. Fixed some colspan problems. Generate custom graph ids
better. Added agent and module name to SLAs. Style correction in the
use of rowclass structure since now each content has its own table.
* operation/reporting/custom_reporting.php: Removed unused variable
for PDF reporting generation link.
* operation/reporting/reporting_viewer_pdf.php: Rewrite the code to
make style corrections and use pandora functions.
* operation/menu.php: Tabs and blankspaces correction.
2008-07-01 Sancho Lerena <slerena@gmail.com> 2008-07-01 Sancho Lerena <slerena@gmail.com>
* include/config_process.php: Default back to 1 week. * include/config_process.php: Default back to 1 week.

View File

@ -22,10 +22,10 @@
if ((! file_exists("include/config.php")) || (! is_readable("include/config.php"))) { if ((! file_exists("include/config.php")) || (! is_readable("include/config.php"))) {
exit; exit;
} }
require ('include/config.php'); require_once ('include/config.php');
// Check for correct language file presence // Check for correct language file presence
if (file_exists ('include/languages/language_'.$config['language'].'.php')) { if (file_exists ('include/languages/language_'.$config['language'].'.php')) {
@ -34,8 +34,8 @@ if (file_exists ('include/languages/language_'.$config['language'].'.php')) {
include "include/languages/language_en.php"; include "include/languages/language_en.php";
} }
require ('include/functions.php'); require_once ('include/functions.php');
require ('include/functions_db.php'); require_once ('include/functions_db.php');
// Real start // Real start
session_start(); session_start();
@ -51,7 +51,7 @@ $config["id_user"] = $_SESSION["id_usuario"];
session_write_close (); session_write_close ();
if (file_exists ($page)) { if (file_exists ($page)) {
$id_user = $_SESSION["id_usuario"]; $id_user = $_SESSION["id_usuario"];
require ($page); require_once ($page);
} else { } else {
echo "<br><b class='error'>Sorry! I can't find the page $page!</b>"; echo "<br><b class='error'>Sorry! I can't find the page $page!</b>";
} }

View File

@ -17,7 +17,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require("include/functions_reporting.php"); require ("include/functions_reporting.php");
echo "<div class='jus'>"; echo "<div class='jus'>";
$nick = $_SESSION['id_usuario']; $nick = $_SESSION['id_usuario'];

View File

@ -2,10 +2,10 @@
// Begin of automatic config file // Begin of automatic config file
$config["dbname"]="pandora"; // MySQL DataBase name $config["dbname"]="pandora"; // MySQL DataBase name
$config["dbuser"]="pandora"; // DB User $config["dbuser"]="pandora"; // DB User
$config["dbpass"]="dstxhvec"; // DB Password $config["dbpass"]="pandora"; // DB Password
$config["dbhost"]="localhost"; // DB Host $config["dbhost"]="localhost"; // DB Host
$config["homedir"]="/var/www/pandora/"; // Config homedir $config["homedir"]="/var/www/pandora_console/"; // Config homedir
$config["homeurl"]="http://192.168.50.1/pandora"; // Base URL $config["homeurl"]="/pandora_console"; // Base URL (all in URL after http://example.com)
// End of automatic config file // End of automatic config file
?><?php ?><?php

View File

@ -18,15 +18,15 @@
//Pandora Version //Pandora Version
if (!isset($build_version)) if (!isset($build_version))
$build_version="PC080610"; $build_version = "PC080610";
if (!isset($pandora_version)) if (!isset($pandora_version))
$pandora_version="v2.0-dev"; $pandora_version = "v2.0-dev";
// This is directory where placed "/attachment" directory, to upload files stores. // This is directory where placed "/attachment" directory, to upload files stores.
// This MUST be writtable by http server user, and should be in pandora root. // This MUST be writtable by http server user, and should be in pandora root.
// By default, Pandora adds /attachment to this, so by default is the pandora console home dir // By default, Pandora adds /attachment to this, so by default is the pandora console home dir
$config["attachment_store"]=$config["homedir"]."attachment"; $config["attachment_store"] = $config["homedir"]."attachment";
// Default font used for graphics (a Free TrueType font included with Pandora FMS) // Default font used for graphics (a Free TrueType font included with Pandora FMS)
$config["fontpath"] = $config["homedir"]."/reporting/FreeSans.ttf"; $config["fontpath"] = $config["homedir"]."/reporting/FreeSans.ttf";
@ -40,85 +40,113 @@ $config["sla_period"] = 604800;
// Read remaining config tokens from DB // Read remaining config tokens from DB
if (! mysql_connect($config["dbhost"],$config["dbuser"],$config["dbpass"])){ if (! mysql_connect($config["dbhost"],$config["dbuser"],$config["dbpass"])){
//Non-persistent connection. If you want persistent conn change it to mysql_pconnect() //Non-persistent connection. If you want persistent conn change it to mysql_pconnect()
exit ('<html><head><title>Pandora FMS Error</title> exit ('<html><head><title>Pandora FMS Error</title>
<link rel="stylesheet" href="./include/styles/pandora.css" type="text/css"> <link rel="stylesheet" href="./include/styles/pandora.css" type="text/css">
</head><body><div align="center"> </head><body><div align="center">
<div id="db_f"> <div id="db_f">
<div> <div>
<a href="index.php"><img src="images/pandora_logo.png" border="0"></a> <a href="index.php"><img src="images/pandora_logo.png" border="0"></a>
</div> </div>
<div id="db_ftxt"> <div id="db_ftxt">
<h1 id="log_f" class="error">Pandora Console Error DB-001</h1> <h1 id="log_f" class="error">Pandora Console Error DB-001</h1>
Cannot connect with Database, please check your database setup in the Cannot connect with Database, please check your database setup in the
<b>./include/config.php</b> file and read documentation.<i><br><br> <b>./include/config.php</b> file and read documentation.<i><br><br>
Probably any of your user/database/hostname values are incorrect or Probably any of your user/database/hostname values are incorrect or
database is not running.</i><br><br><font class="error"> database is not running.</i><br><br><font class="error">
<b>MySQL ERROR:</b> '. mysql_error().'</font> <b>MySQL ERROR:</b> '. mysql_error().'</font>
<br>&nbsp; <br>&nbsp;
</div> </div>
</div></body></html>'); </div></body></html>');
} }
mysql_select_db($config["dbname"]);
if($result2=mysql_query("SELECT * FROM tconfig")){
while ($row2=mysql_fetch_array($result2)){
switch ($row2["token"]) {
case "language_code": $config["language"]=$row2["value"];
break;
case "block_size": $config["block_size"]=$row2["value"];
break;
case "days_purge": $config["days_purge"]=$row2["value"];
break;
case "days_compact": $config["days_compact"]=$row2["value"];
break;
case "graph_res": $config["graph_res"]=$row2["value"];
break;
case "step_compact": $config["step_compact"]=$row2["value"];
break;
case "style": $config["style"]=$row2["value"];
break;
case "show_unknown": $config["show_unknown"] = $row2["value"];
break;
case "show_lastalerts": $config["show_lastalerts"] = $row2["value"];
break;
case "remote_config": $config["remote_config"] = $row2["value"];
break;
case "sla_period": $config["sla_period"] = $row2["value"];
break;
case "graph_color1":
$config["graph_color1"] = $row2["value"];
break;
case "graph_color2":
$config["graph_color2"] = $row2["value"];
break;
case "graph_color3":
$config["graph_color3"] = $row2["value"];
break;
} mysql_select_db ($config["dbname"]);
} require_once ('functions_db.php');
} else { $configs = get_db_all_rows_in_table ('tconfig');
exit ('<html><head><title>Pandora FMS Error</title>
<link rel="stylesheet" href="./include/styles/pandora.css" type="text/css"> if (sizeof ($configs) == 0) {
</head><body><div align="center"> exit ('<html><head><title>Pandora FMS Error</title>
<div id="db_f"> <link rel="stylesheet" href="./include/styles/pandora.css" type="text/css">
<div> </head><body><div align="center">
<a href="index.php"><img src="images/pandora_logo.png" border="0"></a> <div id="db_f">
</div> <div>
<div id="db_ftxt"> <a href="index.php"><img src="images/pandora_logo.png" border="0"></a>
<h1 id="log_f" class="error">Pandora Console Error DB-002</h1> </div>
Cannot load configuration variables. Please check your database setup in the <div id="db_ftxt">
<b>./include/config.php</b> file and read documentation.<i><br><br> <h1 id="log_f" class="error">Pandora Console Error DB-002</h1>
Probably database schema is created but there are no data inside it or you have a problem with DB access credentials. Cannot load configuration variables. Please check your database setup in the
</i><br> <b>./include/config.php</b> file and read documentation.<i><br><br>
</div> Probably database schema is created but there are no data inside it or you have a problem with DB access credentials.
</div></body></html>'); </i><br>
</div>
</div></body></html>');
}
foreach ($configs as $c) {
switch ($c["token"]) {
case "language_code":
$config["language"] = $c["value"];
break;
case "block_size":
$config["block_size"] = $c["value"];
break;
case "days_purge":
$config["days_purge"] = $c["value"];
break;
case "days_compact":
$config["days_compact"] = $c["value"];
break;
case "graph_res":
$config["graph_res"] = $c["value"];
break;
case "step_compact":
$config["step_compact"] = $c["value"];
break;
case "style":
$config["style"] = $c["value"];
break;
case "show_unknown":
$config["show_unknown"] = $c["value"];
break;
case "show_lastalerts":
$config["show_lastalerts"] = $c["value"];
break;
case "remote_config":
$config["remote_config"] = $c["value"];
break;
case "graph_color1":
$config["graph_color1"] = $c["value"];
break;
case "graph_color2":
$config["graph_color2"] = $c["value"];
break;
case "graph_color3":
$config["graph_color3"] = $c["value"];
break;
case "sla_period":
$config["sla_period"] = $c["value"];
break;
}
} }
if ($config["language"] == 'ast_es') { if ($config["language"] == 'ast_es') {
$help_code='ast'; $help_code = 'ast';
} } else {
else $help_code = substr($config["language"],0,2); $help_code = substr ($config["language"], 0, 2);
}
?> ?>

View File

@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require ('functions_html.php'); require_once ('functions_html.php');
/** /**
* Prints a help tip icon. * Prints a help tip icon.

View File

@ -80,8 +80,8 @@ function give_acl ($id_user, $id_group, $access) {
PM - Pandora Management PM - Pandora Management
*/ */
// Conexion con la base Datos global $config;
require("config.php");
$query1="SELECT * FROM tusuario WHERE id_usuario = '".$id_user."'"; $query1="SELECT * FROM tusuario WHERE id_usuario = '".$id_user."'";
$res=mysql_query($query1); $res=mysql_query($query1);
$row=mysql_fetch_array($res); $row=mysql_fetch_array($res);
@ -157,7 +157,6 @@ function give_acl ($id_user, $id_group, $access) {
* @param descripcion Long action description * @param descripcion Long action description
*/ */
function audit_db ($id, $ip, $accion, $descripcion){ function audit_db ($id, $ip, $accion, $descripcion){
require("config.php");
$today=date('Y-m-d H:i:s'); $today=date('Y-m-d H:i:s');
$utimestamp = time(); $utimestamp = time();
$sql1='INSERT INTO tsesion (ID_usuario, accion, fecha, IP_origen,descripcion, utimestamp) VALUES ("'.$id.'","'.$accion.'","'.$today.'","'.$ip.'","'.$descripcion.'", '.$utimestamp.')'; $sql1='INSERT INTO tsesion (ID_usuario, accion, fecha, IP_origen,descripcion, utimestamp) VALUES ("'.$id.'","'.$accion.'","'.$today.'","'.$ip.'","'.$descripcion.'", '.$utimestamp.')';
@ -171,10 +170,11 @@ function audit_db ($id, $ip, $accion, $descripcion){
* @param ip Client user IP address. * @param ip Client user IP address.
*/ */
function logon_db ($id_user, $ip) { function logon_db ($id_user, $ip) {
require ("config.php"); global $config;
audit_db ($id_user, $ip, "Logon", "Logged in");
audit_db ($config['id_user'], $ip, "Logon", "Logged in");
// Update last registry of user to get last logon // Update last registry of user to get last logon
$sql = 'UPDATE tusuario fecha_registro = $today WHERE id_usuario = "$id_user"'; $sql = sprintf ('UPDATE tusuario fecha_registro = $today WHERE id_usuario = "%s"', $id_user);
$result = mysql_query ($sql); $result = mysql_query ($sql);
} }
@ -185,8 +185,8 @@ function logon_db ($id_user, $ip) {
* @param ip Client user IP address. * @param ip Client user IP address.
*/ */
function logoff_db ($id_user, $ip) { function logoff_db ($id_user, $ip) {
require ("config.php"); global $config;
audit_db ($id_user, $ip, "Logoff", "Logged out"); audit_db ($config['id_user'], $ip, "Logoff", "Logged out");
} }
/** /**
@ -683,7 +683,8 @@ function dame_generic_string_data ($id) {
* @param id_inc Incident id * @param id_inc Incident id
*/ */
function borrar_incidencia ($id_inc) { function borrar_incidencia ($id_inc) {
require ("config.php"); global $config;
$sql = "DELETE FROM tincidencia WHERE id_incidencia = ".$id_inc; $sql = "DELETE FROM tincidencia WHERE id_incidencia = ".$id_inc;
mysql_query ($sql); mysql_query ($sql);
$sql = "SELECT * FROM tnota_inc WHERE id_incidencia = ".$id_inc; $sql = "SELECT * FROM tnota_inc WHERE id_incidencia = ".$id_inc;
@ -810,24 +811,25 @@ function existe ($id_user) {
/** /**
* Insert a event in the event log system. * Insert a event in the event log system.
* *
* @param evento * @param event
* @param id_grupo * @param id_group
* @param id_agente * @param id_agent
* @param status * @param status
* @param id_usuario * @param id_user
* @param event_type * @param event_type
* @param priority * @param priority
* @param id_agent_module * @param id_agent_module
* @param id_aam * @param id_aam
*/ */
function event_insert ($evento, $id_grupo, $id_agente, $status = 0, function event_insert ($event, $id_group, $id_agent, $status = 0,
$id_usuario = '', $event_type = "unknown", $priority = 0, $id_user = '', $event_type = "unknown", $priority = 0,
$id_agent_module = 0, $id_aam = 0) { $id_agent_module = 0, $id_aam = 0) {
$sql = 'INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, $sql = sprint ('INSERT INTO tevento (id_agente, id_grupo, evento, timestamp,
estado, utimestamp, id_usuario, event_type, criticity, id_agentmodule, id_alert_am) estado, utimestamp, id_usuario, event_type, criticity,
VALUES ('.$id_agente.','.$id_grupo.',"'.$evento.'",NOW(),'.$status. id_agentmodule, id_alert_am)
', '.$utimestamp.', "'.$id_usuario.'", "'.$event_type.'", '.$priority. VALUES (%d, %d, "%s", NOW(), %d, NOW(), "%s", "%s", %d, %d, %d)',
', '.$id_agent_module.', '.$id_aam.')'; $id_agent, $id_group, $event, $status, $id_user, $event_type,
$priority, $id_agent_module, $id_aam);
mysql_query ($sql); mysql_query ($sql);
} }
@ -1450,7 +1452,7 @@ function get_previous_data ($id_agent_module, $utimestamp) {
* *
* @return The average module value in the interval. * @return The average module value in the interval.
*/ */
function return_moduledata_avg_value ($id_agent_module, $period, $date = 0) { function get_agent_module_value_average ($id_agent_module, $period, $date = 0) {
if (! $date) if (! $date)
$date = time (); $date = time ();
$datelimit = $date - $period; $datelimit = $date - $period;
@ -1482,7 +1484,7 @@ function return_moduledata_avg_value ($id_agent_module, $period, $date = 0) {
* *
* @return The maximum module value in the interval. * @return The maximum module value in the interval.
*/ */
function return_moduledata_max_value ($id_agent_module, $period, $date = 0) { function get_agent_module_value_max ($id_agent_module, $period, $date = 0) {
if (! $date) if (! $date)
$date = time (); $date = time ();
$datelimit = $date - $period; $datelimit = $date - $period;
@ -1510,7 +1512,7 @@ function return_moduledata_max_value ($id_agent_module, $period, $date = 0) {
* *
* @return The minimum module value of the module * @return The minimum module value of the module
*/ */
function return_moduledata_min_value ($id_agent_module, $period, $date = 0) { function get_agent_module_value_min ($id_agent_module, $period, $date = 0) {
if (! $date) if (! $date)
$date = time (); $date = time ();
$datelimit = $date - $period; $datelimit = $date - $period;
@ -1537,7 +1539,7 @@ function return_moduledata_min_value ($id_agent_module, $period, $date = 0) {
* *
* @return The sumatory of the module values in the interval. * @return The sumatory of the module values in the interval.
*/ */
function return_moduledata_sum_value ($id_agent_module, $period, $date = 0) { function get_agent_module_value_sumatory ($id_agent_module, $period, $date = 0) {
if (! $date) if (! $date)
$date = time (); $date = time ();
$datelimit = $date - $period; // limit date $datelimit = $date - $period; // limit date
@ -1596,7 +1598,12 @@ function return_moduledata_sum_value ($id_agent_module, $period, $date = 0) {
if ($timestamp_end <= $datelimit) { if ($timestamp_end <= $datelimit) {
$elapsed = $timestamp_end - $timestamp_begin; $elapsed = $timestamp_end - $timestamp_begin;
$times = intval ($elapsed / $module_interval); $times = intval ($elapsed / $module_interval);
$sum += $times * $previous_data; if (is_module_inc ($module_name)) {
$data_value = $data['datos'] * $module_interval;
} else {
$data_value = $data['datos'];
}
$sum += $times * $data_value;
} }
return (float) $sum; return (float) $sum;

View File

@ -16,7 +16,7 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
function return_module_SLA ($id_agent_module, $period, $min_value, $max_value, $date = 0) { function get_agent_module_sla ($id_agent_module, $period, $min_value, $max_value, $date = 0) {
require("config.php"); require("config.php");
if (! $date) if (! $date)
$date = time (); $date = time ();
@ -190,60 +190,110 @@ function general_stats ( $id_user, $id_group = 0) {
return $data; return $data;
} }
function event_reporting ($id_agent, $period, $date = 0, $return = false) { function event_reporting ($id_group, $period, $date = 0, $return = false) {
require("config.php"); global $config;
require ("include/languages/language_".$config["language"].".php");
$output = '';
$id_user = $_SESSION["id_usuario"];
global $REMOTE_ADDR;
if (! $date) if (! $date)
$date = time (); $date = time ();
$mytimestamp = $date - $period; $datelimit = $date - $period;
$output .= "<table cellpadding='4' cellspacing='4' width='100%' class='databox'>"; $table->data = array ();
$output .= "<tr>"; $table->head = array ();
$output .= "<th>".$lang_label["status"]."</th>"; $table->head[0] = lang_string ('status');
$output .= "<th>".$lang_label["event_name"]."</th>"; $table->head[1] = lang_string ('event_name');
$output .= "<th>".$lang_label["id_user"]."</th>"; $table->head[2] = lang_string ('id_user');
$output .= "<th>".$lang_label["timestamp"]."</th>"; $table->head[3] = lang_string ('timestamp');
$color = 1;
$id_evento = 0;
$sql2="SELECT * FROM tevento WHERE id_agente = $id_agent AND utimestamp > '$mytimestamp'"; $sql = sprintf ('SELECT * FROM tevento
WHERE id_agente = %d
// Make query for data (all data, not only distinct). AND utimestamp > %d AND utimestamp <= %d
$result2 = mysql_query($sql2); AND id_grupo = %d
while ($row2 = mysql_fetch_array($result2)) { ORDER BY utimestamp ASC',
$id_grupo = $row2["id_grupo"]; $id_group, $datelimit, $date, $id_group);
if (give_acl($id_user, $id_grupo, "IR") == 1) { // Only incident read access to view data ! $events = get_db_all_rows_sql ($sql);
$id_group = $row2["id_grupo"]; foreach ($events as $event) {
if ($color == 1){ $data = array ();
$tdcolor = "datos"; if ($event["estado"] == 0)
$color = 0; $data[0] = '<img src="images/dot_red.png">';
} else
else { $data[0] = '<img src="images/dot_green.png">';
$tdcolor = "datos2"; $data[1] = $event['evento'];
$color = 1; $data[2] = $event['id_usuario'] != '0' ? $event['id_usuario'] : '';
} $data[3] = $event["timestamp"];
$output .= "<tr><td class='$tdcolor' align='center'>"; array_push ($table->data, $data);
if ($row2["estado"] == 0)
$output .= "<img src='images/dot_red.png'>";
else
$output .= "<img src='images/dot_green.png'>";
$output .= "<td class='$tdcolor'>".$row2["evento"];
$output .= "<td class='$tdcolor'>";
if ($row2["estado"] <> 0)
$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>";
}
} }
$output .= "</table>";
if (!$return) if (!$return)
echo $output; print_table ($table);
return $output; return $table;
}
function get_alerts_in_group ($id_group) {
$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);
}
return $alerts;
}
function get_alerts_fired ($alerts, $period = 0, $date = 0) {
if (! $date)
$date = time ();
$datelimit = $date - $period;
$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;
}
return $alerts_fired;
}
function get_fired_alerts_reporting_table ($alerts_fired, $return = false) {
$agents = array ();
foreach (array_keys ($alerts_fired) as $id_alert) {
$alert = get_db_row ('talerta_agente_modulo', 'id_aam', $id_alert);
/* 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 ();
}
array_push ($agents[$id_agent], $alert);
}
$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] = dame_nombre_agente_agentemodulo ($alert['id_agente_modulo']);
else
$data[0] = '';
$data[1] = $alert['descripcion'];
$data[2] = $alerts_fired[$alert['id_aam']];
$data[3] = get_alert_priority ($alert['priority']);
array_push ($table->data, $data);
}
}
if (!$return)
print_table ($table);
return $table;
} }
/** /**
@ -258,73 +308,32 @@ function event_reporting ($id_agent, $period, $date = 0, $return = false) {
* @param $return Flag to return or echo the report (by default). * @param $return Flag to return or echo the report (by default).
*/ */
function alert_reporting ($id_group, $period = 0, $date = 0, $return = false) { function alert_reporting ($id_group, $period = 0, $date = 0, $return = false) {
if (! $date)
$date = time ();
$datelimit = $date - $period;
$output = ''; $output = '';
$alerts = array (); $alerts = get_alerts_in_group ($id_group);
$alerts_fired = get_alerts_fired ($alerts, $period, $date);
$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;
$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 ();
/* 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 ();
}
array_push ($agents[$id_agent], $alert);
}
$fired_percentage = round (sizeof ($alerts_fired) / sizeof ($alerts) * 100, 2); $fired_percentage = round (sizeof ($alerts_fired) / sizeof ($alerts) * 100, 2);
$not_fired_percentage = 100 - $fired_percentage; $not_fired_percentage = 100 - $fired_percentage;
$output .= '<img src="reporting/fgraph.php?tipo=alerts_fired_pipe&height=150&width=280&fired='. $output .= '<img src="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">'; $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 ('fired_alerts').': '.sizeof ($alerts_fired).'</strong><br />';
$output .= '<strong>'.lang_string ('total_alerts_monitored').': '.sizeof ($alerts).'</strong><br />'; $output .= '<strong>'.lang_string ('total_alerts_monitored').': '.sizeof ($alerts).'</strong><br />';
if ($alerts_fired) { if (! sizeof ($alerts_fired)) {
$table->width = '100%'; if (!$return)
$table->class = 'databox'; echo $output;
$table->size = array (); return $output;
$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] = get_alert_priority ($alert['priority']);
array_push ($table->data, $data);
}
}
$output .= print_table ($table, true);
} }
$table = get_fired_alerts_reporting_table ($alerts_fired, true);
$table->width = '100%';
$table->class = 'databox';
$table->size = array ();
$table->size[0] = '100px';
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$output .= print_table ($table, true);
if (!$return) if (!$return)
echo $output; echo $output;
return $output; return $output;
@ -347,24 +356,54 @@ function monitor_health_reporting ($id_group, $period = 0, $date = 0, $return =
$datelimit = $date - $period; $datelimit = $date - $period;
$output = ''; $output = '';
$sql = sprintf ('SELECT * FROM tagente_modulo, ttipo_modulo, tagente $monitors = get_monitors_in_group ($id_group);
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_sql ($sql);
if (sizeof ($monitors) == 0) if (sizeof ($monitors) == 0)
return; return;
$monitors_down = get_monitors_down ($monitors, $period, $date);
$down_percentage = round (sizeof ($monitors_down) / sizeof ($monitors) * 100, 2);
$not_down_percentage = 100 - $down_percentage;
$output .= '<img src="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">';
$monitors_down = 0; $output .= '<strong>'.lang_string ('total_monitors').': '.sizeof ($monitors).'</strong><br />';
$agents = array (); $output .= '<strong>'.lang_string ('monitors_down_on_period').': '.sizeof ($monitors_down).'</strong><br />';
$table = get_monitors_down_reporting_table ($monitors_down, true);
$table->width = '100%';
$table->class = 'databox';
$table->size = array ();
$table->size[0] = '100px';
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->size = array ();
$table->size[0] = '100px';
$output .= print_table ($table, true);
if (!$return)
echo $output;
return $output;
}
function get_monitors_down ($monitors, $period = 0, $date = 0) {
$monitors_down = array ();
foreach ($monitors as $monitor) { foreach ($monitors as $monitor) {
$down = get_monitor_downs_in_period ($monitor['id_agente_modulo'], $period, $date); $down = get_monitor_downs_in_period ($monitor['id_agente_modulo'], $period, $date);
if (! $down) { if ($down)
continue; array_push ($monitors_down, $monitor);
} }
$data = array (); return $monitors_down;
}
function get_monitors_down_reporting_table ($monitors_down, $return = false) {
$table->data = array ();
$table->head = array ();
$table->head[0] = lang_string ('agent');
$table->head[1] = lang_string ('monitor');
$agents = array ();
foreach ($monitors_down as $monitor) {
/* Add monitors fired to $agents_fired_alerts indexed by id_agent */ /* Add monitors fired to $agents_fired_alerts indexed by id_agent */
$id_agent = $monitor['id_agente']; $id_agent = $monitor['id_agente'];
if (!isset ($agents[$id_agent])) { if (!isset ($agents[$id_agent])) {
@ -374,39 +413,25 @@ function monitor_health_reporting ($id_group, $period = 0, $date = 0, $return =
$monitors_down++; $monitors_down++;
} }
$down_percentage = round ($monitors_down / sizeof ($monitors) * 100, 2); foreach ($agents as $id_agent => $monitors) {
$not_down_percentage = 100 - $down_percentage;
$output .= '<img src="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 (); $data = array ();
foreach ($monitors as $monitor) { foreach ($monitors as $monitor) {
if (! isset ($data[0])) if (! isset ($data[0]))
$data[0] = '<strong>'.$monitor['nombre'].'</strong>'; $data[0] = dame_nombre_agente ($id_agent);
else else
$data[0] = ''; $data[0] = '';
$data[1] = $monitor['descripcion']; if ($monitor['descripcion'] != '') {
$data[1] = $monitor['descripcion'];
} else {
$data[1] = $monitor['nombre'];
}
array_push ($table->data, $data); array_push ($table->data, $data);
} }
} }
$output .= print_table ($table, true);
if (!$return) if (!$return)
echo $output; print_table ($table);
return $output; return $table;
} }
/** /**
@ -427,42 +452,37 @@ function general_group_reporting ($id_group, $return = false) {
return $output; return $output;
} }
/** function get_monitors_in_group ($id_group) {
* Get a detailed report of an agent $sql = sprintf ('SELECT tagente_modulo.*
* FROM tagente_modulo, ttipo_modulo, tagente
* @param $id_agent Agent to get the report. WHERE id_tipo_modulo = id_tipo
* @param $period Period of time of the desired report. AND tagente.id_agente = tagente_modulo.id_agente
* @param $date Beggining date of the report (current date by default). AND ttipo_modulo.nombre like "%%_proc"
* @param $return Flag to return or echo the report (by default). AND tagente.id_grupo = %d', $id_group);
*/ return get_db_all_rows_sql ($sql);
function agent_detailed_reporting ($id_agent, $period = 0, $date = 0, $return = false) { }
$output = '';
$n_a_string = lang_string ('N/A').'(*)';
$monitors = array ();
$table_modules->data = array ();
$table_modules->head = array ();
$table_alerts->data = array ();
/* Show modules in agent */ function get_monitors_in_agent ($id_agent) {
$modules = get_modules_in_agent ($id_agent); $sql = sprintf ('SELECT tagente_modulo.*
$output .= '<div class="agent_reporting">'; FROM tagente_modulo, ttipo_modulo, tagente
$output .= '<h3 style="text-decoration: underline">'.lang_string ('agent').' - '.dame_nombre_agente ($id_agent).'</h3>'; WHERE id_tipo_modulo = id_tipo
$output .= '<h4>'.lang_string ('modules').'</h3>'; AND tagente.id_agente = tagente_modulo.id_agente
$data = array (); AND ttipo_modulo.nombre like "%%_proc"
foreach ($modules as $module) { AND tagente.id_agente = %d', $id_agent);
if ($module['descripcion'] != $n_a_string && $module['descripcion'] != '') return get_db_all_rows_sql ($sql);
$data[0] = $module['descripcion']; }
else
$data[0] = $module['nombre']; function get_agent_alerts_reporting_table ($id_agent, $period = 0, $date = 0, $return = false) {
$module_name = giveme_module_type ($module['id_tipo_modulo']); $table->data = array ();
if (is_module_proc ($module_name)) { $table->head = array ();
array_push ($monitors, $module); $table->head[0] = lang_string ('type');
} $table->head[1] = lang_string ('description');
array_push ($table_modules->data, $data); $table->head[2] = lang_string ('min');
} $table->head[3] = lang_string ('max');
$output .= print_table ($table_modules, true); $table->head[4] = lang_string ('threshold');
$table->head[5] = lang_string ('last_fired');
$table->head[6] = lang_string ('times_fired');
/* Show alerts in agent */
$alerts = get_alerts_in_agent ($id_agent); $alerts = get_alerts_in_agent ($id_agent);
foreach ($alerts as $alert) { foreach ($alerts as $alert) {
$fires = get_alert_fires_in_period ($alert['id_agente_modulo'], $period, $date); $fires = get_alert_fires_in_period ($alert['id_agente_modulo'], $period, $date);
@ -479,21 +499,21 @@ function agent_detailed_reporting ($id_agent, $period = 0, $date = 0, $return =
$data[5] = get_alert_last_fire_timestamp_in_period ($alert['id_agente_modulo'], $period, $date); $data[5] = get_alert_last_fire_timestamp_in_period ($alert['id_agente_modulo'], $period, $date);
$data[6] = $fires; $data[6] = $fires;
array_push ($table_alerts->data, $data); array_push ($table->data, $data);
}
if (sizeof ($table_alerts->data)) {
$output .= '<h4>'.lang_string ('alerts').'</h4>';
$output .= print_table ($table_alerts, true);
} }
if (!$return)
print_table ($table);
return $table;
}
function get_agent_monitors_reporting_table ($id_agent, $period = 0, $date = 0, $return = false) {
$n_a_string = lang_string ('N/A').'(*)';
$table->head = array ();
$table->head[0] = lang_string ('monitor');
$table->head[1] = lang_string ('last_failure');
$table->data = array ();
$monitors = get_monitors_in_agent ($id_agent);
/* Show monitor status in agent (if any) */
if (sizeof ($monitors) == 0) {
$output .= '</div>';
if (! $return)
echo $output;
return $output;
}
$table_monitors->data = array ();
foreach ($monitors as $monitor) { foreach ($monitors as $monitor) {
$downs = get_monitor_downs_in_period ($monitor['id_agente_modulo'], $period, $date); $downs = get_monitor_downs_in_period ($monitor['id_agente_modulo'], $period, $date);
if (! $downs) { if (! $downs) {
@ -505,12 +525,75 @@ function agent_detailed_reporting ($id_agent, $period = 0, $date = 0, $return =
else else
$data[0] = $monitor['nombre']; $data[0] = $monitor['nombre'];
$data[1] = get_monitor_last_down_timestamp_in_period ($monitor['id_agente_modulo'], $period, $date); $data[1] = get_monitor_last_down_timestamp_in_period ($monitor['id_agente_modulo'], $period, $date);
array_push ($table_monitors->data, $data); array_push ($table->data, $data);
} }
if (sizeof ($table_monitors->data)) { if (!$return)
$output .= '<h4>'.lang_string ('monitors').'</h4>'; print_table ($table);
$output .= print_table ($table_monitors, true); return $table;
}
function get_agent_modules_reporting_table ($id_agent, $period = 0, $date = 0, $return = false) {
$table->data = array ();
$n_a_string = lang_string ('N/A').'(*)';
$modules = get_modules_in_agent ($id_agent);
$data = array ();
foreach ($modules as $module) {
if ($module['descripcion'] != $n_a_string && $module['descripcion'] != '')
$data[0] = $module['descripcion'];
else
$data[0] = $module['nombre'];
array_push ($table->data, $data);
} }
if (!$return)
print_table ($table);
return $table;
}
/**
* Get a detailed report of an agent
*
* @param $id_agent Agent to get the report.
* @param $period Period of time of the desired report.
* @param $date Beggining date of the report (current date by default).
* @param $return Flag to return or echo the report (by default).
*/
function get_agent_detailed_reporting ($id_agent, $period = 0, $date = 0, $return = false) {
$output = '';
$n_a_string = lang_string ('N/A').'(*)';
/* Show modules in agent */
$output .= '<div class="agent_reporting">';
$output .= '<h3 style="text-decoration: underline">'.lang_string ('agent').' - '.dame_nombre_agente ($id_agent).'</h3>';
$output .= '<h4>'.lang_string ('modules').'</h3>';
$table_modules = get_agent_modules_reporting_table ($id_agent, $period, $date, true);
$table_modules->width = '99%';
$output .= print_table ($table_modules, true);
/* Show alerts in agent */
$table_alerts = get_agent_alerts_reporting_table ($id_agent, $period, $date, true);
$table_alerts->width = '99%';
if (sizeof ($table_alerts->data)) {
$output .= '<h4>'.lang_string ('alerts').'</h4>';
$output .= print_table ($table_alerts, true);
}
/* Show monitor status in agent (if any) */
$table_monitors = get_agent_monitors_reporting_table ($id_agent, $period, $date, true);
if (sizeof ($table_monitors->data) == 0) {
$output .= '</div>';
if (! $return)
echo $output;
return $output;
}
$table_monitors->width = '99%';
$table_monitors->align = array ();
$table_monitors->align[1] = 'right';
$table_monitors->size = array ();
$table_monitors->align[1] = '10%';
$output .= '<h4>'.lang_string ('monitors').'</h4>';
$output .= print_table ($table_monitors, true);
$output .= '</div>'; $output .= '</div>';
if (! $return) if (! $return)
@ -524,30 +607,12 @@ function agent_detailed_reporting ($id_agent, $period = 0, $date = 0, $return =
* @param $id_group Group to get the report * @param $id_group Group to get the report
* @param $return Flag to return or echo the report (by default). * @param $return Flag to return or echo the report (by default).
*/ */
function agents_detailed_reporting ($id_group, $period = 0, $date = 0, $return = false) { function get_agents_detailed_reporting ($id_group, $period = 0, $date = 0, $return = false) {
$output = ''; $output = '';
$agents = get_agents_in_group ($id_group); $agents = get_agents_in_group ($id_group);
$table_modules->width = '700px';
$table_alerts->width = '700px';
$table_monitors->width = '700px';
$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);
foreach ($agents as $agent) { foreach ($agents as $agent) {
$output .= agent_detailed_reporting ($agent['id_agente'], $period, $date, true); $output .= get_agent_detailed_reporting ($agent['id_agente'], $period, $date, true);
if (!$return) { if (!$return) {
echo $output; echo $output;
$output = ''; $output = '';

View File

@ -17,314 +17,329 @@
global $config; global $config;
$reporting_debug = 0; $reporting_debug = false;
if ($reporting_debug != 0){ if ($reporting_debug) {
error_reporting(E_ALL); error_reporting (E_ALL);
} else { } else {
error_reporting(0); error_reporting (0);
} }
function doTitle ($pdf, $title=""){ function doTitle ($pdf, $title="") {
$pdf->transaction('start'); $pdf->transaction('start');
$ok=0; $ok=0;
while (!$ok){ while (!$ok) {
$thisPageNum = $pdf->ezPageCount; $thisPageNum = $pdf->ezPageCount;
$pdf->saveState(); $pdf->saveState();
$pdf->setColor(0.9,0.9,0.9); $pdf->setColor(0.9,0.9,0.9);
$pdf->filledRectangle($pdf->ez['leftMargin'],$pdf->y-$pdf->getFontHeight(16)+$pdf->getFontDecender(16),$pdf->ez['pageWidth']-$pdf->ez['leftMargin']-$pdf->ez['rightMargin'],$pdf->getFontHeight(16)); $pdf->filledRectangle($pdf->ez['leftMargin'],$pdf->y-$pdf->getFontHeight(16)+$pdf->getFontDecender(16),$pdf->ez['pageWidth']-$pdf->ez['leftMargin']-$pdf->ez['rightMargin'],$pdf->getFontHeight(16));
$pdf->restoreState(); $pdf->restoreState();
$pdf->ezText (utf8_decode($title),14,array('justification'=>'left')); $pdf->ezText (utf8_decode($title),14,array('justification'=>'left'));
$pdf->ezText ("\n",6); $pdf->ezText ("\n",6);
if ($pdf->ezPageCount==$thisPageNum){ if ($pdf->ezPageCount==$thisPageNum){
$pdf->transaction('commit'); $pdf->transaction('commit');
$ok=1; $ok = 1;
} else { } else {
// then we have moved onto a new page, bad bad, as the background colour will be on the old one // then we have moved onto a new page, bad bad, as the background colour will be on the old one
$pdf->transaction('rewind'); $pdf->transaction('rewind');
$pdf->ezNewPage(); $pdf->ezNewPage();
} }
} }
} }
function doPageNumbering($pdf, $x=500, $y=25, $size=9) { function doPageNumbering($pdf, $x=500, $y=25, $size=9) {
// Original code by Johny Mnemonic (mnemonic23 in SF site) // Original code by Johny Mnemonic (mnemonic23 in SF site)
// God bless Sourceforge forums ! // God bless Sourceforge forums !
//count pages //count pages
$pages = count($pdf->ezPages); $pages = count($pdf->ezPages);
//iterate through pages //iterate through pages
for($pageno = 1; $pageno <= $pages; $pageno++) { for($pageno = 1; $pageno <= $pages; $pageno++) {
//build footer string //build footer string
$foot = 'Page '.$pageno.' of '.$pages; $foot = 'Page '.$pageno.' of '.$pages;
//open the page again //open the page again
$pdf->reopenObject($pdf->ezPages[$pageno]); $pdf->reopenObject($pdf->ezPages[$pageno]);
//print the footer //print the footer
$pdf->addText($x, $y, $size, $foot); $pdf->addText($x, $y, $size, $foot);
//close the page //close the page
$pdf->closeObject(); $pdf->closeObject();
} }
} }
function doPageHeader ($pdf, $title){ function doPageHeader ($pdf, $title){
global $config; global $config;
$pdf->addInfo("Title", $title); $pdf->addInfo("Title", $title);
$pdf->addInfo("Author","Pandora FMS 2.0"); $pdf->addInfo("Author","Pandora FMS 2.0");
$pdf->addInfo("Creator","Pandora FMS with ezPDF engine"); $pdf->addInfo("Creator","Pandora FMS with ezPDF engine");
$pdf->addInfo("Subject","Automated Pandora FMS report for user defined report"); $pdf->addInfo("Subject","Automated Pandora FMS report for user defined report");
// Add header // Add header
$all = $pdf->openObject(); $all = $pdf->openObject();
$pdf->saveState(); $pdf->saveState();
$pdf->addJpegFromFile($config["homedir"]."/images/pandora_logo.jpg",20,812,25); $pdf->addJpegFromFile($config["homedir"]."/images/pandora_logo.jpg",20,812,25);
$pdf->setStrokeColor(0,0,0,1); $pdf->setStrokeColor(0,0,0,1);
$pdf->line(20,40,578,40); $pdf->line(20,40,578,40);
$pdf->line(20,810,578,810); $pdf->line(20,810,578,810);
$pdf->addText(25,25,8,'Pandora FMS 2.0 - http://pandora.sourceforge.net'); $pdf->addText(25,25,8,'Pandora FMS 2.0 - http://pandora.sourceforge.net');
$pdf->addText(50,815,10,"Pandora FMS - Report $title"); $pdf->addText(50,815,10,"Pandora FMS - Report $title");
$pdf->restoreState(); $pdf->restoreState();
$pdf->closeObject(); $pdf->closeObject();
$pdf->addObject($all,'all'); $pdf->addObject($all,'all');
} }
// =========================================================================================== function get_pdf_report ($report) {
// =========================================================================================== global $config;
$session_id = session_id ();
function event_reporting_pdf ($id_agent, $period){
global $config;
require ($config["homedir"]."/include/languages/language_".$config["language"].".php");
$id_user=$_SESSION["id_usuario"];
global $REMOTE_ADDR;
$ahora = date("U");
$mytimestamp = $ahora - $period;
$total_count = 0;
$table_data = array();
$sql2="SELECT * FROM tevento WHERE id_agente = $id_agent AND utimestamp > '$mytimestamp'";
// Make query for data (all data, not only distinct).
$result2=mysql_query($sql2);
while ($row2=mysql_fetch_array($result2)){
$id_grupo = $row2["id_grupo"];
if (give_acl($id_user, $id_grupo, "IR") == 1){ // Only incident read access to view data !
$id_group = $row2["id_grupo"];
if ($row2["estado"] == 0)
$table_data[$total_count][0] = "--";
else
$table_data[$total_count][0] = "OK";
$table_data[$total_count][1] = $row2["evento"];
if ($row2["estado"] <> 0)
$table_data[$total_count][2] = substr($row2["id_usuario"],0,8);
else
$table_data[$total_count][2] = "";
$table_data[$total_count][3] = $row2["timestamp"];
$total_count++;
}
}
return $table_data;
}
function alert_reporting_pdf ($id_agent_module){
global $config;
require ($config["homedir"]."/include/languages/language_".$config["language"].".php");
$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);
$total_count = 0;
$table_data = array();
if (mysql_num_rows ($result_gen)) {
while ($data=mysql_fetch_array($result_gen)){
if ($data["times_fired"] <> 0)
$table_data[$total_count][0] = "FIRED";
else
$table_data[$total_count][0] = "--";
$table_data[$total_count][1] = $data["descripcion"];
$table_data[$total_count][2] = human_time_description($data["time_threshold"]);
if ($data["last_fired"] == "0000-00-00 00:00:00") {
$table_data[$total_count][3] = $lang_label["never"];
}
else {
$table_data[$total_count][3] = human_time_comparation ($data["last_fired"]);
}
$table_data[$total_count][4] = $data["times_fired"];
$total_count++;
}
}
return $table_data;
}
function general_report ($id_report){
global $config;
include $config["homedir"]."/include/languages/language_".$config["language"].".php";
include ($config["homedir"].'/include/pdf/class.ezpdf.php');
require ($config["homedir"]."/include/functions_reporting.php");
$session_id = session_id();
$report_name = html_entity_decode(get_db_value ("name", "treport", "id_report", $id_report), ENT_COMPAT, "iso-8859-15");
$report_description = html_entity_decode (get_db_value ("description", "treport", "id_report", $id_report), ENT_COMPAT, "iso-8859-15");
$report_private= html_entity_decode( get_db_value ("private", "treport", "id_report", $id_report), ENT_COMPAT, "iso-8859-15");
$report_user = html_entity_decode( get_db_value ("id_user", "treport", "id_report", $id_report), ENT_COMPAT, "iso-8859-15");
$report_name = html_entity_decode ($report['name'], ENT_COMPAT, "iso-8859-15");
$report_description = html_entity_decode ($report['description'], ENT_COMPAT, "iso-8859-15");
$report_private= $report['private'];
$report_user = $report['id_user'];
$date_today = date("Y/m/d H:i:s"); $date_today = date("Y/m/d H:i:s");
$report_title = utf8_decode ("$report_name"); $report_title = utf8_decode ("$report_name");
// Start PDF // Start PDF
$pdf = new Cezpdf (); $pdf = new Cezpdf ();
$pdf->selectFont ($config["homedir"].'/include/pdf/fonts/Times-Roman.afm', array('encoding'=>'utf-8')); $pdf->selectFont ($config["homedir"].'/include/pdf/fonts/Times-Roman.afm', array('encoding'=>'utf-8'));
doPageHeader ($pdf, $report_title); doPageHeader ($pdf, $report_title);
$pdf->ezSetCmMargins(2,2,2,2); $pdf->ezSetCmMargins (2, 2, 2, 2);
$pdf->ezText ("<b>$report_title </b>", 18); $pdf->ezText ("<b>$report_title </b>", 18);
$pdf->ezText ("Generated at $date_today", 8); $pdf->ezText ("Generated at $date_today", 8);
$pdf->ezText ("\n".$report_description, 10); $pdf->ezText ("\n".$report_description, 10);
$pdf->ezText ("\n\n", 8); $pdf->ezText ("\n\n", 8);
$table_options = array ('width' => 450,
'fontSize' => 9,
'rowGap' => 2,
'outerLineThickness' => 0.8,
'innerLineThickness' => 0.2,
'shaded' => 1);
$group_name = dame_grupo ($report['id_group']);
$sql = "SELECT * FROM treport_content WHERE id_report = $id_report ORDER by type, id_agent_module DESC"; $agents = get_agents_in_group ($report['id_group']);
$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);
// Agent name for type 3 (event )
if ($type != 3) { $sql = sprintf ('SELECT * FROM treport_content WHERE id_report = %d ORDER BY `order`', $report['id_report']);
$module_name = utf8_decode(get_db_sql ("SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = ". $id_agent_module)); $contents = get_db_all_rows_sql ($sql);
$agent_name = dame_nombre_agente_agentemodulo ($id_agent_module); foreach ($contents as $content) {
} else { $module_name = utf8_decode (get_db_value ('nombre', 'tagente_modulo', 'id_agente_modulo', $content['id_agent_module']));
$agent_name = utf8_decode(get_db_sql ("SELECT nombre FROM tagente WHERE id_agente =$id_agent_module")); $agent_name = utf8_decode (dame_nombre_agente_agentemodulo ($content['id_agent_module']));
$module_name = ""; $period = human_time_description ($content['period']);
}
switch($type){ switch ($content["type"]) {
case 2: // SLA case 1:
$sla_result = format_numeric(return_module_SLA ($id_agent_module, $period, $sla_min, $sla_max), 2); case 'simple_graph':
doTitle($pdf, lang_string("SLA").": $agent_name - $module_name"); doTitle ($pdf, lang_string ("Module graph").': '.$agent_name.
//if ($sla_result < $sla_limit) ' - '.$module_name.' - '.$period);
$pdf->setColor(0.9,0,0,0); // Red ink $image = 'http://'.$_SERVER['HTTP_HOST'].$config["homeurl"].
$pdf->ezText ("<b>".$sla_result . " %</b>", 18); '/reporting/fgraph.php?PHPSESSID='.$session_id.
$pdf->setColor(0,0,0,1); // Black again '&tipo=sparse&id='.$content["id_agent_module"].
$pdf->ezText ($lang_label["sla_max"]. " : ".$sla_max,8); '&height=180&width=780&period='.$content['period'].
$pdf->ezText ($lang_label["sla_min"]. " : ".$sla_min,8); '&avg_only=1&pure=1';
$pdf->ezText ($lang_label["sla_limit"]. " : ".$sla_limit,8); //ezImage(image,[padding],[width],[resize],[justification],[array border]
$pdf->ezText ("\n",8); $pdf->ezImage ($image,0,470,'none','left');
break;
case 0: // Simple graph break;
doTitle($pdf, lang_string("Module graph").": $agent_name - $module_name"); case 2:
$pdf->ezText (human_time_description($period)."\n",8); case 'custom_graph':
$image = $config["homeurl"]."/reporting/fgraph.php?PHPSESSID=".$session_id."&tipo=sparse&id=$id_agent_module&height=180&width=780&period=$period&avg_only=1&pure=1"; $graph = get_db_row ("tgraph", "id_graph", $content["id_gs"]);
//ezImage(image,[padding],[width],[resize],[justification],[array border]) $modules = array ();
$pdf->ezImage($image,0,470,'none','left'); $weights = array ();
$pdf->ezText ("\n",8); $sql = sprintf ('SELECT * FROM tgraph_source
break; WHERE id_graph = %d',
$content["id_gs"]);
$result = mysql_query ($sql);
while ($content2 = mysql_fetch_array($result)) {
array_push ($modules, $content2['id_agent_module']);
array_push ($weights, $content2["weight"]);
}
doTitle ($pdf, lang_string ("Custom graph").': '.$graph["name"].
' - '.$period);
$image = 'http://'.$_SERVER['HTTP_HOST'].$config["homeurl"].
'/reporting/fgraph.php?PHPSESSID='.$session_id.'&tipo=combined&id='.
implode (',', $modules).'&weight_l='.implode (',', $weights).
'&height=230&width=720&period='.$content['period'].'&stacked='.
$graph["stacked"].'&pure=1';
$pdf->ezImage ($image, 0, 470, 'none', 'left');
case 1: // Custom/Combined graph break;
$graph = get_db_row ("tgraph", "id_graph", $id_gs); case 3:
$graph_name = $graph["name"]; case 'SLA':
$stacked = $graph["stacked"]; doTitle ($pdf, lang_string ('SLA').': '.$period);
$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;
}
}
doTitle($pdf, lang_string("Custom graph").": $graph_name");
$pdf->ezText (human_time_description($period)."\n",8);
$image = $config["homeurl"]."/reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&height=230&width=720&stacked=$stacked&period=$period&pure=1";
$pdf->ezImage($image,0,470,'none','left');
$pdf->ezText ("\n",8);
break;
case 6: // AVG value
$avg_value = format_for_graph(return_moduledata_avg_value ($id_agent_module, $period),2);
doTitle($pdf, lang_string("avg_value").": $agent_name - $module_name");
$pdf->ezText (human_time_description($period)."\n",8);
$pdf->ezText ("<b>".$avg_value . "</b>", 18);
$pdf->ezText ("\n",8);
break;
case 7: // MAX value $slas = get_db_all_rows_field_filter ('treport_content_sla_combined',
$max_value = format_for_graph(return_moduledata_max_value ($id_agent_module, $period),2); 'id_report_content', $content['id_rc']);
doTitle($pdf, lang_string("max_value").": $agent_name - $module_name"); if (sizeof ($slas) == 0) {
$pdf->ezText (human_time_description($period)."\n",8); $pdf->ezText ("<b>".lang_string ('no_defined_slas') . " %</b>", 18);
$pdf->ezText ("<b>".$max_value . "</b>", 18); }
$pdf->ezText ("\n",8); $table->data = array ();
break; $table->head = array (lang_string ('Info'),
case 8: // MIN value lang_string ('sla_result'));
$min_value = format_for_graph(return_moduledata_min_value ($id_agent_module, $period),2); foreach ($slas as $sla) {
doTitle($pdf, lang_string("min_value").": $agent_name - $module_name"); $data = array ();
$pdf->ezText (human_time_description($period)."\n",8);
$pdf->ezText ("<b>".$min_value . "</b>", 18);
$pdf->ezText ("\n",8);
break;
case 5: // Monitor report
$monitor_value = $sla_result = format_numeric(return_module_SLA ($id_agent_module, $period, 1, 1), 2);
doTitle($pdf, lang_string("monitor_report").": $agent_name - $module_name");
$pdf->ezText (human_time_description($period)."\n",8);
$pdf->setColor(0,0.9,0,0); // Red ink
$pdf->ezText ("<b>UP: ".$monitor_value . " %</b>", 18);
$pdf->setColor(0.9,0,0,1); // Black again
$monitor_value2 = format_numeric(100 - $monitor_value,2) ;
$pdf->ezText ("<b>DOWN: ".$monitor_value2 . " %</b>", 18);
$pdf->setColor(0,0,0,1); // Black again
$pdf->ezText ("\n",8);
break;
case 3: // Event report
doTitle($pdf, lang_string("event_report")." - $agent_name");
$pdf->ezText (human_time_description($period)."\n",8);
$table_data = array ();
$table_label[0] = lang_string ("status");
$table_label[1] = lang_string ("event");
$table_label[2] = lang_string ("user");
$table_label[3] = lang_string ("timestamp");
$table_data = event_reporting_pdf ($id_agent_module, $period);
$pdf->ezTable( $table_data, $table_label, "",
array('width'=>450, 'fontSize'=>9, 'rowGap'=>2,
'outerLineThickness'=>0.8, 'innerLineThickness'=>0.2, 'shaded'=>1)
);
$pdf->ezText ("\n",8);
break;
case 4: // Alert report
$module_name = get_db_value ("nombre", "tagente_modulo", "id_agente_modulo", $id_agent_module);
$agent_name = dame_nombre_agente_agentemodulo ($id_agent_module);
$table_data = array();
$table_label[0] = $lang_label["status"];
$table_label[1] = $lang_label["description"];
$table_label[2] = $lang_label["time_threshold"];
$table_label[3] = $lang_label["last_fired"];
$table_label[4] = $lang_label["times_fired"];
doTitle($pdf, lang_string("alert_report").": $agent_name - $module_name"); $data[0] = lang_string ('agent')." : ".dame_nombre_agente_agentemodulo ($sla['id_agent_module'])."\n";
$table_data = alert_reporting_pdf ($id_agent_module); $data[0] .= lang_string ('module')." : ".dame_nombre_modulo_agentemodulo ($sla['id_agent_module'])."\n";
$pdf->ezTable( $table_data, $table_label, "", $data[0] .= lang_string ('sla_max')." : ".$sla['sla_max']."\n";
array('width'=>450, 'fontSize'=>9, 'rowGap'=>2, $data[0] .= lang_string ('sla_min')." : ".$sla['sla_min'];
'outerLineThickness'=>0.8, 'innerLineThickness'=>0.2, 'shaded'=>1)
);
$pdf->ezText ("\n",8);
break;
} // switch
} // while row
$sla_value = get_agent_module_sla ($sla['id_agent_module'], $content['period'],
$sla['sla_min'], $sla['sla_max']);
if ($sla_value === false) {
$data[1] = lang_string ('unknown');
} else {
if ($sla_value < $sla['sla_limit'])
$pdf->setColor (0, 1, 0, 0); // Red
$data[1] = format_numeric ($sla_value). " %";
$pdf->setColor (0, 0, 0, 1); // Black
}
array_push ($table->data, $data);
}
$pdf->ezTable ($table->data, $table->head, "", $table_options);
unset ($slas);
break;
case 4:
case 'event_report':
doTitle ($pdf, lang_string ("event_report").' - '.$period);
$table_events = event_reporting ($report['id_group'], $content['period'], 0, true);
$pdf->ezTable ($table_events->data, $table_events->head,
"", $table_options);
// End report break;
doPageNumbering($pdf); case 5:
$pdf->ezStream (); case 'alert_report':
$alerts = get_alerts_in_group ($report['id_group']);
$alerts_fired = get_alerts_fired ($alerts, $content['period']);
doTitle ($pdf, lang_string ("alert_report").': '.$group_name.
' - '.$period);
$fired_percentage = round (sizeof ($alerts_fired) / sizeof ($alerts) * 100, 2);
$not_fired_percentage = 100 - $fired_percentage;
$image = 'http://'.$_SERVER['HTTP_HOST'].$config["homeurl"].
'/reporting/fgraph.php?PHPSESSID='.$session_id.
'&tipo=alerts_fired_pipe&height=150&width=280&fired='.
$fired_percentage.'&not_fired='.$not_fired_percentage;
$pdf->ezImage ($image, 0, 150, 'none', 'left');
$pdf->ezText ('<b>'.lang_string ('fired_alerts').': '.sizeof ($alerts_fired).'</b>', 8);
$pdf->ezText ('<b>'.lang_string ('total_alerts_monitored').': '.sizeof ($alerts).'</b>', 8);
$pdf->ezText ("\n", 8);
$table_alerts = get_fired_alerts_reporting_table ($alerts_fired, true);
$pdf->ezTable ($table_alerts->data, $table_alerts->head,
"", $table_options);
unset ($alerts);
unset ($alerts_fired);
break;
case 6:
case 'monitor_report':
$value = get_agent_module_sla ($content["id_agent_module"], $content['period'], 1, 1);
doTitle ($pdf, lang_string ("monitor_report").': '.$agent_name.' - '.$module_name.
' - '.$period);
$pdf->setColor (0, 0.9, 0, 0); // Red
$pdf->ezText ('<b>'.lang_string ('up').': '.format_for_graph ($value, 2) . " %</b>", 18);
$pdf->setColor (0.9, 0, 0, 1); // Grey
$pdf->ezText ('<b>'.lang_string ('down').': '.format_numeric (100 - $value, 2) . " %</b>", 18);
$pdf->setColor (0, 0, 0, 1); // Black
break;
case 7:
case 'avg_value':
$value = get_agent_module_value_average ($content["id_agent_module"], $content['period']);
doTitle ($pdf, lang_string("avg_value").': '.$agent_name.' - '.
$module_name.' - '.$period);
$pdf->ezText ("<b>".format_for_graph ($value, 2)."</b>", 18);
break;
case 8:
case 'max_value':
$value = get_agent_module_value_max ($content["id_agent_module"], $content['period']);
doTitle ($pdf, lang_string ("max_value").': '.$agent_name.
' - '.$module_name.' - '.$period);
$pdf->ezText ("<b>".format_for_graph ($value, 2)."</b>", 18);
break;
case 9:
case 'min_value':
$value = get_agent_module_value_min ($content["id_agent_module"], $content['period']);
doTitle ($pdf, lang_string ("min_value").': '.$agent_name.
' - '.$module_name.' - '.$period);
$pdf->ezText ("<b>".format_for_graph ($value, 2)."</b>", 18);
break;
case 10:
case 'sumatory':
$value = get_agent_module_value_sumatory ($content["id_agent_module"], $content['period']);
doTitle ($pdf, lang_string ("sumatory").': '.$agent_name.
' - '.$module_name.' - '.$period);
$pdf->ezText ("<b>".format_for_graph ($value, 2)."</b>", 18);
break;
case 11:
case 'general_group_report':
doTitle ($pdf, lang_string ("group").': '.$group_name);
$pdf->ezText ("<b>".lang_string ('agents_in_group').': '.sizeof ($agents)."</b>", 12);
break;
case 12:
case 'monitor_health':
$monitors = get_monitors_in_group ($report['id_group']);
$monitors_down = get_monitors_down ($monitors, $content['period']);
doTitle ($pdf, lang_string ("monitor_health").': '.
$group_name. ' - '.$period);
$down_percentage = round (sizeof ($monitors_down) / sizeof ($monitors) * 100, 2);
$not_down_percentage = 100 - $down_percentage;
$image = 'http://'.$_SERVER['HTTP_HOST'].$config["homeurl"].
'/reporting/fgraph.php?PHPSESSID='.$session_id.
'&tipo=monitors_health_pipe&height=150&width=280&down='.
$down_percentage.'&not_down='.$not_down_percentage;
$pdf->ezImage ($image, 0, 150, 'none', 'left');
$pdf->ezText ("\n", 4);
$pdf->ezText ('<b>'.lang_string ('total_monitors').': '.sizeof ($monitors).'</b>', 8);
$pdf->ezText ('<b>'.lang_string ('monitors_down_on_period').': '.sizeof ($monitors_down).'</b>', 8);
$pdf->ezText ("\n", 8);
$table_monitors = get_monitors_down_reporting_table ($monitors_down, true);
$pdf->ezTable ($table_monitors->data, $table_monitors->head,
"", $table_options);
unset ($monitors);
unset ($monitors_down);
break;
case 13:
case 'agents_detailed':
doTitle ($pdf, lang_string ("agents_detailed").': '.
$group_name.' '.lang_string ('group'));
foreach ($agents as $agent) {
$pdf->ezText ("<b>".$agent['nombre']."</b>", 18);
$table = get_agent_modules_reporting_table ($agent['id_agente'], $content['period'], 0, true);
$pdf->ezText ("<b>".lang_string ('modules')."</b>", 12);
$pdf->ezText ("\n", 3);
$pdf->ezTable ($table->data, array (lang_string ('name')), "", $table_options);
$table = get_agent_alerts_reporting_table ($agent['id_agente'], $content['period'], 0, true);
if (sizeof ($table->data)) {
$pdf->ezText ("<b>".lang_string ('alerts')."</b>", 12);
$pdf->ezText ("\n", 3);
$pdf->ezTable ($table->data, $table->head, "", $table_options);
}
$table = get_agent_monitors_reporting_table ($agent['id_agente'], $content['period'], 0, true);
if (sizeof ($table->data)) {
$pdf->ezText ("<b>".lang_string ('monitors')."</b>", 12);
$pdf->ezText ("\n", 3);
$pdf->ezTable ($table->data, $table->head, "", $table_options);
}
}
break;
}
$pdf->ezText ("\n", 8);
}
// End report
doPageNumbering ($pdf);
$pdf->ezStream ();
} }
// End code
?> ?>

View File

@ -842,6 +842,7 @@ $lang_label["delete_sla_no"]="There was a problem deleting SLA";
$lang_label["sla_module_is_null"]="Module is not set"; $lang_label["sla_module_is_null"]="Module is not set";
$lang_label["no_defined_slas"]="There are no SLAs defined"; $lang_label["no_defined_slas"]="There are no SLAs defined";
$lang_label["defined_slas"]="SLAs defined"; $lang_label["defined_slas"]="SLAs defined";
$lang_label["sla_result"]="SLA result";
$lang_label["up"]="Up"; $lang_label["up"]="Up";
$lang_label["down"]="Down"; $lang_label["down"]="Down";
$lang_label["map_builder"]="Map builder"; $lang_label["map_builder"]="Map builder";
@ -952,6 +953,7 @@ $lang_label["Simple alerts"]="Simple alerts";
$lang_label["Combined alerts"]="Combined alerts"; $lang_label["Combined alerts"]="Combined alerts";
$lang_label["Oper"]="Oper"; $lang_label["Oper"]="Oper";
$lang_label["info"]="info"; $lang_label["info"]="info";
$lang_label["Info"]="Info";
$lang_label["Operation"]="Operation"; $lang_label["Operation"]="Operation";
$lang_label["Source Agent/Alert"]="Source Agent/Alert"; $lang_label["Source Agent/Alert"]="Source Agent/Alert";

View File

@ -176,7 +176,7 @@ div#db_ftxt {
} }
div#container { div#container {
margin: 0 auto; margin: 0 auto;
width: 960px; width: 95%;
text-align: left; text-align: left;
border-left: solid 2px #000; border-left: solid 2px #000;
border-right: solid 2px #000; border-right: solid 2px #000;
@ -184,25 +184,22 @@ div#container {
margin-top: 5px; margin-top: 5px;
} }
div#page { div#page {
width: 960px;
background: #fff; background: #fff;
clear: both; clear: both;
border-bottom: solid 5px #786; border-bottom: solid 5px #786;
border-top: solid 5px #786; border-top: solid 5px #786;
background: #FFF;
} }
div#main { div#main {
width: 780px; width: 80%;
min-height: 500px; min-height: 500px;
float: right; float: both;
padding-left: 0px; padding-left: 0px;
padding-top: 0px; padding-top: 0px;
padding-bottom: 20px; padding-bottom: 20px;
margin-bottom: 25px; margin-left: 180px;
background-color: #fefefe; background-color: #fefefe;
background-image: url(../../images/backgrounds/background4.jpg); background-image: url(../../images/backgrounds/background4.jpg);
margin-top: 0px;
margin-left: 0px;
margin-right: 0px;
} }
div#menu { div#menu {
@ -226,7 +223,6 @@ div#foot {
padding-bottom: 5px; padding-bottom: 5px;
text-align: center; text-align: center;
background: #000; background: #000;
width: 960px;
clear: both; clear: both;
} }
#ver { #ver {

View File

@ -54,45 +54,54 @@ if ($develop_bypass != 1){
} }
if ((! file_exists("include/config.php")) OR (! is_readable("include/config.php"))){ if ((! file_exists("include/config.php")) OR (! is_readable("include/config.php"))){
include ("general/error_noconfig.php"); include ("general/error_noconfig.php");
exit; exit;
} }
// Real start // Real start
session_start(); session_start();
include "include/config.php"; include_once ("include/config.php");
include "include/languages/language_".$config["language"].".php"; include_once ("include/languages/language_".$config["language"].".php");
require "include/functions.php"; // Including funcions. require_once ("include/functions.php");
require "include/functions_db.php"; require_once ("include/functions_db.php");
?> ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> <html>
<head> <head>
<?php <?php
// Pure mode (without menu, header and footer). // Pure mode (without menu, header and footer).
$config["pure"] = get_parameter("pure",0); $config["pure"] = get_parameter("pure",0);
// Auto Refresh page // Auto Refresh page
$intervalo = get_parameter ("refr",0); $intervalo = get_parameter ("refr",0);
if ($intervalo > 0){ if ($intervalo > 0){
// Agent selection filters and refresh // Agent selection filters and refresh
$query = 'http' . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == TRUE ? 's': '') . '://' . $_SERVER['SERVER_NAME']; $query = 'http' . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == TRUE ? 's': '') . '://' . $_SERVER['SERVER_NAME'];
if ($_SERVER['SERVER_PORT'] != 80)
$query .= ":" . $_SERVER['SERVER_PORT'];
$query .= $_SERVER['SCRIPT_NAME'];
if (isset ($_REQUEST["refr"])) {
$query .= '?';
foreach ($_POST as $key => $value) {
$query .= '&'.$key.'='.$value;
}
foreach ($_GET as $key => $value) {
$query .= '&'.$key.'='.$value;
}
}
if (isset ($_POST["ag_group"])) {
$ag_group = $_POST["ag_group"];
$query = 'http://' . $_SERVER['SERVER_NAME'];
if ($_SERVER['SERVER_PORT'] != 80) if ($_SERVER['SERVER_PORT'] != 80)
$query .= ":" . $_SERVER['SERVER_PORT']; $query .= ":" . $_SERVER['SERVER_PORT'];
$query .= $_SERVER['REQUEST_URI'] . '&ag_group_refresh=' . $ag_group;
$query .= $_SERVER['REQUEST_URI']; } else {
if (isset ($_POST["refr"])) echo '<meta http-equiv="refresh" content="' . $intervalo . '; URL=' . $query . '">';
$query .= '&refr=' . $intervalo;
if (isset ($_POST["ag_group"])) {
$ag_group = $_POST["ag_group"];
$query = 'http://' . $_SERVER['SERVER_NAME'];
if ($_SERVER['SERVER_PORT'] != 80)
$query .= ":" . $_SERVER['SERVER_PORT'];
$query .= $_SERVER['REQUEST_URI'] . '&ag_group_refresh=' . $ag_group;
} else
echo '<meta http-equiv="refresh" content="' . $intervalo . '; URL=' . $query . '">';
} }
}
?> ?>
<title>Pandora FMS - <?php echo lang_string("header_title"); ?></title> <title>Pandora FMS - <?php echo lang_string("header_title"); ?></title>
@ -105,10 +114,7 @@ require "include/functions_db.php";
<meta name="keywords" content="pandora, monitoring, system, GPL, software"> <meta name="keywords" content="pandora, monitoring, system, GPL, software">
<meta name="robots" content="index, follow"> <meta name="robots" content="index, follow">
<link rel="icon" href="images/pandora.ico" type="image/ico"> <link rel="icon" href="images/pandora.ico" type="image/ico">
<?php <link rel="stylesheet" href="include/styles/<?=$config['style']?>.css" type="text/css">
// Pandora FMS custom style selection
echo '<link rel="stylesheet" href="include/styles/'.$config['style'].'.css" type="text/css">';
?>
<script type="text/javascript" src="include/javascript/wz_jsgraphics.js"></script> <script type="text/javascript" src="include/javascript/wz_jsgraphics.js"></script>
<script type="text/javascript" src="include/javascript/pandora.js"></script> <script type="text/javascript" src="include/javascript/pandora.js"></script>
@ -117,11 +123,10 @@ require "include/functions_db.php";
<?php <?php
// Show custom background // Show custom background
if ($config["pure"] == 0) if ($config["pure"] == 0)
echo '<body bgcolor="#555555">'; echo '<body bgcolor="#555555">';
else else
echo '<body bgcolor="#FFFFFF">'; echo '<body bgcolor="#FFFFFF">';
$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
$REMOTE_ADDR = getenv ("REMOTE_ADDR");
// Login process // Login process
if ( (! isset ($_SESSION['id_usuario'])) && (isset ($_GET["login"]))) { if ( (! isset ($_SESSION['id_usuario'])) && (isset ($_GET["login"]))) {
@ -201,9 +206,10 @@ if (isset ($_GET["sec"])){
$sec = get_parameter_get ('sec'); $sec = get_parameter_get ('sec');
$sec = parameter_extra_clean ($sec); $sec = parameter_extra_clean ($sec);
$pagina = $sec2; $pagina = $sec2;
} } else {
else
$sec = ""; $sec = "";
}
// http://es2.php.net/manual/en/ref.session.php#64525 // http://es2.php.net/manual/en/ref.session.php#64525
// Session locking concurrency speedup! // Session locking concurrency speedup!
session_write_close(); session_write_close();
@ -212,12 +218,12 @@ session_write_close();
if ($config["pure"] == 0){ if ($config["pure"] == 0){
echo '<div id="container">'; echo '<div id="container">';
echo '<div id="head">'; echo '<div id="head">';
require("general/header.php"); require ("general/header.php");
echo '</div>'; echo '</div>';
echo '<div id="page">'; echo '<div id="page">';
echo ' <div id="menu">'; echo '<div id="menu">';
require ("general/main_menu.php"); require ("general/main_menu.php");
echo ' </div>'; echo '</div>';
} else { } else {
echo '<div id="main_pure">'; echo '<div id="main_pure">';
} }
@ -229,8 +235,8 @@ if ($config["pure"] == 0){
// Page loader / selector // Page loader / selector
if ($pagina != ""){ if ($pagina != ""){
if (file_exists ($pagina . ".php")) { if (file_exists ($pagina.".php")) {
require ($pagina . ".php"); require ($pagina.".php");
} else { } else {
echo "<br><b class='error'>".lang_string("Sorry! I can't find the page!")."</b>"; echo "<br><b class='error'>".lang_string("Sorry! I can't find the page!")."</b>";
} }
@ -247,7 +253,7 @@ if ($config["pure"] == 0){
if ($config["pure"] == 0) { if ($config["pure"] == 0) {
echo '<div id="foot">'; echo '<div id="foot">';
require("general/footer.php"); require ("general/footer.php");
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';
} }

View File

@ -17,10 +17,6 @@ require("include/config.php");
$pandora_name = 'Pandora FMS'; $pandora_name = 'Pandora FMS';
///////////////////////////////////////////////////////////////////////////////
// DOT related functions
///////////////////////////////////////////////////////////////////////////////
// Generate a dot graph definition for graphviz // Generate a dot graph definition for graphviz
function generate_dot ($simple = 0) { function generate_dot ($simple = 0) {
global $config; global $config;
@ -167,8 +163,8 @@ function open_graph () {
if ($pure == 1 && $zoom > 1 && $zoom <= 3) { if ($pure == 1 && $zoom > 1 && $zoom <= 3) {
$size_x *= $zoom; $size_x *= $zoom;
$size_y *= $zoom; $size_y *= $zoom;
} }
$size = $size_x . ',' . $size_y; $size = $size_x . ',' . $size_y;

View File

@ -99,7 +99,7 @@ require ("include/functions_reporting.php");
echo "<td class='".$tdcolor."' title='".$est_description."'>".$est_modulo."</td>"; echo "<td class='".$tdcolor."' title='".$est_description."'>".$est_modulo."</td>";
echo "<td class='$tdcolor'>"; echo "<td class='$tdcolor'>";
$temp = return_module_SLA ($row_t["id_agente_modulo"], $config["sla_period"], 1, 2147483647); $temp = get_agent_module_sla ($row_t["id_agente_modulo"], $config["sla_period"], 1, 2147483647);
if ($temp === false) if ($temp === false)
echo lang_string("N/A"); echo lang_string("N/A");
else { else {
@ -182,7 +182,7 @@ require ("include/functions_reporting.php");
echo " ($sla_min/$sla_max/$sla_limit) </td>"; echo " ($sla_min/$sla_max/$sla_limit) </td>";
echo "<td class='$tdcolor'>"; echo "<td class='$tdcolor'>";
$temp = return_module_SLA ($row_t["id_agente_modulo"], $config["sla_period"], $sla_min, $sla_max); $temp = get_agent_module_sla ($row_t["id_agente_modulo"], $config["sla_period"], $sla_min, $sla_max);
if ($temp === false){ if ($temp === false){
echo lang_string("N/A"); echo lang_string("N/A");
echo "<td class='$tdcolor'>"; echo "<td class='$tdcolor'>";

View File

@ -33,7 +33,7 @@ if (! isset($_SESSION["id_usuario"])) {
<?php <?php
// Agent read, Server read // Agent read, Server read
if (give_acl($_SESSION["id_usuario"], 0, "AR")==1) { if (give_acl($_SESSION["id_usuario"], 0, "AR")) {
if (isset($_GET["sec2"]) && $_GET["sec2"] == "operation/agentes/tactical") { if (isset($_GET["sec2"]) && $_GET["sec2"] == "operation/agentes/tactical") {
echo '<div id="op1s">'; echo '<div id="op1s">';
} else { } else {
@ -187,7 +187,7 @@ if (give_acl($_SESSION["id_usuario"], 0, "AR")==1) {
echo '<ul class="mn"><li><a href="index.php?sec=usuarios&amp;sec2=operation/users/user" class="mn">'.lang_string ("view_users").'</a></li></ul></div>'; echo '<ul class="mn"><li><a href="index.php?sec=usuarios&amp;sec2=operation/users/user" class="mn">'.lang_string ("view_users").'</a></li></ul></div>';
// User edit (submenu) // User edit (submenu)
if (isset($_GET["sec"]) && $_GET["sec"] == "usuarios"){ if (isset($_GET["sec"]) && $_GET["sec"] == "usuarios") {
if(isset($_GET["ver"]) && $_GET["ver"] == $_SESSION["id_usuario"]) { if(isset($_GET["ver"]) && $_GET["ver"] == $_SESSION["id_usuario"]) {
echo "<div class='arrows'>"; echo "<div class='arrows'>";
} else { } else {
@ -195,15 +195,15 @@ if (give_acl($_SESSION["id_usuario"], 0, "AR")==1) {
} }
echo "<ul class='mn'><li><a href='index.php?sec=usuarios&amp;sec2=operation/users/user_edit&amp;ver=".$_SESSION["id_usuario"]."' class='mn'>".lang_string ("index_myuser")."</a></li></ul></div>"; echo "<ul class='mn'><li><a href='index.php?sec=usuarios&amp;sec2=operation/users/user_edit&amp;ver=".$_SESSION["id_usuario"]."' class='mn'>".lang_string ("index_myuser")."</a></li></ul></div>";
// User statistics require UM // User statistics require UM
if (give_acl($_SESSION["id_usuario"], 0, "UM")==1) { if (give_acl($_SESSION["id_usuario"], 0, "UM")==1) {
if(isset($_GET["sec2"]) && $_GET["sec2"] == "operation/users/user_statistics") { if(isset($_GET["sec2"]) && $_GET["sec2"] == "operation/users/user_statistics") {
echo "<div class='arrows'>"; echo "<div class='arrows'>";
} else { } else {
echo "<div class='arrow'>"; echo "<div class='arrow'>";
} }
echo "<ul class='mn'><li><a href='index.php?sec=usuarios&amp;sec2=operation/users/user_statistics' class='mn'>".lang_string ("statistics")."</a></li></ul></div>"; echo "<ul class='mn'><li><a href='index.php?sec=usuarios&amp;sec2=operation/users/user_statistics' class='mn'>".lang_string ("statistics")."</a></li></ul></div>";
} }
} }
// SNMP console // SNMP console

View File

@ -57,8 +57,8 @@ foreach ($reports as $report) {
$data[1] = $report['description']; $data[1] = $report['description'];
$data[2] = '<a href="index.php?sec=reporting&sec2=operation/reporting/reporting_viewer&id='.$report['id_report'].'"> $data[2] = '<a href="index.php?sec=reporting&sec2=operation/reporting/reporting_viewer&id='.$report['id_report'].'">
<img src="images/reporting.png"></a>'; <img src="images/reporting.png"></a>';
$data[3] = '<a href="operation/reporting/reporting_viewer_pdf.php?id='.$report['id_report'].'&rtype=general" $data[3] = '<a href="operation/reporting/reporting_viewer_pdf.php?id_report='.$report['id_report'].'" '.
target="_new"><img src="images/pdf.png"></a>'; 'target="_new"><img src="images/pdf.png"></a>';
array_push ($table->data, $data); array_push ($table->data, $data);
} }

View File

@ -57,7 +57,7 @@ echo "<h2>".lang_string ('reporting')." &gt; ";
echo lang_string ('custom_reporting')." - "; echo lang_string ('custom_reporting')." - ";
echo $report['name']."</h2>"; echo $report['name']."</h2>";
$table->width = '750px'; $table->width = '99%';
$table->class = 'databox'; $table->class = 'databox';
$table->style = array (); $table->style = array ();
$table->style[0] = 'font-weight: bold'; $table->style[0] = 'font-weight: bold';
@ -115,15 +115,19 @@ if ($datetime > time ()) {
$table->size = array (); $table->size = array ();
$table->style = array (); $table->style = array ();
$table->width = '750px'; $table->width = '99%';
$table->class = 'databox report_table'; $table->class = 'databox report_table';
$table->rowclasses = array (); $table->rowclass = array ();
$table->rowclass[0] = 'datos3';
$group_name = dame_grupo ($report['id_group']); $group_name = dame_grupo ($report['id_group']);
$sql = sprintf ('SELECT * FROM treport_content WHERE id_report = %d ORDER BY `order`', $id_report); $sql = sprintf ('SELECT * FROM treport_content WHERE id_report = %d ORDER BY `order`', $id_report);
$contents = get_db_all_rows_sql ($sql); $contents = get_db_all_rows_sql ($sql);
foreach ($contents as $content) { foreach ($contents as $content) {
$table->data = array (); $table->data = array ();
$table->head = array ();
$table->style = array ();
$table->colspan = array ();
$module_name = get_db_value ('nombre', 'tagente_modulo', 'id_agente_modulo', $content['id_agent_module']); $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']); $agent_name = dame_nombre_agente_agentemodulo ($content['id_agent_module']);
@ -131,16 +135,13 @@ foreach ($contents as $content) {
switch ($content["type"]) { switch ($content["type"]) {
case 1: case 1:
case 'simple_graph': case 'simple_graph':
$table->colspan[1][0] = 3; $table->colspan[1][0] = 4;
$data = array (); $data = array ();
$data[0] = '<h4>'.lang_string ('simple_graph').'</h4>'; $data[0] = '<h4>'.lang_string ('simple_graph').'</h4>';
$data[1] = '<h4>'.$agent_name.' - '.$module_name.'</h4>'; $data[1] = '<h4>'.$agent_name.' - '.$module_name.'</h4>';
$data[2] = '<h4>'.human_time_description($content['period']).'</h4>'; $data[2] = '<h4>'.human_time_description($content['period']).'</h4>';
$n = array_push ($table->data, $data); 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 = 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="">'; $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); array_push ($table->data, $data);
@ -148,63 +149,59 @@ foreach ($contents as $content) {
break; break;
case 2: case 2:
case 'custom_graph': 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;
}
}
unset ($modules);
unset ($weights);
$data = array (); $data = array ();
$data[0] = '<h4>'.lang_string ('custom_graph').'</h4>'; $data[0] = '<h4>'.lang_string ('custom_graph').'</h4>';
$data[1] = "<h4>".$graph["name"]."</h4>"; $data[1] = "<h4>".$graph["name"]."</h4>";
$data[2] = "<h4>".human_time_description($content['period'])."</h4>"; $data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data); array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$table->colspan[$n][0] = 3; $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);
$modules = array ();
$weights = array ();
while ($content2 = mysql_fetch_array($res2)) {
array_push ($modules, $content2['id_agent_module']);
array_push ($weights, $content2["weight"]);
}
$table->colspan[1][0] = 4;
$data = array (); $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="">'; $data[0] = '<img src="reporting/fgraph.php?tipo=combined&id='.implode (',', $modules).'&weight_l='.implode (',', $weights).'&height=230&width=720&period='.$content['period'].'&date='.$datetime.'&stacked='.$graph["stacked"].'&pure=1" border="1" alt="">';
array_push ($table->data, $data); array_push ($table->data, $data);
break; break;
case 3: case 3:
case 'SLA': case 'SLA':
$table->colspan[0][0] = 2;
$table->style[1] = 'text-align: right';
$data = array (); $data = array ();
$data[0] = '<h4>'.lang_string ('SLA').'</h4>'; $data[0] = '<h4>'.lang_string ('SLA').'</h4>';
$data[1] = '<h4>'.$group_name.'</h4>'; $data[1] = '<h4>'.human_time_description ($content['period']).'</h4>';;
$data[2] = '<h4>'.human_time_description ($content['period']).'</h4>';
$n = array_push ($table->data, $data); $n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$slas = get_db_all_rows_field_filter ('treport_content_sla_combined', $slas = get_db_all_rows_field_filter ('treport_content_sla_combined',
'id_report_content', $content['id_rc']); 'id_report_content', $content['id_rc']);
if (sizeof ($slas) == 0) { if (sizeof ($slas) == 0) {
$data = array (); $data = array ();
$table->colspan[$n][0] = 3; $table->colspan[1][0] = 3;
$data[0] = lang_string ('no_defined_slas'); $data[0] = lang_string ('no_defined_slas');
array_push ($table->data, $data); array_push ($table->data, $data);
} }
$sla_failed = false;
foreach ($slas as $sla) { foreach ($slas as $sla) {
$data = array (); $data = array ();
$table->colspan[$n][0] = 2; $table->colspan[$n][0] = 2;
$data[0] = '<span style="font-size: 0.6em">'; $data[0] = '<span style="font-size: 0.6em">';
$data[0] .= lang_string ('sla_max')." : ".$sla['sla_max']."<br>"; $data[0] .= lang_string ('agent')." : ".dame_nombre_agente_agentemodulo ($sla['id_agent_module'])."<br />";
$data[0] .= lang_string ('sla_min')." : ".$sla['sla_min']."<br>"; $data[0] .= lang_string ('module')." : ".dame_nombre_modulo_agentemodulo ($sla['id_agent_module'])."<br />";
$data[0] .= lang_string ('sla_limit')." : ".$sla['sla_limit']."<br>"; $data[0] .= lang_string ('sla_max')." : ".$sla['sla_max']."<br />";
$data[0] .= lang_string ('sla_min')." : ".$sla['sla_min']."<br />";
$data[0] .= "</span>"; $data[0] .= "</span>";
$sla_value = return_module_SLA ($sla['id_agent_module'], $content['period'], $sla_value = get_agent_module_sla ($sla['id_agent_module'], $content['period'],
$sla['sla_min'], $sla['sla_max'], $datetime); $sla['sla_min'], $sla['sla_max'], $datetime);
if ($sla_value === false) { if ($sla_value === false) {
$data[1] = '<span style="font: bold 3em Arial, Sans-serif; color: #0000FF;">'; $data[1] = '<span style="font: bold 3em Arial, Sans-serif; color: #0000FF;">';
@ -212,29 +209,43 @@ foreach ($contents as $content) {
} else { } else {
if ($sla_value >= $sla['sla_limit']) if ($sla_value >= $sla['sla_limit'])
$data[1] = '<span style="font: bold 3em Arial, Sans-serif; color: #000000;">'; $data[1] = '<span style="font: bold 3em Arial, Sans-serif; color: #000000;">';
else else {
$sla_failed = true;
$data[1] = '<span style="font: bold 3em Arial, Sans-serif; color: #ff0000;">'; $data[1] = '<span style="font: bold 3em Arial, Sans-serif; color: #ff0000;">';
}
$data[1] .= format_numeric ($sla_value). " %"; $data[1] .= format_numeric ($sla_value). " %";
} }
$data[1] .= "</span>"; $data[1] .= "</span>";
$n = array_push ($table->data, $data); $n = array_push ($table->data, $data);
} }
if (sizeof ($slas)) {
$data = array ();
if ($sla_failed)
$data[0] = '<span style="font: bold 3em Arial, Sans-serif; color: #000000;">'.lang_string ('Ok').'</span>';
else
$data[0] = '<span style="font: bold 3em Arial, Sans-serif; color: #ff0000;">'.lang_string ('Fail').'</span>';
$n = array_push ($table->data, $data);
$table->colspan[$n - 1][0] = 3;
$table->rowstyle[$n - 1] = 'text-align: right';
}
break; break;
case 4: case 4:
case 'event_report': case 'event_report':
$table->colspan[0][0] = 2;
$id_agent = dame_agente_id ($agent_name); $id_agent = dame_agente_id ($agent_name);
$data = array (); $data = array ();
$data[0] = "<h4>".lang_string ('event_report')."</h4>"; $data[0] = "<h4>".lang_string ('event_report')."</h4>";
$data[1] = "<h4>$agent_name - $module_name</h4>"; $data[1] = "<h4>".human_time_description ($content['period'])."</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>"; array_push ($table->data, $data);
$n = array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$table->colspan[$n][0] = 3; $table->colspan[1][0] = 3;
$data = array (); $data = array ();
$data[0] = event_reporting ($id_agent, $content['period'], $datetime, true); $table_report = event_reporting ($report['id_group'], $content['period'], $datetime, true);
$table_report->class = 'databox';
$table_report->width = '100%';
$data[0] = print_table ($table_report, true);
array_push ($table->data, $data); array_push ($table->data, $data);
break; break;
@ -244,11 +255,10 @@ foreach ($contents as $content) {
$data[0] = "<h4>".lang_string ('alert_report')."</h4>"; $data[0] = "<h4>".lang_string ('alert_report')."</h4>";
$data[1] = "<h4>$group_name</h4>"; $data[1] = "<h4>$group_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>"; $data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data); array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array (); $data = array ();
$table->colspan[$n][0] = 3; $table->colspan[1][0] = 3;
$data[0] = alert_reporting ($report['id_group'], $content['period'], $datetime, true); $data[0] = alert_reporting ($report['id_group'], $content['period'], $datetime, true);
array_push ($table->data, $data); array_push ($table->data, $data);
@ -259,11 +269,10 @@ foreach ($contents as $content) {
$data[0] = "<h4>".lang_string ('monitor_report')."</h4>"; $data[0] = "<h4>".lang_string ('monitor_report')."</h4>";
$data[1] = "<h4>$agent_name - $module_name</h4>"; $data[1] = "<h4>$agent_name - $module_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>"; $data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data); array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array (); $data = array ();
$monitor_value = format_numeric (return_module_SLA ($content['id_agent_module'], $content['period'], 1, 1, $datetime)); $monitor_value = format_numeric (get_agent_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] = '<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>'; $data[0] .= $monitor_value.' % <img src="images/b_green.png" height="32" width="32"></p>';
$monitor_value2 = format_numeric (100 - $monitor_value, 2) ; $monitor_value2 = format_numeric (100 - $monitor_value, 2) ;
@ -278,12 +287,11 @@ foreach ($contents as $content) {
$data[0] = "<h4>".lang_string ('avg_value')."</h4>"; $data[0] = "<h4>".lang_string ('avg_value')."</h4>";
$data[1] = "<h4>$agent_name - $module_name</h4>"; $data[1] = "<h4>$agent_name - $module_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>"; $data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data); array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array (); $data = array ();
$table->colspan[$n][0] = 2; $table->colspan[1][0] = 2;
$value = format_numeric (return_moduledata_avg_value ($content['id_agent_module'], $content['period'], $datetime)); $value = format_numeric (get_agent_module_value_average ($content['id_agent_module'], $content['period'], $datetime));
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>'; $data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
array_push ($table->data, $data); array_push ($table->data, $data);
@ -294,12 +302,11 @@ foreach ($contents as $content) {
$data[0] = "<h4>".lang_string ('max_value')."</h4>"; $data[0] = "<h4>".lang_string ('max_value')."</h4>";
$data[1] = "<h4>$agent_name - $module_name</h4>"; $data[1] = "<h4>$agent_name - $module_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>"; $data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data); array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array (); $data = array ();
$table->colspan[$n][0] = 2; $table->colspan[1][0] = 2;
$value = format_numeric (return_moduledata_max_value ($content['id_agent_module'], $content['period'], $datetime)); $value = format_numeric (get_agent_module_value_max ($content['id_agent_module'], $content['period'], $datetime));
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>'; $data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
array_push ($table->data, $data); array_push ($table->data, $data);
@ -310,12 +317,11 @@ foreach ($contents as $content) {
$data[0] = "<h4>".lang_string ('min_value')."</h4>"; $data[0] = "<h4>".lang_string ('min_value')."</h4>";
$data[1] = "<h4>$agent_name - $module_name</h4>"; $data[1] = "<h4>$agent_name - $module_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>"; $data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data); array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array (); $data = array ();
$table->colspan[$n][0] = 2; $table->colspan[1][0] = 2;
$value = format_numeric (return_moduledata_min_value ($content['id_agent_module'], $content['period'], $datetime)); $value = format_numeric (get_agent_module_value_min ($content['id_agent_module'], $content['period'], $datetime));
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>'; $data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
array_push ($table->data, $data); array_push ($table->data, $data);
@ -326,12 +332,11 @@ foreach ($contents as $content) {
$data[0] = "<h4>".lang_string ('sumatory')."</h4>"; $data[0] = "<h4>".lang_string ('sumatory')."</h4>";
$data[1] = "<h4>$agent_name - $module_name</h4>"; $data[1] = "<h4>$agent_name - $module_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>"; $data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data); array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array (); $data = array ();
$table->colspan[$n][0] = 2; $table->colspan[1][0] = 2;
$value = format_numeric (return_moduledata_sum_value ($content['id_agent_module'], $content['period'], $datetime)); $value = format_numeric (get_agent_module_value_sumatory ($content['id_agent_module'], $content['period'], $datetime));
$data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>'; $data[0] = '<p style="font: bold 3em Arial, Sans-serif; color: #000000;">'.$value.'</p>';
array_push ($table->data, $data); array_push ($table->data, $data);
@ -341,12 +346,10 @@ foreach ($contents as $content) {
$data = array (); $data = array ();
$data[0] = "<h4>".lang_string ('group')."</h4>"; $data[0] = "<h4>".lang_string ('group')."</h4>";
$data[1] = "<h4>$group_name</h4>"; $data[1] = "<h4>$group_name</h4>";
$n = array_push ($table->data, $data); array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array (); $data = array ();
$table->colspan[$n][0] = 2; $table->colspan[1][0] = 2;
$value = format_numeric (return_moduledata_sum_value ($content['id_agent_module'], $content['period'], $datetime));
$data[0] = general_group_reporting ($report['id_group'], true); $data[0] = general_group_reporting ($report['id_group'], true);
array_push ($table->data, $data); array_push ($table->data, $data);
@ -357,11 +360,10 @@ foreach ($contents as $content) {
$data[0] = "<h4>".lang_string ('monitor_health')."</h4>"; $data[0] = "<h4>".lang_string ('monitor_health')."</h4>";
$data[1] = "<h4>$group_name</h4>"; $data[1] = "<h4>$group_name</h4>";
$data[2] = "<h4>".human_time_description ($content['period'])."</h4>"; $data[2] = "<h4>".human_time_description ($content['period'])."</h4>";
$n = array_push ($table->data, $data); array_push ($table->data, $data);
$table->rowclass[$n - 1] = 'datos3';
$data = array (); $data = array ();
$table->colspan[$n][0] = 3; $table->colspan[1][0] = 4;
$data[0] = monitor_health_reporting ($report['id_group'], $content['period'], $datetime, true); $data[0] = monitor_health_reporting ($report['id_group'], $content['period'], $datetime, true);
array_push ($table->data, $data); array_push ($table->data, $data);
@ -371,13 +373,12 @@ foreach ($contents as $content) {
$data = array (); $data = array ();
$data[0] = "<h4>".lang_string ('agents_detailed')."</h4>"; $data[0] = "<h4>".lang_string ('agents_detailed')."</h4>";
$data[1] = "<h4>$group_name</h4>"; $data[1] = "<h4>$group_name</h4>";
$data[2] = ""; array_push ($table->data, $data);
$n = array_push ($table->data, $data); $table->colspan[0][0] = 2;
$table->rowclass[$n - 1] = 'datos3';
$data = array (); $data = array ();
$table->colspan[$n][0] = 3; $table->colspan[1][0] = 3;
$data[0] = agents_detailed_reporting ($report['id_group'], $content['period'], $datetime, true); $data[0] = get_agents_detailed_reporting ($report['id_group'], $content['period'], $datetime, true);
array_push ($table->data, $data); array_push ($table->data, $data);
break; break;

View File

@ -24,9 +24,9 @@ require_once ("../../include/functions_db.php");
require_once ("../../include/languages/language_".$config["language"].".php"); require_once ("../../include/languages/language_".$config["language"].".php");
require_once ("../../include/functions_reporting_pdf.php"); require_once ("../../include/functions_reporting_pdf.php");
if (!isset ($_SESSION["id_usuario"])) { if (! isset ($_SESSION["id_usuario"])) {
session_start(); session_start ();
session_write_close(); session_write_close ();
} }
// Session check // Session check
@ -34,44 +34,38 @@ check_login ();
// Login check // Login check
global $REMOTE_ADDR; global $REMOTE_ADDR;
$config['id_user'] = $_SESSION["id_usuario"];
if (comprueba_login ()) { if (comprueba_login ()) {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access graph builder"); audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation", "Trying to access graph builder");
include ("general/noaccess.php"); include ("general/noaccess.php");
exit; exit;
} }
if (! give_acl ($id_user, 0, "AR") && ! dame_admin ($id_user)) { if (! give_acl ($config["id_user"], 0, "AR") && ! dame_admin ($config["id_user"])) {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access graph builder"); audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation", "Trying to access graph builder");
include ("general/noaccess.php"); include ("general/noaccess.php");
exit; exit;
} }
$id_report = (int) get_parameter ('id'); $id_report = (int) get_parameter ('id_report');
if (! $id_report) { if (! $id_report) {
audit_db ($id_user, $REMOTE_ADDR, "HACK Attempt", "Trying to access graph viewer withoud ID"); audit_db ($config["id_user"], $REMOTE_ADDR, "HACK Attempt", "Trying to access graph viewer withoud ID");
include ("general/noaccess.php"); include ("general/noaccess.php");
exit; exit;
} }
$report_private= get_db_value ("private", "treport", "id_report", $id_report); $report = get_db_row ("treport", "id_report", $id_report);
$report_user = get_db_value ("id_user", "treport", "id_report", $id_report);
if ($report_user == $id_user || dame_admin ($id_user) || ! $report_private) { if ($report['id_user'] != $config["id_user"] && ! give_acl ($config["id_user"], $report['id_group'], 'AR')) {
$report_type = get_parameter ("rtype"); echo "<h2>No access without report type</h2>";
// Without report type parameter: ABORT audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation", "Trying to access unauthorized report");
if (! $report_type) { exit;
echo "<h2>No access without report type</h2>";
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access report without specify reportype");
exit;
}
// Available PDF reports:
switch ($report_type) {
case "general":
general_report ($id_report);
break;
}
} }
include ('../../include/pdf/class.ezpdf.php');
require ('../../include/functions_reporting.php');
get_pdf_report ($report);
?> ?>

View File

@ -16,10 +16,10 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
include ('../include/config.php'); require_once ('../include/config.php');
include ($config["homedir"].'/include/functions.php'); require_once ($config["homedir"].'/include/functions.php');
include ($config["homedir"].'/include/functions_db.php'); require_once ($config["homedir"].'/include/functions_db.php');
require ($config["homedir"].'/include/languages/language_'.$config['language'].'.php'); require_once ('Image/Graph.php');
global $config; global $config;
@ -27,7 +27,7 @@ if (!isset($_SESSION["id_user"])){
session_start(); session_start();
session_write_close(); session_write_close();
} }
$config ["id_user"] = $_SESSION["id_usuario"]; $config["id_user"] = $_SESSION["id_usuario"];
// Session check // Session check
check_login (); check_login ();
@ -92,8 +92,8 @@ function dame_fecha_grafico_timestamp ($timestamp) {
function graphic_combined_module ($module_list, $weight_list, $periodo, $width, $height, function graphic_combined_module ($module_list, $weight_list, $periodo, $width, $height,
$title, $unit_name, $show_event = 0, $show_alert = 0, $pure = 0, $stacked = 0, $date = 0) { $title, $unit_name, $show_event = 0, $show_alert = 0, $pure = 0, $stacked = 0, $date = 0) {
include ("../include/config.php"); global $config;
require ("../include/languages/language_".$config['language'].".php");
require_once 'Image/Graph.php'; require_once 'Image/Graph.php';
$resolution = $config['graph_res'] * 50; // Number of "slices" we want in graph $resolution = $config['graph_res'] * 50; // Number of "slices" we want in graph
@ -375,7 +375,6 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event, function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event,
$width, $height , $title, $unit_name, $show_alert, $avg_only = 0, $pure = 0, $date = 0) { $width, $height , $title, $unit_name, $show_alert, $avg_only = 0, $pure = 0, $date = 0) {
include ("../include/config.php"); include ("../include/config.php");
require ("../include/languages/language_".$config['language'].".php");
require_once 'Image/Graph.php'; require_once 'Image/Graph.php';
if (! $date) if (! $date)
@ -661,9 +660,8 @@ function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event,
} }
function generic_pie_graph ($width = 300, $height = 200, $data, $legend) { function generic_pie_graph ($width = 300, $height = 200, $data, $legend) {
require ("../include/config.php"); global $config;
require_once 'Image/Graph.php';
require ("../include/languages/language_".$config['language'].".php");
if (sizeof($data) == 0) { if (sizeof($data) == 0) {
graphic_error (); graphic_error ();
return; return;
@ -723,9 +721,7 @@ function generic_pie_graph ($width = 300, $height = 200, $data, $legend) {
function graphic_agentmodules($id_agent, $width, $height) { function graphic_agentmodules($id_agent, $width, $height) {
include ("../include/config.php"); global $config;
require_once 'Image/Graph.php';
require ("../include/languages/language_".$config['language'].".php");
$sql1="SELECT * FROM ttipo_modulo"; $sql1="SELECT * FROM ttipo_modulo";
$result=mysql_query($sql1); $result=mysql_query($sql1);
@ -771,9 +767,8 @@ function graphic_agentmodules($id_agent, $width, $height) {
} }
function graphic_agentaccess ($id_agent, $periodo, $width, $height) { function graphic_agentaccess ($id_agent, $periodo, $width, $height) {
include ("../include/config.php"); global $config;
require_once 'Image/Graph.php';
require ("../include/languages/language_".$config['language'].".php");
$color ="#437722"; // Green pandora 1.1 octopus color $color ="#437722"; // Green pandora 1.1 octopus color
/* /*
$agent_interval = give_agentinterval($id_agent); $agent_interval = give_agentinterval($id_agent);
@ -865,9 +860,8 @@ function graphic_agentaccess ($id_agent, $periodo, $width, $height) {
} }
function graphic_string_data ($id_agent_module, $periodo, $width, $height, $pure = 0, $date = "") { function graphic_string_data ($id_agent_module, $periodo, $width, $height, $pure = 0, $date = "") {
include ("../include/config.php"); global $config;
require_once 'Image/Graph.php';
require ("../include/languages/language_".$config['language'].".php");
// $color = $config["color_graph1"]; //#437722"; // Green pandora 1.1 octopus color // $color = $config["color_graph1"]; //#437722"; // Green pandora 1.1 octopus color
$color = "#437722"; $color = "#437722";
@ -907,44 +901,44 @@ function graphic_string_data ($id_agent_module, $periodo, $width, $height, $pure
$valor_maximo = $valores[$i][0]; $valor_maximo = $valores[$i][0];
} }
if ($valor_maximo <= 0) { if ($valor_maximo <= 0) {
graphic_error (); graphic_error ();
return; return;
} }
$nombre_agente = dame_nombre_agente_agentemodulo ($id_agent_module); $nombre_agente = dame_nombre_agente_agentemodulo ($id_agent_module);
$id_agente = dame_agente_id ($nombre_agente); $id_agente = dame_agente_id ($nombre_agente);
$nombre_modulo = dame_nombre_modulo_agentemodulo ($id_agent_module); $nombre_modulo = dame_nombre_modulo_agentemodulo ($id_agent_module);
if ($pure == 0){ if ($pure == 0) {
$Graph =& Image_Graph::factory('graph', array($width, $height)); $Graph =& Image_Graph::factory('graph', array($width, $height));
// add a TrueType font // add a TrueType font
$Font =& $Graph->addNew('font', $config['fontpath']); $Font =& $Graph->addNew('font', $config['fontpath']);
$Font->setSize(7); $Font->setSize(7);
$Graph->setFont($Font); $Graph->setFont($Font);
$Graph->add( $Graph->add(
Image_Graph::vertical(
Image_Graph::vertical( Image_Graph::vertical(
$Title = Image_Graph::factory('title', array(' Pandora FMS Graph - '.strtoupper($nombre_agente)." - ".give_human_time ($periodo), 10)), Image_Graph::vertical(
$Subtitle = Image_Graph::factory('title', array(' '.lang_string("Data occurrence for module ").$nombre_modulo, 7)), $Title = Image_Graph::factory('title', array(' Pandora FMS Graph - '.strtoupper($nombre_agente)." - ".give_human_time ($periodo), 10)),
90 $Subtitle = Image_Graph::factory('title', array(' '.lang_string("Data occurrence for module ").$nombre_modulo, 7)),
), 90
Image_Graph::horizontal( ),
$Plotarea = Image_Graph::factory('plotarea'), Image_Graph::horizontal(
$Legend = Image_Graph::factory('legend'), $Plotarea = Image_Graph::factory('plotarea'),
100 $Legend = Image_Graph::factory('legend'),
), 100
15) ),
); 15)
$Legend->setPlotarea($Plotarea); );
$Title->setAlignment(IMAGE_GRAPH_ALIGN_LEFT); $Legend->setPlotarea($Plotarea);
$Subtitle->setAlignment(IMAGE_GRAPH_ALIGN_LEFT); $Title->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
$Subtitle->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
} else { // Pure, without title and legends } else { // Pure, without title and legends
$Graph->add($Plotarea = Image_Graph::factory('plotarea')); $Graph->add($Plotarea = Image_Graph::factory('plotarea'));
} }
//$Legend->setPlotarea($Plotarea); //$Legend->setPlotarea($Plotarea);
// Create the dataset // Create the dataset
@ -968,9 +962,6 @@ if ($pure == 0){
function grafico_incidente_estados() { function grafico_incidente_estados() {
include ("../include/config.php");
require ("../include/languages/language_".$config['language'].".php");
$data = array(0,0,0,0); $data = array(0,0,0,0);
// 0 - Abierta / Sin notas // 0 - Abierta / Sin notas
// 2 - Descartada // 2 - Descartada
@ -1001,29 +992,18 @@ function grafico_incidente_estados() {
} }
function grafico_incidente_prioridad () { function grafico_incidente_prioridad () {
include ("../include/config.php"); $data = array (0, 0, 0, 0, 0, 0);
require ("../include/languages/language_".$config['language'].".php");
$data = array(0,0,0,0,0,0);
// 0 - Abierta / Sin notas // 0 - Abierta / Sin notas
// 2 - Descartada // 2 - Descartada
// 3 - Caducada // 3 - Caducada
// 13 - Cerrada // 13 - Cerrada
$sql1="SELECT * FROM tincidencia"; $sql = "SELECT * FROM tincidencia";
$result=mysql_query($sql1); $result = mysql_query ($sql);
while ($row=mysql_fetch_array($result)){ while ($row = mysql_fetch_array ($result)){
if ($row["prioridad"] == 0) if ($row["prioridad"] < 10)
$data[0]=$data[0]+1; $data[$row["prioridad"]] += 1;
if ($row["prioridad"] == 1) else
$data[1]=$data[1]+1; $data[5] += 1;
if ($row["prioridad"] == 2)
$data[2]=$data[2]+1;
if ($row["prioridad"] == 3)
$data[3]=$data[3]+1;
if ($row["prioridad"] == 4)
$data[4]=$data[4]+1;
if ($row["prioridad"] == 10)
$data[5]=$data[5]+1;
} }
$mayor = 0; $mayor = 0;
@ -1033,26 +1013,28 @@ function grafico_incidente_prioridad () {
$mayor = $i; $mayor = $i;
$mayor_data = $data[$i]; $mayor_data = $data[$i];
} }
$legend = array ("Informative","Low","Medium","Serious", "Very serious", "Maintance"); $legend = array (lang_string ("Informative"),
lang_string ("Low"),
lang_string ("Medium"),
lang_string ("Serious"),
lang_string ("Very serious"),
lang_string ("Maintance"));
generic_pie_graph (320, 200, $data, $legend); generic_pie_graph (320, 200, $data, $legend);
} }
function graphic_incident_group() { function graphic_incident_group () {
include ("../include/config.php");
require ("../include/languages/language_".$config['language'].".php");
$data = array(); $data = array();
$legend = array(); $legend = array();
$sql1="SELECT distinct id_grupo FROM tincidencia "; $sql = "SELECT distinct id_grupo FROM tincidencia ";
$result=mysql_query($sql1); $result = mysql_query ($sql);
while ($row=mysql_fetch_array($result)){ while ($row = mysql_fetch_array($result)) {
$sql1="SELECT COUNT(id_incidencia) FROM tincidencia WHERE id_grupo = ".$row[0]; $sql="SELECT COUNT(id_incidencia) FROM tincidencia WHERE id_grupo = ".$row[0];
$result2=mysql_query($sql1); $result2=mysql_query ($sql);
$row2=mysql_fetch_array($result2); $row2 = mysql_fetch_array($result2);
$data[] = $row2[0]; $data[] = $row2[0];
$legend[] = dame_nombre_grupo($row[0])."(".$row2[0].")"; $legend[] = dame_nombre_grupo($row[0])."(".$row2[0].")";
} }
// Sort array by bubble method (yes, I study more methods in university, but if you want more speed, please, submit a patch :) // Sort array by bubble method (yes, I study more methods in university, but if you want more speed, please, submit a patch :)
// or much better, pay me to do a special version for you, highly optimized :-)))) // or much better, pay me to do a special version for you, highly optimized :-))))
for ($i = 0; $i < sizeof($data); $i++) { for ($i = 0; $i < sizeof($data); $i++) {
for ($j = $i; $j <sizeof($data); $j++) for ($j = $i; $j <sizeof($data); $j++)
@ -1077,9 +1059,6 @@ function graphic_incident_group() {
} }
function graphic_incident_user() { function graphic_incident_user() {
include ("../include/config.php");
require ("../include/languages/language_".$config['language'].".php");
$data = array(); $data = array();
$legend = array(); $legend = array();
$sql1="SELECT distinct id_usuario FROM tincidencia "; $sql1="SELECT distinct id_usuario FROM tincidencia ";
@ -1115,10 +1094,7 @@ function graphic_incident_user() {
generic_pie_graph (320, 200, $data, $legend); generic_pie_graph (320, 200, $data, $legend);
} }
function graphic_user_activity($width=350, $height=230) { function graphic_user_activity ($width = 350, $height = 230) {
include ("../include/config.php");
require ("../include/languages/language_".$config['language'].".php");
$data = array(); $data = array();
$legend = array(); $legend = array();
$sql1="SELECT DISTINCT ID_usuario FROM tsesion "; $sql1="SELECT DISTINCT ID_usuario FROM tsesion ";
@ -1158,9 +1134,6 @@ function graphic_user_activity($width=350, $height=230) {
} }
function graphic_incident_source ($width=320, $height=200) { function graphic_incident_source ($width=320, $height=200) {
include ("../include/config.php");
require ("../include/languages/language_".$config['language'].".php");
$data = array(); $data = array();
$legend = array(); $legend = array();
$sql1="SELECT DISTINCT origen FROM tincidencia"; $sql1="SELECT DISTINCT origen FROM tincidencia";
@ -1197,9 +1170,6 @@ function graphic_incident_source ($width=320, $height=200) {
} }
function grafico_db_agentes_modulos($width, $height) { function grafico_db_agentes_modulos($width, $height) {
include ("../include/config.php");
require ("../include/languages/language_".$config['language'].".php");
$data = array(); $data = array();
$legend = array(); $legend = array();
$sql1="SELECT * FROM tagente"; $sql1="SELECT * FROM tagente";
@ -1228,9 +1198,6 @@ function grafico_db_agentes_modulos($width, $height) {
} }
function grafico_eventos_usuario( $width=420, $height=200) { function grafico_eventos_usuario( $width=420, $height=200) {
include ("../include/config.php");
require ("../include/languages/language_".$config['language'].".php");
$data = array(); $data = array();
$legend = array(); $legend = array();
$sql1="SELECT * FROM tusuario"; $sql1="SELECT * FROM tusuario";
@ -1269,10 +1236,7 @@ function grafico_eventos_usuario( $width=420, $height=200) {
} }
function grafico_eventos_total ($filter = "") { function grafico_eventos_total ($filter = "") {
require ("../include/config.php"); $filter = str_replace ( "\\" , "", $filter);
require ("../include/languages/language_".$config['language'].".php");
$filter = str_replace ( "\\" , "", $filter);
$data = array(); $data = array();
$legend = array(); $legend = array();
$total = 0; $total = 0;
@ -1329,10 +1293,6 @@ function grafico_eventos_total ($filter = "") {
} }
function graph_event_module ($width = 300, $height = 200, $id_agent) { function graph_event_module ($width = 300, $height = 200, $id_agent) {
include ("../include/config.php");
require ("../include/languages/language_".$config['language'].".php");
global $config;
// Need ACL check // Need ACL check
$data = array(); $data = array();
$legend = array(); $legend = array();
@ -1385,10 +1345,8 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) {
function grafico_eventos_grupo ($width = 300, $height = 200, $url = "") { function grafico_eventos_grupo ($width = 300, $height = 200, $url = "") {
include ("../include/config.php");
require ("../include/languages/language_".$config['language'].".php");
global $config; global $config;
$url = str_replace ( "\\" , "", $url); $url = str_replace ( "\\" , "", $url);
$data = array(); $data = array();
$legend = array(); $legend = array();
@ -1441,9 +1399,7 @@ function grafico_eventos_grupo ($width = 300, $height = 200, $url = "") {
function generic_bar_graph ( $width =380, $height = 200, $data, $legend) { function generic_bar_graph ( $width =380, $height = 200, $data, $legend) {
include ("../include/config.php"); global $config;
require_once 'Image/Graph.php';
require ("../include/languages/language_".$config['language'].".php");
if (sizeof($data) > 10){ if (sizeof($data) > 10){
$height = sizeof($legend) * 20; $height = sizeof($legend) * 20;
@ -1480,9 +1436,6 @@ function generic_bar_graph ( $width =380, $height = 200, $data, $legend) {
} }
function grafico_db_agentes_paquetes ($width = 380, $height = 300) { function grafico_db_agentes_paquetes ($width = 380, $height = 300) {
include ("../include/config.php");
require ("../include/languages/language_".$config['language'].".php");
$data = array(); $data = array();
$legend = array(); $legend = array();
$sql1="SELECT distinct (id_agente) FROM tagente_datos"; $sql1="SELECT distinct (id_agente) FROM tagente_datos";
@ -1517,10 +1470,6 @@ function grafico_db_agentes_paquetes ($width = 380, $height = 300) {
} }
function grafico_db_agentes_purge ($id_agent, $width, $height) { function grafico_db_agentes_purge ($id_agent, $width, $height) {
include ("../include/config.php");
require_once 'Image/Graph.php';
require ("../include/languages/language_".$config['language'].".php");
if ($id_agent == 0) if ($id_agent == 0)
$id_agent = -1; $id_agent = -1;
// All data (now) // All data (now)
@ -1564,8 +1513,8 @@ function grafico_db_agentes_purge ($id_agent, $width, $height) {
} }
function drawWarning($width,$height) { function drawWarning($width,$height) {
include ("../include/config.php"); global $config;
require ("../include/languages/language_".$config['language'].".php");
if ($width == 0) { if ($width == 0) {
$width = 50; $width = 50;
} }
@ -1583,7 +1532,7 @@ function drawWarning($width,$height) {
ImageFilledRectangle($image,0,0,$width-1,$height-1,$back); ImageFilledRectangle($image,0,0,$width-1,$height-1,$back);
ImageRectangle($image,0,0,$width-1,$height-1,$border); ImageRectangle($image,0,0,$width-1,$height-1,$border);
ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $border, $config['fontpath'], $lang_label["no_data"]); ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $border, $config['fontpath'], lang_string ("no_data"));
imagePNG($image); imagePNG($image);
imagedestroy($image); imagedestroy($image);
} }
@ -1599,8 +1548,8 @@ function progress_bar ($progress, $width, $height, $mode = 1) {
// With some adds from sdonie at lgc dot com // With some adds from sdonie at lgc dot com
// Get from official documentation PHP.net website. Thanks guys :-) // Get from official documentation PHP.net website. Thanks guys :-)
function drawRating($rating, $width, $height, $mode) { function drawRating($rating, $width, $height, $mode) {
include ("../include/config.php"); global $config;
require ("../include/languages/language_".$config["language"].".php");
$rating = format_numeric($rating,1); $rating = format_numeric($rating,1);
if ($width == 0) { if ($width == 0) {
$width = 150; $width = 150;
@ -1672,8 +1621,7 @@ function progress_bar ($progress, $width, $height, $mode = 1) {
} }
function odo_tactic ($value1, $value2, $value3) { function odo_tactic ($value1, $value2, $value3) {
require_once 'Image/Graph.php'; global $config;
include ("../include/config.php");
// create the graph // create the graph
$driver=& Image_Canvas::factory('png',array('width'=>350,'height'=>260,'antialias' => 'driver')); $driver=& Image_Canvas::factory('png',array('width'=>350,'height'=>260,'antialias' => 'driver'));
@ -1773,9 +1721,7 @@ function odo_tactic ($value1, $value2, $value3) {
function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event, function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event,
$width, $height , $title, $unit_name, $show_alert, $avg_only = 0, $pure=0 ) { $width, $height , $title, $unit_name, $show_alert, $avg_only = 0, $pure=0 ) {
include ("../include/config.php"); global $config;
require ("../include/languages/language_".$config['language'].".php");
require_once 'Image/Graph.php';
$resolution = $config['graph_res'] * 50; // Number of "slices" we want in graph $resolution = $config['graph_res'] * 50; // Number of "slices" we want in graph
@ -1917,12 +1863,12 @@ function grafico_modulo_boolean ( $id_agente_modulo, $periodo, $show_event,
//echo $valores[$i][6]; //echo $valores[$i][6];
//echo "<br>"; //echo "<br>";
} }
//exit;
// Create graph // Create graph
// ************* // *************
$Graph =& Image_Graph::factory('graph', array($width, $height)); $Graph =& Image_Graph::factory('graph', array($width, $height));
// add a TrueType font // add a TrueType font
$Font =& $Graph->addNew('font', $config['fontpath']); $Font =& $Graph->addNew ('font', $config['fontpath']);
$Font->setSize(6); $Font->setSize(6);
$Graph->setFont($Font); $Graph->setFont($Font);
@ -2115,64 +2061,83 @@ if ($graphic_type) {
switch ($graphic_type) { switch ($graphic_type) {
case 'string': case 'string':
graphic_string_data ($id, $period, $width, $height, $date); graphic_string_data ($id, $period, $width, $height, $date);
break;
case 'sparse': case 'sparse':
grafico_modulo_sparse ($id, $period, $draw_events, $width, $height , $label, $unit_name, $draw_alerts, $avg_only, $pure, $date); grafico_modulo_sparse ($id, $period, $draw_events, $width, $height,
$label, $unit_name, $draw_alerts, $avg_only, $pure, $date);
break; break;
case "boolean": case "boolean":
grafico_modulo_boolean ($id, $period, $draw_events, $width, $height , $label, $unit_name, $draw_alerts, 1, $pure); grafico_modulo_boolean ($id, $period, $draw_events, $width, $height , $label, $unit_name, $draw_alerts, 1, $pure);
break; break;
case "estado_incidente": case "estado_incidente":
grafico_incidente_estados (); grafico_incidente_estados ();
break; break;
case "prioridad_incidente": case "prioridad_incidente":
grafico_incidente_prioridad (); grafico_incidente_prioridad ();
break; break;
case "db_agente_modulo": case "db_agente_modulo":
grafico_db_agentes_modulos($width, $height); grafico_db_agentes_modulos($width, $height);
break; break;
case "db_agente_paquetes": case "db_agente_paquetes":
grafico_db_agentes_paquetes($width, $height); grafico_db_agentes_paquetes($width, $height);
break; break;
case "db_agente_purge": case "db_agente_purge":
grafico_db_agentes_purge($id, $width, $height); grafico_db_agentes_purge($id, $width, $height);
break; break;
case "event_module": case "event_module":
graph_event_module ($width, $height, $id_agent); graph_event_module ($width, $height, $id_agent);
case "group_events": case "group_events":
grafico_eventos_grupo($width, $height); grafico_eventos_grupo($width, $height);
break; break;
case "user_events": case "user_events":
grafico_eventos_usuario($width, $height); grafico_eventos_usuario($width, $height);
break; break;
case "total_events": case "total_events":
grafico_eventos_total(); grafico_eventos_total();
break; break;
case "group_incident": case "group_incident":
graphic_incident_group(); graphic_incident_group();
break; break;
case "user_incident": case "user_incident":
graphic_incident_user(); graphic_incident_user();
break; break;
case "source_incident": case "source_incident":
graphic_incident_source(); graphic_incident_source();
break; break;
case "user_activity": case "user_activity":
graphic_user_activity($width,$height); graphic_user_activity($width,$height);
break; break;
case "agentaccess": case "agentaccess":
graphic_agentaccess ($_GET["id"], $_GET["periodo"], $width, $height); graphic_agentaccess ($_GET["id"], $_GET["periodo"], $width, $height);
break; break;
case "agentmodules": case "agentmodules":
graphic_agentmodules($_GET["id"], $width, $height); graphic_agentmodules($_GET["id"], $width, $height);
break; break;
//elseif ($_GET["tipo"] == "gdirect")
// graphic_test ($id, $period, $intervalo, $label, $width, $height);
case "progress": case "progress":
$percent = $_GET["percent"]; $percent = $_GET["percent"];
progress_bar ($percent,$width,$height, $mode); progress_bar ($percent,$width,$height, $mode);
break; break;
case "odo_tactic": case "odo_tactic":
odo_tactic ( $value1, $value2, $value3 ); odo_tactic ( $value1, $value2, $value3 );
break; break;
case "combined": case "combined":
// Split id to get all parameters // Split id to get all parameters
@ -2182,6 +2147,7 @@ if ($graphic_type) {
$weight_list = split (",", $weight_l); $weight_list = split (",", $weight_l);
graphic_combined_module ($module_list, $weight_list, $period, $width, $height, graphic_combined_module ($module_list, $weight_list, $period, $width, $height,
$label, $unit_name, $draw_events, $draw_alerts, $pure, $stacked, $date); $label, $unit_name, $draw_events, $draw_alerts, $pure, $stacked, $date);
break; break;
case "alerts_fired_pipe": case "alerts_fired_pipe":
$data = array (); $data = array ();
@ -2191,6 +2157,7 @@ if ($graphic_type) {
$legends[0] = lang_string ('fired_alerts'); $legends[0] = lang_string ('fired_alerts');
$legends[1] = lang_string ('not_fired_alerts'); $legends[1] = lang_string ('not_fired_alerts');
generic_pie_graph ($width, $height, $data, $legends); generic_pie_graph ($width, $height, $data, $legends);
break; break;
case 'monitors_health_pipe': case 'monitors_health_pipe':
$data = array (); $data = array ();
@ -2200,6 +2167,7 @@ if ($graphic_type) {
$legends[0] = lang_string ('monitors_ok'); $legends[0] = lang_string ('monitors_ok');
$legends[1] = lang_string ('monitors_bad'); $legends[1] = lang_string ('monitors_bad');
generic_pie_graph ($width, $height, $data, $legends); generic_pie_graph ($width, $height, $data, $legends);
break; break;
default: default:
graphic_error (); graphic_error ();

View File

@ -122,11 +122,11 @@ if ($start_date != $current){
echo "<table width=450 cellspacing=1 cellpadding=1 class='databox' style='margin-left: 20px'>"; echo "<table width=450 cellspacing=1 cellpadding=1 class='databox' style='margin-left: 20px'>";
echo "<tr><td><b>"; echo "<tr><td><b>";
echo $lang_label["max_value"]." </b>: ". format_for_graph(return_moduledata_max_value ($id, $period)); echo $lang_label["max_value"]." </b>: ". format_for_graph(get_agent_module_value_max ($id, $period));
echo "</td><td><b>"; echo "</td><td><b>";
echo $lang_label["avg_value"]." </b>: ". format_for_graph(return_moduledata_avg_value ($id, $period)); echo $lang_label["avg_value"]." </b>: ". format_for_graph(get_agent_module_value_average ($id, $period));
echo "</td><td><b>"; echo "</td><td><b>";
echo $lang_label["min_value"]." </b>: ". format_for_graph(return_moduledata_min_value ($id, $period)); echo $lang_label["min_value"]." </b>: ". format_for_graph(get_agent_module_value_min ($id, $period));
echo "</td></tr>"; echo "</td></tr>";
echo "</table>"; echo "</table>";