2007-03-28 Sancho Lerena <slerena@artica.es>

* tip.css, pandora.css: Some updates to fix render in tooltips and
	datos3 background color.

	* config.php: Version update.

	* operation/menu.php: Added reporting suboption: Custom Graph Builder.

       	* operation/reporting/graph_builder.php: New custom and combined
	graphic generator that uses new function from fgraph
	graphic_combined_module().

	* reporting/fgraph.php: new function graphic_combined_module() to
	generate combined graphs. Needs to finish implementation to show
	alerts and evetns (most work done). Function
	grafico_db_agentes_purge() now uses Pear Graph instead jpgraph.

	* operation/agents/exportdata.php: Now uses indexes and improve
	the overall speed.

	* operation/agents/estado_grupo.php: Rewritten version, much more
	fast than previous.

	* operation/events/events.php: Fixed code to mass delete/update
	and added some audit control points.

	* pandora_db.php: audit_db() now uses utimestamp. event_insert()
	now uses utimestamp. Added function
	give_agent_id_from_module_id().

	* operation/agents/estado_ultimopaquete.php: Now render in red
	timestamp for "outdated" data. Fixes some minor problems with
	module groups and interval rendering.

	* operation/agents/estado_monitores.php: now uses utimestamp.

	* operation/agents/ver_agente.php: Uses lang_label labels for some
	texts. Fixed image bug.

	* operation/servers/view_server.php: Added version of server and
	some cosmetic adjustments.

	* godmode/db/db_main.php: Applied new graphic.

	* godmode/agentes/module_manager.php: Now sort by modulegroup.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@405 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2007-03-28 16:07:29 +00:00
parent b887172f46
commit e21ca2e398
21 changed files with 1414 additions and 496 deletions

View File

@ -1,3 +1,51 @@
2007-03-28 Sancho Lerena <slerena@artica.es>
* tip.css, pandora.css: Some updates to fix render in tooltips and
datos3 background color.
* config.php: Version update.
* operation/menu.php: Added reporting suboption: Custom Graph Builder.
* operation/reporting/graph_builder.php: New custom and combined
graphic generator that uses new function from fgraph
graphic_combined_module().
* reporting/fgraph.php: new function graphic_combined_module() to
generate combined graphs. Needs to finish implementation to show
alerts and evetns (most work done). Function
grafico_db_agentes_purge() now uses Pear Graph instead jpgraph.
* operation/agents/exportdata.php: Now uses indexes and improve
the overall speed.
* operation/agents/estado_grupo.php: Rewritten version, much more
fast than previous.
* operation/events/events.php: Fixed code to mass delete/update
and added some audit control points.
* pandora_db.php: audit_db() now uses utimestamp. event_insert()
now uses utimestamp. Added function
give_agent_id_from_module_id().
* operation/agents/estado_ultimopaquete.php: Now render in red
timestamp for "outdated" data. Fixes some minor problems with
module groups and interval rendering.
* operation/agents/estado_monitores.php: now uses utimestamp.
* operation/agents/ver_agente.php: Uses lang_label labels for some
texts. Fixed image bug.
* operation/servers/view_server.php: Added version of server and
some cosmetic adjustments.
* godmode/db/db_main.php: Applied new graphic.
* godmode/agentes/module_manager.php: Now sort by modulegroup.
2007-03-28 Esteban Sanchez <estebans@artica.es>
* pandoradb.sql: Changed MyISAM tables to InnoDB. Deleted charset

View File

@ -163,7 +163,7 @@ if (give_acl($id_user, 0, "AW")!=1) {
// ==========================
$sql1='SELECT * FROM tagente_modulo WHERE id_agente = "'.$id_agente.'"
ORDER BY nombre';
ORDER BY id_module_group, nombre ';
$result=mysql_query($sql1);
echo "<h2>".$lang_label["agent_conf"]." &gt; ".$lang_label["assigned_modules"]."
<a href='help/".$help_code."/chap3.php#321' target='_help' class='help'>
@ -180,7 +180,7 @@ if ($row=mysql_num_rows($result)){
echo "<th>".$lang_label["module_group"];
echo "<th>".$lang_label["max_min"];
echo "<th width=50>".$lang_label["action"];
$color=1;
$color=1;$last_modulegroup = "0";
while ($row=mysql_fetch_array($result)){
if ($color == 1){
$tdcolor="datos";
@ -196,6 +196,12 @@ if ($row=mysql_num_rows($result)){
$module_min = $row["min"];
$module_interval2 = $row["module_interval"];
$module_group2 = $row["id_module_group"];
if ($module_group2 != $last_modulegroup ){
// Render module group names (fixed code)
$nombre_grupomodulo = dame_nombre_grupomodulo ($module_group2);
$last_modulegroup = $module_group2;
echo "<tr><td class='datos3' align='center' colspan=9><b>".$nombre_grupomodulo."</b>";
}
echo "<tr><td class='".$tdcolor."_id'>".$nombre_modulo;
echo "<td class='".$tdcolor."f9'>";

View File

@ -32,7 +32,7 @@ if (comprueba_login() == 0)
<div align='justify'>
<?php echo $lang_label["dbsetup_info"]; ?>
</div><br>
<!-- <img src="reporting/fgraph.php?tipo=db_agente_purge&id=-1"> -->
<img src="reporting/fgraph.php?tipo=db_agente_purge&id=-1">
</table>
<?php
} else {

View File

@ -24,7 +24,7 @@
// This is the base config file
//Pandora Version
$build_version="PC070221"; //PCyymmdd
$build_version="PC070328"; //PCyymmdd
$pandora_version="v1.3 devel";
// Database configuration
@ -38,7 +38,7 @@ $config_fontpath = "../reporting/FreeSans.ttf"; // Change this to your font fold
// Do not display any ERROR
//error_reporting(E_ALL);
error_reporting(0);
error_reporting(E_ALL);
// Uncomment next to Display all errors, warnings and notices

View File

@ -90,10 +90,11 @@ function give_acl($id_user, $id_group, $access){
// audit_db, update audit log
// ---------------------------------------------------------------
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');
$sql1='INSERT INTO tsesion (ID_usuario, accion, fecha, IP_origen,descripcion) VALUES ("'.$id.'","'.$accion.'","'.$today.'","'.$ip.'","'.$descripcion.'")';
$utimestamp = time();
$sql1='INSERT INTO tsesion (ID_usuario, accion, fecha, IP_origen,descripcion, utimestamp) VALUES ("'.$id.'","'.$accion.'","'.$today.'","'.$ip.'","'.$descripcion.'", '.$utimestamp.')';
$result=mysql_query($sql1);
}
@ -212,6 +213,7 @@ function dame_agente_modulo_id($id_agente, $id_tipomodulo, $nombre){
return $pro;
}
// ---------------------------------------------------------------
// Returns event description given it's id
// ---------------------------------------------------------------
@ -335,7 +337,7 @@ function dame_nombre_agente_agentemodulo($id_agente_modulo){
}
// ---------------------------------------------------------------
// Return agent module, given a ID of agente_module table
// Return agent module name, given a ID of agente_module table
// ---------------------------------------------------------------
function dame_nombre_modulo_agentemodulo($id_agente_modulo){
@ -692,7 +694,9 @@ function existe($id){
function event_insert($evento, $id_grupo, $id_agente){
require("config.php");
$today=date('Y-m-d H:i:s');
$sql1='INSERT INTO tevento (id_agente,id_grupo,evento,timestamp,estado) VALUES ('.$id_agente.','.$id_grupo.',"'.$evento.'","'.$today.'",0)';
$utimestamp = time();
$sql1='INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, estado, utimestamp) VALUES ('.$id_agente.','.$id_grupo.',"'.$evento.'","'.$today.'",0, $utimestamp)';
$result=mysql_query($sql1);
}
@ -913,4 +917,20 @@ function give_network_profile_name ($id_np){
return $pro;
}
// ---------------------------------------------------------------
// Returns agent id given name of agent
// ---------------------------------------------------------------
function give_agent_id_from_module_id ($id_module){
require("config.php");
$query1="SELECT * FROM tagente_modulo WHERE id_agente_modulo = $id_module";
$resq1=mysql_query($query1);
if ($rowdup=mysql_fetch_array($resq1))
$pro=$rowdup["id_agente"];
else
$pro = "";
return $pro;
}
?>

View File

@ -726,6 +726,20 @@ $lang_label["no"]="No";
$lang_label["view"]="View";
$lang_label["number_of_modules"]="# Modules";
$lang_label["network_profile_management"]="Network profile management";
$lang_label["graph_builder"]="Graph builder";
$lang_label["combined_image"]="Combined image render";
$lang_label["redraw"]="Redraw";
$lang_label["graph_builder_modulelist"]="Graph builder module list";
$lang_label["seconds"]="Seconds";
$lang_name["custom_graph_name"]="Custom graph name";
$lang_label["save"]="Save";
$lang_label["Manage"]="Manage";
$lang_label["group_view_tab"]="Group view";
$lang_label["Alerts"]="Alerts";
$lang_label["Data"]="Data";
$lang_label["Main"]="Main";
$lang_label["version"]="Version";
global $lang_label;
global $help_label;

View File

@ -225,7 +225,7 @@ td.datos2f9i, td.datos2_jus, td.w90datos2, td.w135datos2 {
}
td.datos3 {
background-color: #e6e9cd;
background-color: #a7b896;
}
td.datos_id {
color: #1a313a;

View File

@ -55,7 +55,7 @@ a.help:hover span {
a.info:hover span {
top: 45px;
left: 20px;
width: 140px;
width: 100px;
}
a.info2:hover span {
top: 8px;

View File

@ -2,12 +2,12 @@
// Pandora - the Free monitoring system
// ====================================
// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com
// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es
// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com
// Copyright (c) 2004-2007 Raul Mateos Martin, raulofpandora@gmail.com
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// as published by the Free Software Foundation; version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -23,56 +23,34 @@ require("include/config.php");
function datos_raw($id_agente_modulo, $periodo){
require("include/config.php");
require("include/languages/language_".$language_code.".php");
// 24 hours date
$yesterday_year = date("Y", time()-86400);
$yesterday_month = date("m", time()-86400);
$yesterday_day = date ("d", time()-86400);
$yesterday_hour = date ("H", time()-86400);
$dia = $yesterday_year."-".$yesterday_month."-".$yesterday_day." ".$yesterday_hour.":00:00";
// 24x7 hours (one week)
$week_year = date("Y", time()-604800);
$week_month = date("m", time()-604800);
$week_day = date ("d", time()-604800);
$week_hour = date ("H", time()-604800);
$week = $week_year."-".$week_month."-".$week_day." ".$week_hour.":00:00";
// 24x7x30 Hours (one month)
$month_year = date("Y", time()-2592000);
$month_month = date("m", time()-2592000);
$month_day = date ("d", time()-2592000);
$month_hour = date ("H", time()-2592000);
$month = $month_year."-".$month_month."-".$month_day." ".$month_hour.":00:00";
$et = " ";
switch ($periodo) {
case "mes":
$periodo = $month;
$periodo = 86400*30;
$et=$lang_label["last_month"];
break;
case "semana":
$periodo = $week;
$periodo = 86400*7;
$et=$lang_label["last_week"];
break;
case "dia":
$periodo = $dia;
$periodo = 86400;
$et=$lang_label["last_24"];
break;
}
$periodo = time() - $periodo;
$id_agent = give_agent_id_from_module_id ($id_agente_modulo);
// Different query for string data type
$id_tipo_modulo = dame_id_tipo_modulo_agentemodulo($id_agente_modulo);
if ( (dame_nombre_tipo_modulo($id_tipo_modulo) == "generic_data_string" ) OR
(dame_nombre_tipo_modulo($id_tipo_modulo) == "remote_tcp_string" ) OR
(dame_nombre_tipo_modulo($id_tipo_modulo) == "remote_snmp_string" )) {
$sql1="SELECT * FROM tagente_datos_string WHERE id_agente_modulo = ".
$id_agente_modulo." AND timestamp > '".$periodo."'
$id_agente_modulo." AND id_agente = $id_agent AND utimestamp > '".$periodo."'
ORDER BY timestamp DESC";
}
else {
$sql1="SELECT * FROM tagente_datos WHERE id_agente_modulo = ".
$id_agente_modulo." AND timestamp > '".$periodo."'
$id_agente_modulo." AND id_agente = $id_agent AND utimestamp > '".$periodo."'
ORDER BY timestamp DESC";
}
@ -99,7 +77,7 @@ function datos_raw($id_agente_modulo, $periodo){
$color = 1;
}
echo "<tr>";
echo "<td class='".$tdcolor."f9 w130'>".$row["timestamp"];
echo "<td class='".$tdcolor."' style='width:150px'>".$row["timestamp"];
echo "<td class='".$tdcolor."'>";
if (($row["datos"] != 0) AND (is_numeric($row["datos"]))) {
$mytempdata = fmod($row["datos"], $row["datos"]);
@ -126,18 +104,29 @@ function datos_raw($id_agente_modulo, $periodo){
}
}
// Comienzo de la pagina en si misma
// ---------------
// Page begin
// ---------------
if (comprueba_login() == 0) {
if (isset($_GET["tipo"]) AND isset($_GET["id"])) {
$id_user = "";
if (comprueba_login() == 0)
$id_user = $_SESSION["id_usuario"];
if (give_acl($id_user, 0, "AR")!=1) {
audit_db ($id_user, $REMOTE_ADDR, "ACL Violation",
"Trying to access Agent Data view");
require ("general/noaccess.php");
exit;
}
if (isset($_GET["tipo"]) AND isset($_GET["id"])) {
$id =entrada_limpia($_GET["id"]);
$tipo= entrada_limpia($_GET["tipo"]);
}
else {
} else {
echo "<h3 class='error'>".$lang_label["graf_error"]."</h3>";
exit;
}
datos_raw($id,$tipo);
}
datos_raw($id,$tipo);
?>

View File

@ -36,6 +36,7 @@
<span>".$lang_label["help"]."</span>
</a></h2>";
// Get group list that user has access
$mis_grupos = list_group2 ($id_user);
// Update network modules for this group
@ -61,91 +62,54 @@
// For each valid group for this user, take data from agent and modules
foreach ($mis_grupos as $migrupo) {
if ($migrupo != "") {
$existen_agentes = 0;
$grupo[$array_index]["agent"] = 0;
$grupo[$array_index]["ok"] = 0;
$grupo[$array_index]["down"] = 0;
$grupo[$array_index]["bad"] = 0;
$grupo[$array_index]["alerts"] = 0;
$grupo[$array_index]["data"] = 0;
$grupo[$array_index]["icon"] = dame_grupo_icono ($migrupo);
$grupo[$array_index]["id_grupo"] = $migrupo;
$existen_agentes =0;
$sql1 = "SELECT intervalo, id_agente
FROM tagente WHERE disabled=0
AND id_grupo = ".$migrupo;
if ($result1 = mysql_query ($sql1)) {
while ($row1 = mysql_fetch_array ($result1)) {
$existen_agentes = 1;
$intervalo = $row1["intervalo"];
$id_agente = $row1["id_agente"];
// Check for recent alerts
if ($config_show_lastalerts == 1)
if (check_alert_fired($id_agente) == 1) {
$grupo[$array_index]["alerts"]++;
}
$grupo[$array_index]["agent"]++;
$grupo[$array_index]["group"] = dame_nombre_grupo ($migrupo);
// Estado grupo, agent
$contador_agente++;
$sql3 = "SELECT estado, utimestamp, id_agente_modulo,
datos FROM tagente_estado
WHERE id_agente = ".$row1["id_agente"];
$result3 = mysql_query ($sql3);
while ($row3 = mysql_fetch_array ($result3)) {
$estado = $row3["estado"];
$ahora = date ("Y/m/d H:i:s");
$sql0 = "SELECT COUNT(id_agente) FROM tagente WHERE id_grupo = $migrupo AND disabled = 0";
$result0 = mysql_query ($sql0);
$row0 = mysql_fetch_array ($result0);
$contador_agente = $contador_agente + $row0[0];
$grupo[$array_index]["agent"] = $row0[0];
if ($row0[0] > 0)
$existen_agentes = 1;
if ($config_show_unknown != 0){
// Get module interval
$sql4 = "SELECT module_interval
FROM tagente_modulo
WHERE id_agente_modulo = ".$row3["id_agente_modulo"];
$result4 = mysql_query ($sql4);
if ($row4 = mysql_fetch_array ($result4)) {
$module_interval = $row4["module_interval"];
if ($module_interval > 0) {
$intervalo_comp = $module_interval;
} else {
$intervalo_comp = $intervalo;
}
}
$ultimo_contacto_modulo = $row3["utimestamp"];
// Defines if module is down (interval x 2 > time last contact)
if ($ultimo_contacto_modulo != 0) {
$seconds = strtotime ($ahora) -
$ultimo_contacto_modulo;
if ($seconds >= ($intervalo_comp * 2)) {
$grupo[$array_index]["down"]++;
} elseif ($estado != 100) {
if ($row3["datos"] != 0) {
// SQL Join to get monitor status for agents belong this group
$sql1 = "SELECT tagente.id_agente, tagente_estado.estado, tagente_estado.datos FROM tagente, tagente_estado WHERE tagente.disabled = 0 AND tagente.id_grupo = $migrupo AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.estado != 100";
if ($result1 = mysql_query ($sql1)){
while ($row1 = mysql_fetch_array ($result1)) {
$id_agente = $row1[0];
$estado = $row1[1];
$datos = $row1[2];
if ($datos != 0) {
$grupo[$array_index]["ok"]++;
} else {
$grupo[$array_index]["bad"]++;
}
} elseif ($estado == 100) // For data module, not monitors
$grupo[$array_index]["data"]++; // Data module
}
// do not use module interval neither down check
} elseif ($estado != 100) {
if ($row3["datos"] != 0) {
$grupo[$array_index]["ok"]++;
} else {
$grupo[$array_index]["bad"]++;
}
} elseif ($estado == 100) // For data module, not monitors
$grupo[$array_index]["data"]++; // Data module
}
if ($config_show_lastalerts == 1){
// How many alerts has been fired recently for this group:
// SQL Join to get alert status for agents belong this group
$sql1 = "SELECT SUM(talerta_agente_modulo.times_fired)
FROM tagente_modulo, talerta_agente_modulo, tagente WHERE tagente.disabled = 0 AND tagente.id_grupo = $migrupo AND tagente.id_agente = tagente_modulo.id_agente AND talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo";
if ($result1 = mysql_query ($sql1)){
$row1 = mysql_fetch_array ($result1);
$grupo[$array_index]["alerts"] = $row1[0];
}
}
if ($existen_agentes == 1){
$array_index++;
}
}
}
// Draw data
@ -160,11 +124,6 @@
$group_name = $grupo[$real_count]["group"];
$icono_grupo = $grupo[$real_count]["icon"];
$icono_type = "";
if ($grupo[$real_count]["down"] > 0) {
$icono_type = "
<img src='images/dot_down.gif' alt=''>";
}
if ($grupo[$real_count]["bad"] > 0) {
$icono_type = $icono_type."
<img src='images/dot_red.gif' alt=''>";
@ -173,28 +132,26 @@
$icono_type = $icono_type."
<img src='images/dot_green.gif' alt=''>";
}
if ($grupo[$real_count]["data"] > 0) {
$icono_type = $icono_type."
<img src='images/dot_white.gif' alt=''>";
}
// Show yellow light if there are recent alerts fired for this group
if ($grupo[$real_count]["alerts"] > 0 ){
$icono_type=$icono_type."
<img src='images/dot_yellow.gif' alt=''>";
}
$celda = "<td class='top' width='100'>";
// Bu default green border
$celda = "<td class='top' style='border: 3px solid #AEFF21;' width='100'>";
// Yellow border if agents down / unknown
if ($grupo[$real_count]["down"] > 0)
$celda = "<td class='top' style='border: 3px solid #FFDD00;' width='100'>";
// Yellow border if agents with alerts
if ($grupo[$real_count]["alerts"] > 0)
$celda = "<td class='top' style='border: 3px solid #FFEA00;' width='100'>";
// Red border if agents bad
if ($grupo[$real_count]["bad"] > 0)
$celda = "<td class='top' style='border: 3px solid #ff0000;' width='100'>";
if (($grupo[$real_count]["bad"] > 0) && ($grupo[$real_count]["down"] > 0))
$celda = "<td class='top' style='border: 3px solid #F700FF;' width='100'>";
// Orange if alerts and down modules
if (($grupo[$real_count]["bad"] > 0) && ($grupo[$real_count]["alerts"] > 0))
$celda = "<td class='top' style='border: 3px solid #FFBB00;' width='100'>";
$celda .= "<a href='index.php?sec=estado&amp;
sec2=operation/agentes/estado_agente&amp;
@ -210,14 +167,14 @@
$celda .= "
<span>
<table cellspacing='2' cellpadding='0'
style='margin-left:20px;'>
style='margin-left:2px;'>
<tr><td colspan='2' width='91' class='lb'>".
$lang_label["agents"].": </td></tr>
<tr><td colspan='2' class='datos' align='center'><b>".
$grupo[$real_count]["agent"]."</b></td></tr>
</table>
<table cellspacing='2' cellpadding='0'
style='margin-left:20px'>
style='margin-left:2px'>
<tr>
<td colspan='2' width='90' class='lb'>".
ucfirst($lang_label["monitors"]).":</td>
@ -232,27 +189,23 @@
</tr>
<tr>
<td class='datos'>
<img src='images/b_down.gif' align='top' alt=''>
".$lang_label["down"].": </td>
<td class='datos'><font class='#a9aa9a'>".
$grupo[$real_count]["down"]."</font></td>
</tr>
<tr>
<td class='datos'>
<img src='images/b_red.gif' align='top' alt=''>
".$lang_label["fail"].": </td>
<td class='datos'><font class='redb'>".
$grupo[$real_count]["bad"]."</font></td>
</tr>
<tr>
</tr>";
if ($config_show_lastalerts == 1)
$celda .= "<tr>
<td class='datos'>
<img src='images/b_yellow.gif' align='top' alt=''>
".$lang_label["alerts"].": </td>
<td class='datos'><font class='grey'>".
$grupo[$real_count]["alerts"]."</font></td>
</tr>
</table>
</span></a>";
</tr>";
$celda .= "</table></span></a>";
// Render network exec module button, only when this group is writtable by user
if (give_acl ($id_user, $grupo[$real_count]["id_grupo"], "AW") == 1) {
$celda .= "&nbsp;<a href='index.php?

View File

@ -56,8 +56,7 @@ if (comprueba_login() == 0) {
$tdcolor = "datos2";
$color = 1;
}
$ahora=date("Y/m/d H:i:s");
$seconds = strtotime($ahora) - strtotime($row_t["timestamp"]);
$seconds = time() - $row_t["utimestamp"];
if ($seconds >= ($temp_interval*2)) // If every interval x 2 secs. we get nothing, there's and alert
$agent_down = 1;
else

View File

@ -72,7 +72,7 @@ if (comprueba_login() == 0) {
echo "<th>".$lang_label["graph"]."</th>";
echo "<th>".$lang_label["raw_data"]."</th>";
echo "<th>".$lang_label["timestamp"]."</th>";
$texto='';
$texto=''; $last_modulegroup = 0;
$color = 1;
while ($row3=mysql_fetch_array($result3)){
// Calculate table line color
@ -84,16 +84,14 @@ if (comprueba_login() == 0) {
$tdcolor = "datos2";
$color = 1;
}
if ($row3["id_module_group"] != $last_modulegroup ){
// Render module group names (fixed code)
$nombre_grupomodulo = dame_nombre_grupomodulo ($row3["id_module_group"]);
if ($nombre_grupomodulo != ""){
if (($label_group == 0) || ($last_label != $nombre_grupomodulo)){
// Show label module group
$label_group = -1;
$last_label = $nombre_grupomodulo;
$last_modulegroup = $row3["id_module_group"];
echo "<tr><td class='datos3' align='center' colspan=9><b>".$nombre_grupomodulo."</b>";
}
}
// Begin to render data ...
echo "<tr><td class='$tdcolor'>";
// Render network exec module button, only when
@ -141,10 +139,13 @@ if (comprueba_login() == 0) {
echo "<td class='".$tdcolor."'>";
echo "<img src='images/".show_icon_type($row3["id_tipo_modulo"])."' border=0>";
echo "<td class='".$tdcolor."'>";
if ($row3["module_interval"] != 0)
if ($row3["module_interval"] != 0){
echo $row3["module_interval"];
else
$real_interval = $row3["module_interval"];
} else {
echo $intervalo_agente;
$real_interval = $intervalo_agente;
}
//echo $nombre_tipo_modulo;
echo "<td class='".$tdcolor."f9' title='".$row3["descripcion"]."'>";
echo salida_limpia(substr($row3["descripcion"],0,32));
@ -206,6 +207,12 @@ if (comprueba_login() == 0) {
if ($row3["timestamp"] == "0000-00-00 00:00:00"){
echo $lang_label["never"];
} else {
$ahora = time();
if ( ($ahora - $row3["utimestamp"]) > ($real_interval*2)) {
echo "<font color='red'>";
echo $row3["timestamp"];
echo "</font>";
} else
echo $row3["timestamp"];
}
echo "</td></tr>";

View File

@ -1,14 +1,15 @@
<?php
// Pandora - the Free monitoring system
// ====================================
// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com
// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es
// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com
// Pandora FMS - the Free monitoring system
// ========================================
// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com
// Main PHP/SQL code development and project architecture and management
// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ -20,10 +21,18 @@
// Load global vars
require("include/config.php");
$id_user = "";
if (comprueba_login() == 0)
$id_user = $_SESSION["id_usuario"];
if ( (give_acl($id_user, 0, "AR")==1) OR (give_acl($id_user, 0, "AW")==1) ){
if ((isset($_GET["operacion"])) AND (! isset($_POST["update_agent"]))){
if (give_acl($id_user, 0, "AR")!=1) {
audit_db ($id_user, $REMOTE_ADDR, "ACL Violation",
"Trying to access Agent Data Export view (Grouped)");
require ("general/noaccess.php");
exit;
}
if ((isset($_GET["operacion"])) AND (! isset($_POST["update_agent"]))){
if (isset ($_POST["copiar"])){ // Export main button
echo "<h2>".$lang_label["ag_title"]."</h2>";
echo "<h3>".$lang_label["export_title"]."<a href='help/".$help_code."/chap3.php#336' target='_help' class='help'>&nbsp;<span>".$lang_label["help"]."</span></a></h3>";
@ -75,10 +84,10 @@ if (comprueba_login() == 0)
echo "<tr><td colspan='3'><div class='raya'></div></td></tr>";
}
echo "</table>";
} else echo "<b class='error'>".$lang_label["no_sel_mod"]."</b>";
} else
echo "<b class='error'>".$lang_label["no_sel_mod"]."</b>";
}
} else { // Form view
} else { // Form view
?>
<h2><?php echo $lang_label["ag_title"] ?></h2>
<h3><?php echo $lang_label["export_data"] ?><a href='help/<?php echo $help_code; ?>/chap3.php#336' target='_help' class='help'>&nbsp;<span><?php echo $lang_label["help"] ?></span></a></h3>
@ -184,9 +193,9 @@ if (comprueba_login() == 0)
?>
<tr><td class='datost'><?php echo $lang_label["from"] ?>
&nbsp;&nbsp;<input type="text" class="sub" name="from_date" value="<?php echo $date_from; ?>" size="21"><br><br>
&nbsp;&nbsp;<input type="text" class="sub" name="from_date" value="<?php echo $date_from; ?>" size="21"><br><br>
<?php
//print calendar and links for next and previous months
//print calendar and links for next and previous months
echo "
<table><tr>
<td class='datost'><a href='index.php?sec=estado&sec2=operation/agentes/exportdata&month=".$month_a."&year=".$year_a.$date."'><font size =+1>&laquo;</font></a></td>
@ -209,11 +218,7 @@ if (comprueba_login() == 0)
<input type=submit name="copiar" class=sub value="<?php echo $lang_label["export"] ?>">
</table></td></tr>
</table>
<?php
}
<?php
}
} else {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent Export Data");
require ("general/noaccess.php");
}
?>

View File

@ -0,0 +1,278 @@
<?php
// Pandora FMS - the Free monitoring system
// ========================================
// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com
// Main PHP/SQL code development and project architecture and management
// Copyright (c) 2004-2007 Raul Mateos Martin, raulofpandora@gmail.com
// CSS and some PHP additions
// Copyright (c) 2006-2007 Jonathan Barajas, jonathan.barajas[AT]gmail[DOT]com
// Javascript Active Console code.
// Copyright (c) 2006 Jose Navarro <contacto@indiseg.net>
// Additions to Pandora FMS 1.2 graph code and new XML reporting template management
// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Load global vars
require("include/config.php");
if (give_acl ($id_user, 0, "AR") != 1) {
audit_db ($id_user, $REMOTE_ADDR, "ACL Violation",
"Trying to access Agent view (Grouped)");
require ("general/noaccess.php");
exit;
}
echo "<h2>".$lang_label["ag_title"]." &gt; ".$lang_label["group_view"]."
<a href='help/".$help_code."/chap3.php#324' target='_help' class='help'>
<span>".$lang_label["help"]."</span>
</a></h2>";
$mis_grupos = list_group2 ($id_user);
// Update network modules for this group
// Check for Network FLAG change request
if (isset ($_GET["update_netgroup"])) {
if (give_acl ($id_user, $_GET["update_netgroup"], "AW") == 1) {
$sql = "SELECT * FROM tagente WHERE id_grupo = ".
$_GET["update_netgroup"];
$result = mysql_query ($sql);
while ($row = mysql_fetch_array ($result)) {
$id_agente = $row["id_agente"];
$query2 ="UPDATE tagente_modulo SET flag=1
WHERE id_agente = ".$id_agente;
$res = mysql_query ($query2);
}
}
}
$contador_grupo = 0;
$contador_agente = 0;
$array_index = 0;
// Prepare data to show
// For each valid group for this user, take data from agent and modules
foreach ($mis_grupos as $migrupo) {
if ($migrupo != "") {
$grupo[$array_index]["agent"] = 0;
$grupo[$array_index]["ok"] = 0;
$grupo[$array_index]["down"] = 0;
$grupo[$array_index]["bad"] = 0;
$grupo[$array_index]["alerts"] = 0;
$grupo[$array_index]["data"] = 0;
$grupo[$array_index]["icon"] = dame_grupo_icono ($migrupo);
$grupo[$array_index]["id_grupo"] = $migrupo;
$grupo[$array_index]["group"] = dame_nombre_grupo ($migrupo);
$existen_agentes =0;
$sql1 = "SELECT intervalo, id_agente
FROM tagente WHERE disabled=0
AND id_grupo = ".$migrupo;
if ($result1 = mysql_query ($sql1)) {
while ($row1 = mysql_fetch_array ($result1)) {
$existen_agentes = 1;
$intervalo = $row1["intervalo"];
$id_agente = $row1["id_agente"];
// Check for recent alerts
if ($config_show_lastalerts == 1)
if (check_alert_fired($id_agente) == 1) {
$grupo[$array_index]["alerts"]++;
}
$grupo[$array_index]["agent"]++;
// Estado grupo, agent
$contador_agente++;
$sql3 = "SELECT estado, utimestamp, id_agente_modulo,
datos FROM tagente_estado
WHERE id_agente = ".$row1["id_agente"];
$result3 = mysql_query ($sql3);
while ($row3 = mysql_fetch_array ($result3)) {
$estado = $row3["estado"];
if ($config_show_unknown != 0){
// Get module interval
$sql4 = "SELECT module_interval
FROM tagente_modulo
WHERE id_agente_modulo = ".$row3["id_agente_modulo"];
$result4 = mysql_query ($sql4);
if ($row4 = mysql_fetch_array ($result4)) {
$module_interval = $row4["module_interval"];
if ($module_interval > 0) {
$intervalo_comp = $module_interval;
} else {
$intervalo_comp = $intervalo;
}
}
$ultimo_contacto_modulo = $row3["utimestamp"];
// Defines if module is down (interval x 2 > time last contact)
if ($ultimo_contacto_modulo != 0) {
$seconds = time() -
$ultimo_contacto_modulo;
if ($seconds >= ($intervalo_comp * 2)) {
$grupo[$array_index]["down"]++;
} elseif ($estado != 100) {
if ($row3["datos"] != 0) {
$grupo[$array_index]["ok"]++;
} else {
$grupo[$array_index]["bad"]++;
}
} elseif ($estado == 100) // For data module, not monitors
$grupo[$array_index]["data"]++; // Data module
}
// do not use module interval neither down check
} elseif ($estado != 100) {
if ($row3["datos"] != 0) {
$grupo[$array_index]["ok"]++;
} else {
$grupo[$array_index]["bad"]++;
}
} elseif ($estado == 100) // For data module, not monitors
$grupo[$array_index]["data"]++; // Data module
}
}
}
if ($existen_agentes == 1){
$array_index++;
}
}
}
// Draw data
if ($contador_agente != 0) {
$ancho = ceil(sqrt($array_index+1));
$real_count =0;
echo "<table cellpadding=10 cellspacing=10 border=0>";
for ($table=0; $table < $ancho; $table++) {
echo "<tr class='bot'>";
for ($table_row=0; $table_row < $ancho; $table_row++) {
if ($real_count < $array_index) {
$group_name = $grupo[$real_count]["group"];
$icono_grupo = $grupo[$real_count]["icon"];
$icono_type = "";
if ($grupo[$real_count]["down"] > 0) {
$icono_type = "
<img src='images/dot_down.gif' alt=''>";
}
if ($grupo[$real_count]["bad"] > 0) {
$icono_type = $icono_type."
<img src='images/dot_red.gif' alt=''>";
}
if ($grupo[$real_count]["ok"] > 0) {
$icono_type = $icono_type."
<img src='images/dot_green.gif' alt=''>";
}
if ($grupo[$real_count]["data"] > 0) {
$icono_type = $icono_type."
<img src='images/dot_white.gif' alt=''>";
}
// Show yellow light if there are recent alerts fired for this group
if ($grupo[$real_count]["alerts"] > 0 ){
$icono_type=$icono_type."
<img src='images/dot_yellow.gif' alt=''>";
}
$celda = "<td class='top' width='100'>";
// Yellow border if agents down / unknown
if ($grupo[$real_count]["down"] > 0)
$celda = "<td class='top' style='border: 3px solid #FFDD00;' width='100'>";
// Red border if agents bad
if ($grupo[$real_count]["bad"] > 0)
$celda = "<td class='top' style='border: 3px solid #ff0000;' width='100'>";
if (($grupo[$real_count]["bad"] > 0) && ($grupo[$real_count]["down"] > 0))
$celda = "<td class='top' style='border: 3px solid #F700FF;' width='100'>";
$celda .= "<a href='index.php?sec=estado&amp;
sec2=operation/agentes/estado_agente&amp;
refr=60&amp;
group_id=".$grupo[$real_count]["id_grupo"]."'
class='info'>";
// Add group icon
$celda .= "<img class='top'
src='images/groups_small/".$icono_grupo.".png' height='32' width='32' alt=''>";
// Add float info table
$celda .= "
<span>
<table cellspacing='2' cellpadding='0'
style='margin-left:20px;'>
<tr><td colspan='2' width='91' class='lb'>".
$lang_label["agents"].": </td></tr>
<tr><td colspan='2' class='datos' align='center'><b>".
$grupo[$real_count]["agent"]."</b></td></tr>
</table>
<table cellspacing='2' cellpadding='0'
style='margin-left:20px'>
<tr>
<td colspan='2' width='90' class='lb'>".
ucfirst($lang_label["monitors"]).":</td>
</tr>
<tr>
<td class='datos'>
<img src='images/b_green.gif' align='top' alt='' >
".$lang_label["ok"].": </td>
<td class='datos'>
<font class='greenb'>".$grupo[$real_count]["ok"]."</font>
</td>
</tr>
<tr>
<td class='datos'>
<img src='images/b_down.gif' align='top' alt=''>
".$lang_label["down"].": </td>
<td class='datos'><font class='#a9aa9a'>".
$grupo[$real_count]["down"]."</font></td>
</tr>
<tr>
<td class='datos'>
<img src='images/b_red.gif' align='top' alt=''>
".$lang_label["fail"].": </td>
<td class='datos'><font class='redb'>".
$grupo[$real_count]["bad"]."</font></td>
</tr>
<tr>
<td class='datos'>
<img src='images/b_yellow.gif' align='top' alt=''>
".$lang_label["alerts"].": </td>
<td class='datos'><font class='grey'>".
$grupo[$real_count]["alerts"]."</font></td>
</tr>
</table>
</span></a>";
// Render network exec module button, only when this group is writtable by user
if (give_acl ($id_user, $grupo[$real_count]["id_grupo"], "AW") == 1) {
$celda .= "&nbsp;<a href='index.php?
sec=estado&
sec2=operation/agentes/estado_grupo&
update_netgroup=".$grupo[$real_count]["id_grupo"]."'>
<img src='images/target.gif'></a>";
}
$celda .= "<br><br>".
$icono_type."<br><br>
<span class='gr'>".$group_name."</span>";
echo $celda;
}
$real_count++;
}
echo "</tr>";
}
echo "</table>";
} else {
echo "<div class='nf'>".$lang_label["no_agent_def"]."</div>";
}
?>

View File

@ -51,7 +51,7 @@ if (comprueba_login() == 0) {
<ul class='mn'>
<li class='nomn'>";
echo "<li class='nomn'>";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente'><img src='../images/bricks.png' class='top' border=0>&nbsp; ".dame_nombre_agente($id_agente)." - ".$lang_label["view_mode"]."</A>";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente'><img src='images/bricks.png' class='top' border=0>&nbsp; ".dame_nombre_agente($id_agente)." - ".$lang_label["view_mode"]."</A>";
echo "</li>";
echo "</ul></div>";
@ -60,34 +60,30 @@ if (comprueba_login() == 0) {
$tab = $_GET["tab"];
else
$tab = "main";
echo "
<div id='menu_tab'>
<ul class='mn'>";
echo "<div id='menu_tab'><ul class='mn'>";
if (give_acl($id_usuario,$id_grupo, "AW") == 1){
// Manage agent
echo "<li class='nomn'><a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=$id_agente'><img src='images/setup.gif' width='16' class='top' border=0> Manage</A>";
echo "<li class='nomn'><a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=$id_agente'><img src='images/setup.gif' width='16' class='top' border=0> ".$lang_label["Manage"]." </A>";
echo "</li>";
}
// Main view
echo "<li class='nomn'>";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente'><img src='images/monitor.png' class='top' border=0> Main</a>";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente'><img src='images/monitor.png' class='top' border=0> ".$lang_label["Main"]." </a>";
echo "</li>";
// Data
echo "<li class='nomn'>";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente&tab=data'><img src='images/lightbulb.png' class='top' border=0> Data</a>";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente&tab=data'><img src='images/lightbulb.png' class='top' border=0> ".$lang_label["Data"]." </a>";
echo "</li>";
// Alerts
echo "<li class='nomn'>";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente&tab=alert'><img src='images/bell.png' class='top' border=0> Alerts</A>";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=$id_agente&tab=alert'><img src='images/bell.png' class='top' border=0> ".$lang_label["Alerts"]." </A>";
echo "</li>";
// Go to group view
echo "<li class='nomn'>";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=$id_grupo&refr=60'><img src='images/images.png' class='top' border=0> Group view</a>";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=$id_grupo&refr=60'><img src='images/images.png' class='top' border=0> ".$lang_label["group_view_tab"]." </a>";
echo "</li>";
echo "</ul>";

View File

@ -74,6 +74,7 @@ if (isset($_GET["delete"])){
$result2=mysql_query($sql2);
if ($result) {
echo "<h3 class='suc'>".$lang_label["delete_event_ok"]."</h3>";
audit_db($id_user,$REMOTE_ADDR, "Event deleted","Deleted event: ".return_event_description ($id_evento));
}
} else {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation",
@ -91,12 +92,13 @@ if (isset($_GET["check"])){
$result2=mysql_query($sql2);
if ($result2) {
echo "<h3 class='suc'>".$lang_label["validate_event_ok"]."</h3>";
audit_db($id_user,$REMOTE_ADDR, "Event validated","Validate event: ".return_event_description ($id_evento));
} else {
echo "<h3 class='error'>".$lang_label["validate_event_failed"]."</h3>";
}
} else {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to checkout event ID".$id_evento);
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to checkout event ".return_event_description ($id_evento));
}
}
@ -109,9 +111,10 @@ if (isset($_POST["deletebt"])){
// Look for event_id following parameters: id_group.
$id_group = gime_idgroup_from_idevent($event_id);
if (give_acl($id_user, $id_group, "IM") ==1){
mysql_query("DELETE FROM tevento WHERE id_evento =".$event_id);
mysql_query("DELETE FROM tevento WHERE id_evento = ".$event_id);
audit_db($id_user,$REMOTE_ADDR, "Event deleted","Deleted event: ".return_event_description ($event_id));
} else {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to delete event ID".$id_evento);
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to delete event ".return_event_description ($event_id));
}
}
$count++;
@ -126,8 +129,9 @@ if (isset($_POST["updatebt"])){
$id_evento = $_POST["eventid".$count];
$id_group = gime_idgroup_from_idevent($id_evento);
if (give_acl($id_user, $id_group, "IW") ==1){
$sql2="UPDATE tevento SET estado=1, id_user = '".$id_user."' WHERE estado = 0 AND id_evento = ".$id_evento;
$sql2="UPDATE tevento SET estado=1, id_usuario = '".$id_user."' WHERE estado = 0 AND id_evento = ".$id_evento;
$result2=mysql_query($sql2);
audit_db($id_user,$REMOTE_ADDR, "Event validated","Validate event: ".return_event_description ($id_evento));
} else {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to checkout event ID".$id_evento);
}
@ -256,6 +260,7 @@ if ($total_events > 0){
}
}
$offset_counter=0;
// Make query for data (all data, not only distinct).
$result2=mysql_query($sql2);
while ($row2=mysql_fetch_array($result2)){
@ -303,6 +308,7 @@ if ($total_events > 0){
echo "<input type='checkbox' class='chk' name='eventid".$offset_counter."' value='".$row2["id_evento"]."'>";
echo "</td></tr>";
}
$offset_counter++;
}
echo "<tr><td colspan='8'><div class='raya'></div></td></tr>";

View File

@ -205,21 +205,30 @@ if (give_acl($_SESSION["id_usuario"], 0, "AR")==1) {
}
// Reporting
if (isset($_GET["sec2"]) && $_GET["sec2"] == "operation/reporting/reporting") {
if (isset($_GET["sec2"]) && $_GET["sec2"] == "operation/reporting/reporting"){
echo '<div id="op8s">';
} else {
echo '<div id="op8">';
}
echo '<ul class="mn"><li><a href="index.php?sec=reporting&sec2=operation/reporting/reporting" class="mn">'. $lang_label["reporting"].'</a></li></ul></div>';
// New message (reporting)
// Agent general reporting
if (isset($_GET["sec"]) && $_GET["sec"] == "reporting"){
if(isset($_GET["sec2"])){
if (isset($_GET["sec2"]) && $_GET["sec2"] == "operation/reporting/agent_overview"){
echo "<div class='arrows'>";
} else {
echo "<div class='arrow'>";
}
echo "<ul class='mn'><li><a href='index.php?sec=reporting&sec2=operation/reporting/reporting' class='mn'>".$lang_label["agent_general_reporting"]."</a></li></ul></div>";
echo "<ul class='mn'><li><a href='index.php?sec=reporting&sec2=operation/reporting/agent_overview' class='mn'>".$lang_label["agent_general_reporting"]."</a></li></ul></div>";
}
// Custom graph builder
if (isset($_GET["sec"]) && $_GET["sec"] == "reporting"){
if (isset($_GET["sec2"]) && $_GET["sec2"] == "operation/reporting/graph_builder"){
echo "<div class='arrows'>";
} else {
echo "<div class='arrow'>";
}
echo "<ul class='mn'><li><a href='index.php?sec=reporting&sec2=operation/reporting/graph_builder' class='mn'>".$lang_label["graph_builder"]."</a></li></ul></div>";
}
}

View File

@ -0,0 +1,326 @@
<?PHP
// Pandora FMS - the Free monitoring system
// ========================================
// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com
// Main PHP/SQL code development and project architecture and management
// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
$id_agent = 0;
$id_module = 0;
$name = "Pandora FMS combined graph";
$width = 550;
$height = 210;
$period = "";
$alerts= "";
$events = "";
$factor = 1;
if (isset($_GET["get_agent"])) {
$id_agent = $_POST["id_agent"];
$chunkdata = $_POST["chunk"];
}
if (isset($_GET["delete_module"] )) {
$chunkdata = $_POST["chunk"];
if (isset($chunkdata)) {
$chunk1 = array();
$chunk1 = split ("\|", $chunkdata);
$modules="";$weights="";
for ($a=0; $a < count($chunk1); $a++){
if (isset($_POST["delete_$a"])){
$id_module = $_POST["delete_$a"];
$deleted_id[]=$id_module;
}
}
$chunkdata2 = "";
$module_array = array();
$weight_array = array();
$agent_array = array();
for ($a=0; $a < count($chunk1); $a++){
$chunk2[$a] = array();
$chunk2[$a] = split ( ",", $chunk1[$a]);
$skip_module =0;
for ($b=0; $b < count($deleted_id); $b++){
if ($deleted_id[$b] == $chunk2[$a][1]){
$skip_module = 1;
}
}
if (($skip_module == 0) && (strpos($modules, $chunk2[$a][1]) == 0)){ // Skip
$module_array[] = $chunk2[$a][1];
$agent_array[] = $chunk2[$a][0];
$weight_array[] = $chunk2[$a][2];
if ($chunkdata2 == "")
$chunkdata2 .= $chunk2[$a][0].",".$chunk2[$a][1].",".$chunk2[$a][2];
else
$chunkdata2 .= "|".$chunk2[$a][0].",".$chunk2[$a][1].",".$chunk2[$a][2];
if ($modules !="")
$modules = $modules.",".$chunk2[$a][1];
else
$modules = $chunk2[$a][1];
if ($weights !="")
$weights = $weights.",".$chunk2[$a][2];
else
$weights = $chunk2[$a][2];
}
}
$chunkdata = $chunkdata2;
}
}
if ( (isset($_GET["add_module"]))){
$id_agent = $_POST["id_agent"];
$id_module = $_POST["id_module"];
if (isset($_POST["factor"]))
$factor = $_POST["factor"];
else
$factor = 1;
$period = $_POST["period"];
$graphname = $_POST["graphname"];
$render = $_POST["render"];
$alerts = $_POST["alerts"];
$chunkdata = $_POST["chunk"];
$events = $_POST["events"];
$factor = $_POST["factor"];
if ($_POST["width"]!= "")
$width = $_POST["width"];
if ($_POST["height"]!= "")
$height = $_POST["height"];
if ($id_module > 0){
if ($chunkdata == "")
$chunkdata = "$id_agent,$id_module,$factor";
else
$chunkdata = $chunkdata."|$id_agent,$id_module,$factor";
}
}
// Parse CHUNK information into showable information
// Split id to get all parameters
if (! isset($_GET["delete_module"])){
if (isset($chunkdata)) {
$module_array = array();
$weight_array = array();
$agent_array = array();
$chunk1 = array();
$chunk1 = split ("\|", $chunkdata);
$modules="";$weights="";
for ($a=0; $a < count($chunk1); $a++){
$chunk2[$a] = array();
$chunk2[$a] = split ( ",", $chunk1[$a]);
if (strpos($modules, $chunk2[$a][1]) == 0){ // Skip dupes
$module_array[] = $chunk2[$a][1];
$agent_array[] = $chunk2[$a][0];
$weight_array[] = $chunk2[$a][2];
if ($modules !="")
$modules = $modules.",".$chunk2[$a][1];
else
$modules = $chunk2[$a][1];
if ($weights !="")
$weights = $weights.",".$chunk2[$a][2];
else
$weights = $chunk2[$a][2];
}
}
}
}
if (isset($chunk1)) {
echo "<h3>".$lang_label["graph_builder_modulelist"]."</h3>";
echo "<form method='post' action='index.php?sec=reporting&sec2=operation/reporting/graph_builder&delete_module=1'>";
if (isset($chunkdata))
echo "<input type='hidden' name='chunk' value='$chunkdata'>";
if (isset($id_agent))
echo "<input type='hidden' name='id_agent' value='$id_agent'>";
echo "<table width='500' cellpadding=4 cellpadding=4>";
echo "<tr><th>Agent<th>Module<th>Weight<th>Delete";
for ($a=0; $a < count($module_array); $a++){
// Calculate table line color
if ($color == 1){
$tdcolor = "datos";
$color = 0;
}
else {
$tdcolor = "datos2";
$color = 1;
}
echo "<tr><td class='$tdcolor'>";
echo dame_nombre_agente($agent_array[$a]);
echo "<td class='$tdcolor'>";
echo dame_nombre_modulo_agentemodulo($module_array[$a]);
echo "<td class='$tdcolor'>";
echo $weight_array[$a];
echo "<td class='$tdcolor'>";
echo "<input style='height=2px;' type=checkbox name='delete_$a' value='".$module_array[$a]."'>";
}
echo "<tr><td colspan=4 align='right'><input type=submit name='update_agent' class=sub value='".$lang_label["delete"]."'>";
echo "</table>";
echo "</form>";
}
// -----------------------
// SOURCE AGENT TABLE/FORM
// -----------------------
echo "<h3>".$lang_label["graph_builder"]."</h3>";
echo "<table width='500' cellpadding=4 cellpadding=4>";
echo "<form method='post' action='index.php?sec=reporting&sec2=operation/reporting/graph_builder&get_agent=1'>";
echo "<tr>";
echo "<td class='datos'><b>".$lang_label["source_agent"];
echo "</b>";
// Show combo with agents
echo "<td class='datos'><select name='id_agent' style='width:180px;'>";
if ($id_agent != 0)
echo "<option value='$id_agent'>".dame_nombre_agente($id_agent);
$sql1='SELECT * FROM tagente order by nombre';
$result=mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
if ( $id_agent != $row["id_agente"])
echo "<option value=".$row["id_agente"].">".$row["nombre"];
}
echo '</select>';
if (isset($chunkdata))
echo "<input type='hidden' name='chunk' value='$chunkdata'>";
echo "<td class='datos' colspan=2 align='right'><input type=submit name='update_agent' class=sub value='".$lang_label["get_info"]."'>";
echo "</form>";
// -----------------------
// SOURCE MODULE FORM
// -----------------------
echo "<form method='post' action='index.php?sec=reporting&sec2=operation/reporting/graph_builder&add_module=1'>";
if (isset($chunkdata))
echo "<input type='hidden' name='chunk' value='$chunkdata'>";
if (isset($id_agent))
echo "<input type='hidden' name='id_agent' value='$id_agent'>";
echo "<tr><td class='datos2'>";
echo "<b>".$lang_label["modules"]."</b>";
echo "<td class='datos2' colspan=3>";
echo "<select name='id_module' size=1 style='width:180px;'>";
echo "<option value=-1> --";
if ($id_agent != 0){
// Populate Module/Agent combo
$sql1="SELECT * FROM tagente_modulo WHERE id_agente = ".$id_agent. " order by nombre";
$result = mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
echo "<option value=".$row["id_agente_modulo"].">".$row["nombre"];
}
}
echo "</select>";
echo "<tr><td class='datos'>";
echo "<b>Factor</b>";
echo "<td class='datos'>";
echo "<input type='text' name='factor' value='$factor' size=6>";
echo "<td class='datos'>";
echo "<b>Width</b>";
echo "<td class='datos'>";
echo "<input type='text' name='width' value='$width' size=6>";
echo "<tr><td class='datos2'>";
echo "<b>Graph Name</b>";
echo "<td class='datos2'>";
echo "<input type='text' name='graphname' value='$name' size=25>";
echo "<td class='datos2'>";
echo "<b>Height</b>";
echo "<td class='datos2'>";
echo "<input type='text' name='height' value='$height' size=6>";
echo "<tr><td class='datos'>";
echo "<b>Period</b>";
echo "<td class='datos'>";
echo "<select name='period'>";
if ($period != ""){
if ($period == 3600)
echo "<option value='".$period."'>Last Hour";
elseif ($period == 86400)
echo "<option value='".$period."'>Last day";
elseif ($period == 604800)
echo "<option value='".$period."'>Last week";
elseif ($period == 2592000)
echo "<option value='".$period."'>Last month";
}
echo "<option value=86400>Last day";
echo "<option value=3600>Last hour";
echo "<option value=604800>Last week";
echo "<option value=2592000>Last month";
echo "</select>";
echo "<td class='datos'>";
echo "<b>Show alert limit</b>";
echo "<td class='datos'>";
echo "<select name='alerts'>";
if ($alerts == 1){
echo "<option value=1>Yes";
echo "<option value=0>No";
} else {
echo "<option value=0>No";
echo "<option value=1>Yes";
}
echo "</select>";
echo "<tr><td class='datos2'>";
echo "<b>Render now</b>";
echo "<td class='datos2'>";
echo "<select name='render'>";
if ($render == 1){
echo "<option value=1>Yes";
echo "<option value=0>No";
} else {
echo "<option value=0>No";
echo "<option value=1>Yes";
}
echo "</select>";
echo "<td class='datos2'>";
echo "<b>Show events</b>";
echo "<td class='datos2'>";
echo "<select name='events'>";
if ($events == 1){
echo "<option value=1>Yes";
echo "<option value=0>No";
} else {
echo "<option value=0>No";
echo "<option value=1>Yes";
}
echo "</select>";
echo "<tr><td colspan=4 align='right'><input type=submit name='update_agent' class=sub value='".$lang_label["add"]."/".$lang_label["redraw"]."'>";
echo "</form>";
echo "</table>";
// Parse chunkdata and render graph
if ($render == 1){
// parse chunk
echo "<h3>".$lang_label["combined_image"]."</h3>";
echo "<img src='reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&label=$graphname&height=$height&width=$width&period=$period' border=1 alt=''>";
}
/*
if (isset($chunkdata)){
echo "<form method='post' action='index.php?sec=reporting&sec2=operation/reporting/graph_builder&save_graph=1'>";
echo "<input type='hidden' name='chunk' value='$chunkdata'>";
echo "<table width='500' cellpadding=4 cellpadding=4>";
echo "<tr><td class='datos2'>".$lang_name["custom_graph_name"];
echo "<td class='datos2'><input type='text' value='' size=20 name='graph_name'>";
echo "<td class='datos2'><input type=submit name='save' class=sub value='".$lang_label["save"]."'>";
echo "</table>";
}
*/
?>

View File

@ -54,10 +54,11 @@ if (comprueba_login() == 0) {
echo "<th class='datos'>".$lang_label['modules']."</th>";
echo "<th class='datos'>".$lang_label['lag']."</th>";
echo "<th class='datos'>".$lang_label['description']."</th>";
echo "<th class='datos'>".$lang_label['type']."</th>";
echo "<th class='datos' width=80>".$lang_label['type']."</th>";
// echo "<th class='datos'>".$lang_label['master']."</th>";
//echo "<th class='datos'>".$lang_label['checksum']."</th>";
//echo "<th class='datos'>".$lang_label['laststart']."</th>";
echo "<th class='datos'>".$lang_label['version']."</th>";
echo "<th class='datos'>".$lang_label['lastupdate']."</th>";
$color=1;
while ($row=mysql_fetch_array($result)){
@ -82,6 +83,7 @@ if (comprueba_login() == 0) {
$master = $row["master"];
$checksum = $row["checksum"];
$description = $row["description"];
$version = $row["version"];
$modules_server = 0;
if (($network_server == 1) OR ($data_server == 1))
@ -150,7 +152,7 @@ if (comprueba_login() == 0) {
if (($network_server == 1) OR ($data_server == 1) OR ($recon_server == 1))
// Progress bar render
echo '<img src="reporting/fgraph.php?tipo=progress&percent='.$percentil.'&height=20&width=100">';
echo '<img src="reporting/fgraph.php?tipo=progress&percent='.$percentil.'&height=18&width=80">';
// Number of modules
echo "<td class='$tdcolor'>";
@ -175,21 +177,31 @@ if (comprueba_login() == 0) {
if ($maxlag2 > $maxlag)
$maxlag = $maxlag2;
}
if ($maxlag < 60)
echo $maxlag." sec";
elseif ($maxlag < 86400)
echo format_numeric($maxlag/60) . " min";
elseif ($maxlag > 86400)
echo "+1 ".$lang_label["day"];
} elseif ($recon_server == 1) {
$sql1 = "SELECT * FROM trecon_task WHERE id_network_server = $id_server";
$result1=mysql_query($sql1);
$nowtime = time();
$maxlag=0;
while ($row1=mysql_fetch_array($result1)){
if (($row1["utimestamp"] + $row1["interval"]) < $nowtime)
if (($row1["utimestamp"] + $row1["interval_sweep"]) < $nowtime)
$maxlag2 = $nowtime - ($row1["utimestamp"] + $row1["interval"]);
if ($maxlag2 > $maxlag)
$maxlag = $maxlag2;
}
if ($maxlag < 60)
echo $maxlag." sec";
elseif ($maxlag < 86400)
echo format_numeric($maxlag/60) . " min";
elseif ($maxlag > 86400)
echo "+1 ".$lang_label["day"];
} else
echo "-";
echo "--";
echo "<td class='".$tdcolor."f9'>".substr($description,0,25);
echo "<td class='$tdcolor' align='middle'>";
if ($network_server == 1){
@ -213,10 +225,10 @@ if (comprueba_login() == 0) {
//echo "<td class='".$tdcolor."f9' align='middle'>"
//.substr($laststart,0,25)."</td>";
echo "<td class='".$tdcolor."f9' align='middle'>";
if ($status ==0)
echo "<font color='red'>";
else
echo "<font color='black'>";
echo $version;
echo "<td class='".$tdcolor."f9' align='middle'>";
// if ($status ==0)
echo substr($keepalive,0,25)."</td>";
}
echo '<tr><td colspan="11"><div class="raya"></div></td></tr></table>';

View File

@ -37,7 +37,6 @@ function graphic_error () {
}
function dame_fecha_grafico ($mh, $format){
// Date 24x7x30 hours ago (one month)
$m_year = date("Y", time()-$mh*60);
$m_month = date("m", time()-$mh*60);
@ -73,6 +72,255 @@ function dame_fecha_grafico_timestamp ($timestamp) {
return date('d/m H:i', $timestamp);
}
function graphic_combined_module ($module_list, $weight_list, $periodo, $width, $height , $title, $unit_name, $show_event=0, $show_alert=0 ) {
include ("../include/config.php");
require ("../include/languages/language_".$language_code.".php");
require_once 'Image/Graph.php';
$resolution = $config_graph_res * 50; // Number of "slices" we want in graph
//$unix_timestamp = strtotime($mysql_timestamp) // Convert MYSQL format tio utime
$fechatope = time() - $periodo; // limit date
$horasint = $periodo / $resolution; // Each intervalo is $horasint seconds length
$module_number = count($module_list);
// intervalo - This is the number of "rows" we are divided the time to fill data.
// more interval, more resolution, and slower.
// periodo - Gap of time, in seconds. This is now to (now-periodo) secs
// Init tables
for ($y = 0; $y < $module_number; $y++){
$real_data[$y] = array();
if ($show_event == 1)
$real_event[$y] = array();
if (isset($weight_list[$y])){
if ($weight_list[$y] == 0)
$weight_list[$y] = 1;
} else
$weight_list[$y] = 1;
}
$max_value = 0;
$min_value = 0;
// FOR EACH MODULE IN module_list....
for ($y = 0; $y < $module_number; $y++){
$id_agente_modulo = $module_list[$y];
$nombre_agente = dame_nombre_agente_agentemodulo($id_agente_modulo);
$id_agente = dame_agente_id($nombre_agente);
$nombre_modulo = dame_nombre_modulo_agentemodulo($id_agente_modulo);
$module_list_name[$y] = substr($nombre_agente,0,8)." - ".substr($nombre_modulo,0,8);
if ($weight_list[$y] != 1)
$module_list_name[$y] .= " (x".$weight_list[$y].")";
for ($x = 0; $x <= $resolution; $x++) {
$valores[$x][0] = 0; // SUM of all values for this interval
$valores[$x][1] = 0; // counter
$valores[$x][2] = $fechatope + ($horasint * $x); // [2] Top limit for this range
$valores[$x][3] = $fechatope + ($horasint*($x+1)); // [3] Botom limit
$valores[$x][4] = 0; // MIN
$valores[$x][5] = 0; // MAX
$valores[$x][6] = 0; // Event
}
// Init other general variables
if ($show_event == 1){
// If we want to show events in graphs
$sql1="SELECT utimestamp FROM tevento WHERE id_agente = $id_agente AND utimestamp > $fechatope";
$result=mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
$utimestamp = $row[0];
for ($i=0; $i <= $resolution; $i++) {
if ( ($utimestamp <= $valores[$i][3]) && ($utimestamp >= $valores[$i][2]) ){
$real_event[$i]=1;
}
}
}
}
$alert_high = 0;
$alert_low = 0;
if ($show_alert == 1){
// If we want to show alerts limits
$sql1="SELECT * FROM talerta_agente_modulo where id_agente_modulo = ".$id_agente_modulo;
$result=mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
if ($row["dis_max"] > $alert_high)
$alert_high = $row["dis_max"];
if ($row["dis_max"] > $alert_high)
$min = $row["dis_min"];
}
}
$previous=0;
// Get the first data outsite (to the left---more old) of the interval given
$sql1="SELECT datos,utimestamp FROM tagente_datos WHERE id_agente = $id_agente AND id_agente_modulo = $id_agente_modulo AND utimestamp < $fechatope ORDER BY utimestamp DESC LIMIT 1";
$result=mysql_query($sql1);
if ($row=mysql_fetch_array($result))
$previous=$row[0];
$sql1="SELECT datos,utimestamp FROM tagente_datos WHERE id_agente = $id_agente AND id_agente_modulo = $id_agente_modulo AND utimestamp > $fechatope";
if ($result=mysql_query($sql1))
while ($row=mysql_fetch_array($result)){
$datos = $row[0];
$utimestamp = $row[1];
if ($datos > 0) {
for ($i=0; $i <= $resolution; $i++) {
if ( ($utimestamp <= $valores[$i][3]) && ($utimestamp >= $valores[$i][2]) ){
$valores[$i][0]=$valores[$i][0]+$datos;
$valores[$i][1]++;
// Init min value
if ($valores[$i][4] == 0)
$valores[$i][4] = $datos;
else {
// Check min value
if ($datos < $valores[$i][4])
$valores[$i][4] = $datos;
}
// Check max value
if ($datos > $valores[$i][5])
$valores[$i][5] = $datos;
$i = $resolution+1; // BREAK FOR
}
}
}
}
// Calculate Average value for $valores[][0]
for ($x =0; $x <= $resolution; $x++) {
if ($valores[$x][1] > 0){
$valores[$x][0] = $valores[$x][0]/$valores[$x][1];
$real_data[$y][$x] = $weight_list[$y]*($valores[$x][0]/$valores[$x][1]);
} else {
$valores[$x][0] = $previous;
$real_data[$y][$x] = $previous * $weight_list[$y];
$valores[$x][4] = $previous;
$valores[$x][5] = $previous;
}
// Get max value for all graph
if ($valores[$x][5] * $weight_list[$y] > $max_value )
$max_value = $valores[$x][5] * $weight_list[$y];
// Take prev. value
// TODO: CHeck if there are more than 24hours between
// data, if there are > 24h, module down.
$previous = $valores[$x][0];
}
}
// Create graph
// *************
$Graph =& Image_Graph::factory('graph', array($width, $height));
// add a TrueType font
$Font =& $Graph->addNew('font', $config_fontpath);
$Font->setSize(6);
$Graph->setFont($Font);
if ($periodo == 86400)
$title_period = "Last day";
elseif ($periodo == 604800)
$title_period = "Last week";
elseif ($periodo == 3600)
$title_period = "Last hour";
elseif ($periodo == 2419200)
$title_period = "Last month";
else
$title_period = "Last ".format_numeric(($periodo / (3600*24)),2)." days";
$Graph->add(
Image_Graph::vertical(
Image_Graph::vertical(
$Title = Image_Graph::factory('title', array(' Pandora FMS Graph - '.$title_period, 10)),
$Subtitle = Image_Graph::factory('title', array(' '.$title, 7)),
90
),
Image_Graph::horizontal(
$Plotarea = Image_Graph::factory('plotarea'),
$Legend = Image_Graph::factory('legend'),
80
),
20)
);
$Legend->setPlotarea($Plotarea);
$Title->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
$Subtitle->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
// Create the dataset
// Merge data into a dataset object (sancho)
// $Dataset =& Image_Graph::factory('dataset');
for ($y = 0; $y < $module_number; $y++){
$dataset[$y] = Image_Graph::factory('dataset');
$dataset[$y] -> setName($module_list_name[$y]);
}
if ($show_event == 1){
$dataset_event = Image_Graph::factory('dataset');
$dataset_event -> setName("Event Fired");
}
// ... and populated with data ...
for ($cc=0; $cc <= $resolution; $cc++) {
$tdate = date('d/m', $valores[$cc][2])."\n".date('H:i', $valores[$cc][2]);
for ($y = 0; $y < $module_number; $y++){
$dataset[$y]->addPoint($tdate, $real_data[$y][$cc]);
if (($show_event == 1) AND (isset($real_event[$cc]))) {
$dataset_event->addPoint($tdate, $max_value);
}
}
}
if ($max_value > 0){
// Show events !
if ($show_event == 1){
$Plot =& $Plotarea->addNew('Plot_Impulse', array($dataset_event));
$Plot->setLineColor( 'black' );
$Marker_event =& Image_Graph::factory('Image_Graph_Marker_Cross');
$Plot->setMarker($Marker_event);
$Marker_event->setFillColor( 'red' );
$Marker_event->setLineColor( 'red' );
$Marker_event->setSize ( 5 );
}
// Show limits (for alert or whathever you want...
if ($show_alert == 1){
$Plot =& $Plotarea->addNew('Image_Graph_Axis_Marker_Area', IMAGE_GRAPH_AXIS_Y);
$Plot->setFillColor( 'blue@0.1' );
$Plot->setLowerBound( $alert_low);
$Plot->setUpperBound( $alert_high );
}
// create the 1st plot as smoothed area chart using the 1st dataset
$Plot =& $Plotarea->addNew('area', array(&$dataset));
$Plot->setLineColor('gray@0.4');
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
// $AxisX->Hide();
$AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY->setLabelOption("showtext",true);
$AxisY->setLabelInterval(ceil($max_value / 5));
$AxisY->showLabel(IMAGE_GRAPH_LABEL_ZERO);
if ($unit_name != "")
$AxisY->setTitle($unit_name, 'vertical');
$AxisX->setLabelInterval($resolution / 10);
//$AxisY->forceMinimum($minvalue);
$AxisY->forceMaximum($max_value+($max_value/12)) ;
$GridY2 =& $Plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y_SECONDARY);
$GridY2->setLineColor('gray');
$GridY2->setFillColor('lightgray@0.05');
// set line colors
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
$Plot->setFillStyle($FillArray);
$FillArray->addColor('#BFFF51@0.6'); // Green
$FillArray->addColor('yellow@0.6'); // yellow
$FillArray->addColor('#FF5FDF@0.6'); // pink
$FillArray->addColor('orange@0.6'); // orange
$FillArray->addColor('#7D8AFF@0.6'); // blue
$FillArray->addColor('#FF302A@0.6'); // red
$FillArray->addColor('brown@0.6'); // brown
$FillArray->addColor('green@0.6');
$AxisY_Weather =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$Graph->done();
} else
graphic_error ();
}
function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $draw_events,
$width, $height , $title, $unit_name ) {
@ -183,7 +431,7 @@ function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $draw_events,
elseif ($periodo == 2419200)
$title_period = "Last month";
else
$title_period = "Last ".($periodo / (3600*24))." days";
$title_period = "Last ".format_numeric(($periodo / (3600*24)),2)." days";
$Graph->add(
Image_Graph::vertical(
@ -243,9 +491,13 @@ function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $draw_events,
// set line colors
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
$Plot->setFillStyle($FillArray);
$FillArray->addColor('yellow@0.5'); // MAX
$FillArray->addColor('orange@0.6'); // AVG
$FillArray->addColor('brown@0.7'); // MIN
$FillArray->addColor('yellow@0.5');
$FillArray->addColor('orange@0.6');
$FillArray->addColor('brown@0.7');
$FillArray->addColor('red@0.7');
$FillArray->addColor('blue@0.7');
$FillArray->addColor('green@0.7');
$FillArray->addColor('black@0.7');
$AxisY_Weather =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
@ -1108,65 +1360,23 @@ function grafico_db_agentes_paquetes() {
$graph->Stroke();
}
function grafico_db_agentes_purge($id_agente) {
function grafico_db_agentes_purge ($id_agente, $width, $height) {
include ("../include/config.php");
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_pie.php");
include ("jpgraph/jpgraph_pie3d.php");
require_once 'Image/Graph.php';
require ("../include/languages/language_".$language_code.".php");
// All data (now)
$purge_all=date("Y-m-d H:i:s",time());
// 1 day
$d1_year = date("Y", time()-28800);
$d1_month = date("m", time()-28800);
$d1_day = date ("d", time()-28800);
$d1_hour = date ("H", time()-28800);
$minuto = date("i",time());
$segundo = date("s",time());
$d1 = $d1_year."-".$d1_month."-".$d1_day." ".$d1_hour.":".$minuto.":".$segundo."";
// 3 days
$d3_year = date("Y", time()-86400);
$d3_month = date("m", time()-86400);
$d3_day = date ("d", time()-86400);
$d3_hour = date ("H", time()-86400);
$d3 = $d3_year."-".$d3_month."-".$d3_day." ".$d3_hour.":".$minuto.":".$segundo."";
// Fecha 24x7 Horas (una semana)
$week_year = date("Y", time()-604800);
$week_month = date("m", time()-604800);
$week_day = date ("d", time()-604800);
$week_hour = date ("H", time()-604800);
$d7 = $week_year."-".$week_month."-".$week_day." ".$week_hour.":".$minuto.":".$segundo."";
// Fecha 24x7x2 Horas (dos semanas)
$week2_year = date("Y", time()-1209600);
$week2_month = date("m", time()-1209600);
$week2_day = date ("d", time()-1209600);
$week2_hour = date ("H", time()-1209600);
$d14 = $week2_year."-".$week2_month."-".$week2_day." ".$week2_hour.":".$minuto.":".$segundo."";
// Fecha de hace 24x7x30 Horas (un mes)
$month_year = date("Y", time()-2592000);
$month_month = date("m", time()-2592000);
$month_day = date ("d", time()-2592000);
$month_hour = date ("H", time()-2592000);
$d30 = $month_year."-".$month_month."-".$month_day." ".$month_hour.":".$minuto.":".$segundo."";
// Three months
$month3_year = date("Y", time()-7257600);
$month3_month = date("m", time()-7257600);
$month3_day = date ("d", time()-7257600);
$month3_hour = date ("H", time()-7257600);
$d90 = $month3_year."-".$month3_month."-".$month3_day." ".$month3_hour.":".$minuto.":".$segundo."";
$data = array();
$legend = array();
$fechas= array($d90, $d30, $d7, $d1);
$fechas_label = array("> 30 days","7-30 days","2-7 days","24Hr");
$d90 = time()-(2592000*3);
$d30 = time()-2592000;
$d7 = time()-604800;
$d1 = time()-86400;
$fechas = array($d90, $d30, $d7, $d1);
$fechas_label = array("30-90 days","7-30 days","This week","Today");
// Calc. total packets
$sql1="SELECT COUNT(id_agente_datos) FROM tagente_datos";;
@ -1174,30 +1384,18 @@ function grafico_db_agentes_purge($id_agente) {
$row2=mysql_fetch_array($result2);
$total = $row2[0];
for ($a=0;$a<sizeof($fechas);$a++){ // 4 x intervals will be enought, increase if your database is very very quickly :)
for ($a=0; $a < sizeof ($fechas); $a++){
// 4 x intervals will be enought, increase if your database is very very fast :)
if ($a==3)
$sql1="SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE timestamp >= '".$fechas[$a]."' ";
$sql1="SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp >= ".$fechas[$a];
else
$sql1="SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE timestamp >= '".$fechas[$a]."' AND timestamp < '".$fechas[$a+1]."' ";
$sql1="SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp >= ".$fechas[$a]." AND utimestamp < ".$fechas[$a+1];
$result=mysql_query($sql1);
$row=mysql_fetch_array($result);
$data[] = $row[0];
$legend[]=$fechas_label[$a]." ( ".$row[0]." )";
}
// 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 :-))))
for ($a=0;$a < sizeof($data);$a++){
for ($b=$a; $b <sizeof($data); $b++)
if ($data[$b] > $data[$a]){
$temp = $data[$a];
$temp_label = $legend[$a];
$data[$a] = $data[$b];
$legend[$a] = $legend[$b];
$data[$b] = $temp;
$legend[$b] = $temp_label;
}
}
$mayor = 0;
$mayor_data =0;
for ($a=0;$a < sizeof($data); $a++)
@ -1206,21 +1404,59 @@ function grafico_db_agentes_purge($id_agente) {
$mayor_data = $data[$a];
}
$graph = new PieGraph(500,200,"auto");
$graph->SetMarginColor('white@0.2');
$graph->title->Set($lang_label["packets_by_date"]." ( Tot - $total ) ");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->SetShadow();
$graph->SetAlphaBlending();
$graph->SetFrame(true);
$p1 = new PiePlot3D($data);
$p1->ExplodeSlice($mayor);
$p1->SetSize(0.35);
$p1->SetCenter(0.3);
$p1->SetLegends($legend);
$graph->Add($p1);
$graph->img->SetAntiAliasing();
$graph->Stroke();
if ($total> 1){
// create the graph
$Graph =& Image_Graph::factory('graph', array($width, $height));
// add a TrueType font
$Font =& $Graph->addNew('font', $config_fontpath);
// set the font size to 7 pixels
$Font->setSize(7);
$Graph->setFont($Font);
// create the plotarea
$Graph->add(
Image_Graph::horizontal(
$Plotarea = Image_Graph::factory('plotarea'),
$Legend = Image_Graph::factory('legend'),
70
)
);
$Legend->setPlotarea($Plotarea);
// Create the dataset
// Merge data into a dataset object (sancho)
$Dataset1 =& Image_Graph::factory('dataset');
for ($a=0;$a < sizeof($data); $a++){
$Dataset1->addPoint($legend[$a], $data[$a]);
}
$Plot =& $Plotarea->addNew('pie', $Dataset1);
$Plotarea->hideAxis();
// create a Y data value marker
$Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_PCT_Y_TOTAL);
// create a pin-point marker type
$PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(1, &$Marker));
// and use the marker on the 1st plot
$Plot->setMarker($PointingMarker);
// format value marker labels as percentage values
$Marker->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.1f%%'));
$Plot->Radius = 15;
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
$Plot->setFillStyle($FillArray);
$FillArray->addColor('green@0.7');
$FillArray->addColor('yellow@0.7');
$FillArray->addColor('red@0.7');
$FillArray->addColor('orange@0.7');
$FillArray->addColor('blue@0.7');
$FillArray->addColor('purple@0.7');
$FillArray->addColor('lightgreen@0.7');
$FillArray->addColor('lightblue@0.7');
$FillArray->addColor('lightred@0.7');
$FillArray->addColor('grey@0.6', 'rest');
$Plot->explode(6);
$Plot->setStartingAngle(145);
// output the Graph
$Graph->done();
} else
graphic_error ();
}
function drawWarning($width,$height) {
@ -1418,6 +1654,12 @@ if (isset($_GET["id"]))
$id = entrada_limpia($_GET["id"]);
else
$id = 0;
if (isset($_GET["weight_l"]))
$weight_l = entrada_limpia($_GET["weight_l"]);
else
$weight_l = 0;
if (isset($_GET["width"]))
$width = entrada_limpia($_GET["width"]);
else
@ -1481,7 +1723,7 @@ if (isset($_GET["tipo"])){
elseif ($_GET["tipo"]=="db_agente_paquetes")
grafico_db_agentes_paquetes();
elseif ($_GET["tipo"] =="db_agente_purge")
grafico_db_agentes_purge(-1);
grafico_db_agentes_purge(-1, $width, $height);
elseif ($_GET["tipo"] =="group_events")
grafico_eventos_grupo();
elseif ($_GET["tipo"] =="user_events")
@ -1506,6 +1748,14 @@ if (isset($_GET["tipo"])){
$percent= $_GET["percent"];
progress_bar($percent,$width,$height);
}
elseif ( $_GET["tipo"] =="combined"){
// Split id to get all parameters
$module_list = array();
$module_list = split ( ",", $id);
$weight_list = array();
$weight_list = split ( ",", $weight_l);
graphic_combined_module ($module_list, $weight_list, $period, $width, $height , $label, $unit_name );
}
else
graphic_error ();
} else

View File

@ -169,10 +169,10 @@ if (comprueba_login() == 0) {
<tr><td>
<?php
echo "<input type='hidden' name='$id' value='$id'>";
echo "<input type='hidden' name='$refresh' value='$refresh'>";
echo "<input type='hidden' name='$zoom' value='$zoom'>";
echo "<input type='hidden' name='$events' value='$draw_events'>";
echo "<input type='hidden' name='id' value='$id'>";
echo "<input type='hidden' name='refresh' value='$refresh'>";
echo "<input type='hidden' name='zoom' value='$zoom'>";
echo "<input type='hidden' name='event' value='$draw_events'>";
?>
</td><td>