2007-06-22 Sancho Lerena <slerena@artica.es>

This commit should finish Pandora FMS Console 1.3 beta 1 :-)

        * pandoradb_data.sql: Added default news for new instalation.

        * include/styles/op.css: Changed icon for Visual Console.

        * include/config.inc.php: Some minimal changes for skeleton.

        * include/languages/language_en.php: Added final strings (hope!).

        * index.php: Adjusted some issues for production.

        * operation/incidents/incident_statistics.php: Added titles.

        * operation/events/event_statistics.php: Added titles.

        * operation/agentes/tactical.php: DivZero bug fixed.

        * images/image_problem.png: Updated image with new logo.

        * reporting/fgraph.php: Added generic_bar_graph and, at least, no
        more jpgraph graph usage !. All graphs are using GD/Pear Graph
        now.

        * general/logon_ok.php: Fixed the same bug that in tactical.

        * godmode/db/db_info.php: Added titles.

        * godmode/db/db_purge.php: Now render detailed info in graph for
        each agent selected.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@534 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2007-06-22 12:00:04 +00:00
parent 9db0e03a91
commit 5b15ef46f4
14 changed files with 236 additions and 345 deletions

View File

@ -1,3 +1,37 @@
2007-06-22 Sancho Lerena <slerena@artica.es>
This commit should finish Pandora FMS Console 1.3 beta 1 :-)
* pandoradb_data.sql: Added default news for new instalation.
* include/styles/op.css: Changed icon for Visual Console.
* include/config.inc.php: Some minimal changes for skeleton.
* include/languages/language_en.php: Added final strings (hope!).
* index.php: Adjusted some issues for production.
* operation/incidents/incident_statistics.php: Added titles.
* operation/events/event_statistics.php: Added titles.
* operation/agentes/tactical.php: DivZero bug fixed.
* images/image_problem.png: Updated image with new logo.
* reporting/fgraph.php: Added generic_bar_graph and, at least, no
more jpgraph graph usage !. All graphs are using GD/Pear Graph
now.
* general/logon_ok.php: Fixed the same bug that in tactical.
* godmode/db/db_info.php: Added titles.
* godmode/db/db_purge.php: Now render detailed info in graph for
each agent selected.
2007-06-22 Raul Mateos <raulofpandora@gmail.com>
* include/languages/language_en.php: More strings.

View File

@ -76,9 +76,19 @@
$total_alerts = $data_alert_total + $monitor_alert_total;
$total_checks = $data_checks + $monitor_checks;
if ($monitor_checks > 0){
$monitor_health = format_numeric ((($monitor_ok - $monitor_alert - $monitor_unknown)/ $monitor_checks) * 100,1);
} else
$monitor_health = 100;
if ($data_checks > 0){
$data_health = format_numeric ( (($data_checks -($data_unknown + $data_alert)) / $data_checks ) * 100,1);;
} else
$data_health = 100;
if (($data_checks != 0) OR ($data_checks != 0)){
$global_health = format_numeric( ((($monitor_ok -$monitor_alert - $monitor_unknown )+($data_checks -($data_unknown + $data_alert))) / ($data_checks + $monitor_checks) ) * 100, 1);
} else
$global_health = 100;
echo "<h3>".$lang_label["tactical_indicator"]."</h3>";
echo "<img src='reporting/fgraph.php?tipo=odo_tactic&value1=$global_health&value2=$data_health&value3=$monitor_health'>";

View File

@ -23,9 +23,13 @@ if (comprueba_login() == 0)
echo "<h2>".$lang_label["dbmain_title"]." &gt; ";
echo $lang_label["db_info2"]."<a href='help/".$help_code."/chap8.php#81' target='_help' class='help'>&nbsp;<span>".$lang_label["help"]."</span></a></h2>";
echo "<table border=0>";
echo "<tr><td><img src='reporting/fgraph.php?tipo=db_agente_modulo'><br>";
echo "<tr><td>";
echo '<h3>'.$lang_label["db_agente_modulo"].'</h3>';
echo "<img src='reporting/fgraph.php?tipo=db_agente_modulo&width=600&height=200'><br>";
echo "<tr><td><br>";
echo "<tr><td><img src='reporting/fgraph.php?tipo=db_agente_paquetes'><br>";
echo "<tr><td>";
echo '<h3>'.$lang_label["db_agente_paquetes"].'</h3>';
echo "<img src='reporting/fgraph.php?tipo=db_agente_paquetes&width=600&height=200'><br>";
echo "<br><br><a href='index.php?sec=gdbman&sec2=godmode/db/db_info_data'>".$lang_label["press_db_info"]."</a>";
echo "</table>";
}

View File

@ -19,12 +19,16 @@ if (comprueba_login() == 0)
- A more powerful selection (by Agent, by Module, etc).
*/
?>
<h2><?php echo $lang_label["dbmain_title"] ?> &gt;
<?php echo $lang_label["db_purge"] ?><a href='help/<?php echo $help_code ?>/chap8.php#8' target='_help' class='help'>&nbsp;<span><?php echo $lang_label["help"] ?></span></a></h2>
<img src="reporting/fgraph.php?tipo=db_agente_purge&id=-1"><br><br>
<h3><?php echo $lang_label["get_data_agent"] ?></h3>
<?php
if (isset($_POST["agent"])){
$id_agent =$_POST["agent"];
} else
$id_agent = -1;
echo '<h2>'.$lang_label["dbmain_title"].' &gt;'.$lang_label["db_purge"]."<a href='help/$help_code/chap8.php#8' target='_help' class='help'>&nbsp;<span>".$lang_label["help"]."</span></a></h2>";
echo "<img src='reporting/fgraph.php?tipo=db_agente_purge&id=$id_agent'>";
echo "<br><br>";
echo '<h3>'.$lang_label["get_data_agent"].'</h3>';
// All data (now)
$purge_all=date("Y-m-d H:i:s",time());
@ -77,9 +81,7 @@ if (comprueba_login() == 0)
# ======================================
# Purge data using dates
if (isset($_POST["agent"])){
$id_agent =$_POST["agent"];
}
# Purge data using dates
if (isset($_POST["purgedb"])){
$from_date =$_POST["date_purge"];
@ -148,8 +150,8 @@ if (comprueba_login() == 0)
$sql_2='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_agent;
$result_t=mysql_query($sql_2);
while ($row=mysql_fetch_array($result_t)){
flush();
ob_flush();
/* flush();
ob_flush(); */
$rango00=mysql_query('SELECT COUNT(*) FROM tagente_datos WHERE id_agente_modulo = '.$row["id_agente_modulo"].' and timestamp > "'.$d1.'"');
$rango0=mysql_query('SELECT COUNT(*) FROM tagente_datos WHERE id_agente_modulo = '.$row["id_agente_modulo"].' and timestamp > "'.$d3.'"');
$rango1=mysql_query('SELECT COUNT(*) FROM tagente_datos WHERE id_agente_modulo = '.$row["id_agente_modulo"].' and timestamp > "'.$week.'"');

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,15 +1,16 @@
<?php
// Pandora FMS - the Free monitoring system
// ========================================
// Copyright (c) 2004-2007 Sancho Lerena, slerena@openideas.info
// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas
// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com
// Main PHP/SQL code development, project architecture and management.
// Copyright (c) 2004-2007 Raul Mateos Martin, raulofpandora@gmail.com
// Copyright (c) 2006-2007 Jose Navarro jose@jnavarro.net
// Copyright (c) 2006-2007 Jonathan Barajas, jonathan.barajas[AT]gmail[DOT]com
// CSS and some PHP code additions
// Copyright (c) 2006 Jose Navarro <jnavarro@jnavarro.net>
// Additions to code for Pandora FMS 1.2 graph code
//
// 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
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ -17,13 +18,16 @@
// 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.
// This is the base config file
// Pandora FMS 1.x uses icons from famfamfam, licensed under CC Atr. 2.5
// Silk icon set 1.3 (cc) Mark James, http://www.famfamfam.com/lab/icons/silk/
// Pandora FMS 1.x uses Pear Image::Graph code
//Pandora Version
if (!isset($build_version))
$build_version="PC070602";
$build_version="PC070622";
if (!isset($pandora_version))
$pandora_version="v1.3 devel";
$pandora_version="v1.3 Beta 1";
// Database configuration (default ones)
//$dbname="pandora13"; // MySQL DataBase
@ -32,7 +36,7 @@ if (!isset($pandora_version))
//$dbhost="localhost"; // MySQL Host
// This is used for reporting, please add "/" character at the end
//$config_homedir = "/var/www/pandora2/";
//$config_homedir = "/var/www/pandora/";
// Do not display any ERROR
//error_reporting(0); // Need to use active console at this moment

View File

@ -876,6 +876,15 @@ $lang_label["map_item_add"] = "Add map item";
$lang_label["graph_event_total"] = "Event graph";
$lang_label["graph_event_group"] = "Event graph by group";
$lang_label["graph_event_user"] = "Event graph by user";
$lang_label["db_agente_paquetes"] = "Packets per agent";
$lang_label["db_agente_modulo"] = "Modules per agent";
$lang_label["inc_stat_status"] = "Incidents by status";
$lang_label["inc_stat_priority"] = "Incidents by priority";
$lang_label["inc_stat_user"] = "Incidents by user";
$lang_label["inc_stat_source"] = "Incidents by source";
$lang_label["inc_stat_group"] = "Incidents by group";
$lang_label["no_layout_def"] = "There are no defined layouts";
$lang_label["no_reporting_def"] = "There are no defined reportings";
$lang_label["no_map_def"] = "There are no defined maps";

View File

@ -51,7 +51,7 @@ div#op7s>ul, div#op8s>ul, div#op9s>ul {
background: url(../../images/reporting.png) no-repeat 4px 4px;
}
#op9 li, #op9 li:hover, #op9s li {
background: url(../../images/application.png) no-repeat 4px 3px;
background: url(../../images/monitor.png) no-repeat 4px 3px;
}
div.arrow>ul, div.arrows>ul, div#arrowl>ul, div#arrowls>ul {
width: 75%;

View File

@ -1,6 +1,6 @@
<?php
// Pandora FMS - the Free monitoring system
// Pandora FMS - the Free Monitoring System
// ========================================
// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com
// Main PHP/SQL code development, project architecture and management.
@ -8,7 +8,7 @@
// CSS and some PHP code additions
// Copyright (c) 2006 Jose Navarro <jnavarro@jnavarro.net>
// Additions to code for Pandora FMS 1.2 graph code
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
@ -25,13 +25,13 @@
// Pandora FMS 1.x uses Pear Image::Graph code
//Pandora Version, if not defined here it would take from config.php
$build_version="PC070612";
$pandora_version="v1.3 devel";
$build_version="PC070622";
$pandora_version="v1.3 Beta 1";
global $build_version;
global $pandora_version;
// Set to 1 to do not check for installer or config file (for development!).
$develop_bypass = 1;
$develop_bypass = 0;
if ($develop_bypass != 1){
// If no config file, automatically try to install

View File

@ -35,106 +35,6 @@
echo "<h2>".$lang_label["ag_title"]." &gt; ";
echo $lang_label["tactical_view"]."</h2>";
/*
// Get group list that user has access
$mis_grupos = list_group2 ($id_user);
$contador_grupo = 0;
$contador_agente = 0;
$array_index = 0;
// Init final counters
$monitor_checks = 0;
$monitor_ok = 0;
$monitor_bad = 0;
$monitor_unknown =0;
$monitor_alert = 0;
$total_agents = 0;
$data_checks = 0;
$data_unknown =0;
$data_alert = 0;
$data_alert_total = 0;
$monitor_alert_total = 0;
$monitor->checks = 0;
$monitor->ok = 0;
$monitor->bad =0;
$monitor->unknown = 0;
$monitor->alert = 0;
$monitor->alert_total = 0;
$total->agents = 0;
$data->checks = 0;
$data->unknown = 0;
$data->alert = 0;
$data->alert_total= 0;
$ahora=date("Y/m/d H:i:s");
$ahora_sec = strtotime($ahora);
// Prepare data to show
// For each valid group for this user, take data from agent and modules
foreach ($mis_grupos as $migrupo) {
if ($migrupo != "") {
$existen_agentes = 0;
$sql0 = "SELECT COUNT(id_agente) FROM tagente WHERE id_grupo = $migrupo AND disabled = 0";
$result0 = mysql_query ($sql0);
$row0 = mysql_fetch_array ($result0);
$total_agents = $total_agents + $row0[0];
if ($row0[0] > 0)
$existen_agentes = 1;
// SQL Join to get monitor status for agents belong this group
$sql1 = "SELECT tagente.id_agente, tagente_estado.estado, tagente_estado.datos, tagente_estado.current_interval, tagente_estado.utimestamp, tagente_estado.id_agente_modulo FROM tagente, tagente_estado WHERE tagente.disabled = 0 AND tagente.id_grupo = $migrupo AND tagente.id_agente = tagente_estado.id_agente";
if ($result1 = mysql_query ($sql1)){
while ($row1 = mysql_fetch_array ($result1)) {
$id_agente = $row1[0];
$estado = $row1[1];
$datos = $row1[2];
$module_interval = $row1[3];
$seconds = $ahora_sec - $row1[4];
$id_agente_modulo = $row1[5];
if ($estado != 100){
// Monitor check
$monitor_checks++;
if ($seconds >= ($module_interval*2))
$monitor_unknown++;
elseif ($datos != 0) {
$monitor_ok++;
} else {
$monitor_bad++;
}
// Alert
$sql2 = "SELECT times_fired FROM talerta_agente_modulo WHERE id_agente_modulo = $id_agente_modulo";
if ($result2 = mysql_query ($sql2)){
if ($row2 = mysql_fetch_array ($result2)){
$monitor_alert_total++;
if ($row2[0] > 0)
$monitor_alert++;
}
}
} else {
// Data check
if ($seconds >= ($module_interval*2))
$data_unknown++;
$data_checks++;
// Alert
$sql2 = "SELECT times_fired FROM talerta_agente_modulo WHERE id_agente_modulo = $id_agente_modulo";
if ($result2 = mysql_query ($sql2)){
if ($row2 = mysql_fetch_array ($result2)) {
$data_alert_total++;
if ($row2[0] > 0)
$data_alert++;
}
}
}
}
}
}
}
*/
$data = general_stats($id_user,0);
$monitor_checks = $data[0];
$monitor_ok = $data[1];
@ -226,7 +126,7 @@
$data_health = format_numeric ( (($data_checks -($data_unknown + $data_alert)) / $data_checks ) * 100,1);;
} else
$data_health = 100;
if (($data_checks == 0) && ($data_checks == 0)){
if (($data_checks != 0) OR ($data_checks != 0)){
$global_health = format_numeric( ((($monitor_ok -$monitor_alert - $monitor_unknown )+($data_checks -($data_unknown + $data_alert))) / ($data_checks + $monitor_checks) ) * 100, 1);
} else
$global_health = 100;

View File

@ -26,15 +26,17 @@ if (comprueba_login() == 0) {
echo "<h2>".$lang_label["events"]." &gt; ";
echo $lang_label["event_statistics"]."<a href='help/".$help_code."/chap5.php#51' target='_help' class='help'>&nbsp;<span>".$lang_label["help"]."</span></a></h2>";
echo "<br><br>";
echo "<table width=95%>";
echo "<tr><td>";
echo "<h2>".$lang_label["graph_event_total"]."</h2>";
echo '<img src="reporting/fgraph.php?tipo=total_events" border=0>';
echo "<br><br>";
echo '<img src="reporting/fgraph.php?tipo=total_events&width=300&height=200" border=0>';
echo "<td>";
echo "<h2>".$lang_label["graph_event_user"]."</h2>";
echo '<img src="reporting/fgraph.php?tipo=user_events" border=0>';
echo "<br><br>";
echo '<img src="reporting/fgraph.php?tipo=user_events&width=300&height=200" border=0>';
echo "<tr><td>";
echo "<h2>".$lang_label["graph_event_group"]."</h2>";
echo '<img src="reporting/fgraph.php?tipo=group_events&width=300&height=200" border=0>';
echo "<br><br>";
echo "</table>";
} else {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access event viewer");
require ("general/noaccess.php");

View File

@ -26,18 +26,25 @@ if (comprueba_login() == 0) {
if (give_acl($id_user, 0, "IR")==1) {
echo "<h2>".$lang_label["incident_manag"]." &gt; ";
echo $lang_label["statistics"]."<a href='help/".$help_code."/chap4.php#44' target='_help' class='help'>&nbsp;<span>".$lang_label["help"]."</span></a></h2>";
?>
<img src="reporting/fgraph.php?tipo=estado_incidente" border=0>
<br><br>
<img src="reporting/fgraph.php?tipo=prioridad_incidente" border=0>
<br><br>
<img src="reporting/fgraph.php?tipo=group_incident" border=0>
<br><br>
<img src="reporting/fgraph.php?tipo=user_incident" border=0>
<br><br>
<img src="reporting/fgraph.php?tipo=source_incident" border=0>
<br><br>
<?php
echo "<table width = 90%>";
echo "<tr><td>";
echo '<h3>'.$lang_label["inc_stat_status"].'</h3>';
echo '<img src="reporting/fgraph.php?tipo=estado_incidente" border=0>';
echo "<td>";
echo '<h3>'.$lang_label["inc_stat_priority"].'</h3>';
echo '<img src="reporting/fgraph.php?tipo=prioridad_incidente" border=0>';
echo "<tr><td>";
echo '<h3>'.$lang_label["inc_stat_group"].'</h3>';
echo '<img src="reporting/fgraph.php?tipo=group_incident" border=0>';
echo "<td>";
echo '<h3>'.$lang_label["inc_stat_user"].'</h3>';
echo '<img src="reporting/fgraph.php?tipo=user_incident" border=0>';
echo "<tr><td>";
echo '<h3>'.$lang_label["inc_stat_source"].'</h3>';
echo '<img src="reporting/fgraph.php?tipo=source_incident" border=0>';
echo "<td>";
echo "</table>";
} else {
require ("general/noaccess.php");
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Incident section");

View File

@ -124,3 +124,4 @@ INSERT INTO `tusuario_perfil` VALUES (1,'demo',1,1,'admin'),(2,'admin',5,1,'admi
INSERT INTO `tperfil` VALUES (1,'Operator (Read)',0,1,0,1,0,0,0,0,0,0),(2,'Operator (Write)',1,1,0,1,0,0,0,0,0,0),(3,'Chief Operator',1,1,1,1,0,0,0,0,0,0),(4,'Group coordinator',1,1,1,1,1,1,1,0,0,0),(5,'Pandora Administrator',1,1,1,1,1,1,1,1,1,1);
INSERT INTO `tnews` VALUES (1,'admin','Welcome to Pandora FMS 1.3 !','This is our new console, a lot of new features has been added from last version. Please read documentation about it and be free to test any option.\r\n\r\nPandora FMS team.','2007-06-22 13:03:20');

View File

@ -3,16 +3,15 @@
// 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
// Main PHP/SQL code development, project architecture and management.
// Copyright (c) 2004-2007 Raul Mateos Martin, raulofpandora@gmail.com
// CSS and some PHP additions
// Copyright (c) 2006 Jose Navarro <contacto@indiseg.net>
// Additions to Pandora FMS 1.2 graph code
// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es
// CSS and some PHP code additions
// Copyright (c) 2006 Jose Navarro <jnavarro@jnavarro.net>
// Additions to code for Pandora FMS 1.2 graph code
//
// 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
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ -20,7 +19,11 @@
// 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
// Pandora FMS 1.x uses icons from famfamfam, licensed under CC Atr. 2.5
// Silk icon set 1.3 (cc) Mark James, http://www.famfamfam.com/lab/icons/silk/
// Pandora FMS 1.x uses Pear Image::Graph code
include ("../include/config.php");
include ("../include/functions.php");
include ("../include/functions_db.php");
@ -642,7 +645,7 @@ function generic_pie_graph ($width=300, $height=200, $data, $legend) {
// 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]);
$Dataset1->addPoint(str_pad($legend[$a],15), $data[$a]);
}
$Plot =& $Plotarea->addNew('pie', $Dataset1);
$Plotarea->hideAxis();
@ -966,7 +969,7 @@ function graphic_incident_user() {
generic_pie_graph (320, 200, $data, $legend);
}
function graphic_user_activity($width=300, $height=200) {
function graphic_user_activity($width=350, $height=230) {
include ("../include/config.php");
require ("../include/languages/language_".$language_code.".php");
@ -980,7 +983,7 @@ function graphic_user_activity($width=300, $height=200) {
$result2=mysql_query($sql1);
$row2=mysql_fetch_array($result2);
$data[] = $row2[0];
$legend[] = substr($row[0],0,16)."(".$row2[0].")";
$legend[] = str_pad(substr($row[0],0,16)."(".format_for_graph($row2[0],0).")", 15);
}
// Sort array by bubble method (yes, I study more methods in university, but if you want more speed, please, submit a patch :)
@ -1047,10 +1050,8 @@ function graphic_incident_source ($width=320, $height=200) {
generic_pie_graph ($width, $height, $data, $legend);
}
function grafico_db_agentes_modulos() {
function grafico_db_agentes_modulos($width, $height) {
include ("../include/config.php");
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_bar.php");
require ("../include/languages/language_".$language_code.".php");
$data = array();
@ -1077,44 +1078,10 @@ function grafico_db_agentes_modulos() {
$legend[$b] = $temp_label;
}
}
$mayor = 0;
$mayor_data =0;
for ($a=0;$a < sizeof($data); $a++)
if ($data[$a] > $mayor_data){
$mayor = $a;
$mayor_data = $data[$a];
generic_bar_graph ($width, $height, $data, $legend);
}
$ajuste_altura = sizeof($data) * 20;
//$graph = new PieGraph(400,140+$ajuste_altura,"auto");
$graph = new Graph(400,140+$ajuste_altura,'auto');
$graph->SetScale("textlin");
$graph->SetMarginColor('white@0.2');
$graph->title->Set($lang_label["modules_per_agent"]);
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->scale->SetGrace(0);
$graph->yaxis->SetLabelAlign('center','bottom');
$graph->SetAlphaBlending();
$graph->SetFrame(true);
$graph->xaxis->SetLabelMargin(5);
$graph->Set90AndMargin(100,20,50,30);
$p1 = new BarPlot($data);
$p1->value->SetFormat('%.0f ');
$p1->value->Show();
$p1->value->SetAlign('left','center');
$p1->SetFillColor("#00bf00");
$p1->SetWidth(0.6);
$p1->SetShadow();
$graph->yaxis->SetLabelFormat('%d');
$graph->xaxis->SetTickLabels($legend);
$graph->legend->Pos(0.05,0.49,"right","center");
$graph->Add($p1);
$graph->img->SetAntiAliasing();
$graph->Stroke();
}
function grafico_eventos_usuario( $width=320, $height=200) {
function grafico_eventos_usuario( $width=420, $height=200) {
include ("../include/config.php");
require ("../include/languages/language_".$language_code.".php");
@ -1190,12 +1157,6 @@ function grafico_eventos_total() {
$legend[$b] = $temp_label;
}
}
$mayor=0; $mayor_data=0;
for ($a=0;$a < sizeof($data); $a++)
if ($data[$a] > $mayor_data){
$mayor = $a;
$mayor_data = $data[$a];
}
generic_pie_graph (320, 200, $data, $legend);
}
@ -1240,10 +1201,50 @@ function grafico_eventos_grupo ($width = 300, $height = 200 ) {
generic_pie_graph ($width, $height, $data, $legend);
}
function grafico_db_agentes_paquetes() {
function generic_bar_graph ( $width =380, $height = 300, $data, $legend) {
include ("../include/config.php");
require_once 'Image/Graph.php';
require ("../include/languages/language_".$language_code.".php");
$ajuste_altura = sizeof($data) * 20;
if (sizeof($data) > 10){
$height = $height + $ajuste_altura;
}
// 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 11 pixels
$Font->setSize(8);
$Graph->setFont($Font);
$Graph->add(
Image_Graph::vertical (
$Plotarea = Image_Graph::factory('plotarea',array('category', 'axis', 'horizontal')),
$Legend = Image_Graph::factory('legend'),
100
)
);
$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(str_pad($legend[$a],15), $data[$a]);
}
$Plot =& $Plotarea->addNew('bar', $Dataset1);
$GridY2 =& $Plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y_SECONDARY);
$GridY2->setLineColor('gray');
$GridY2->setFillColor('lightgray@0.05');
$Plot->setLineColor('gray');
$Plot->setFillColor('blue@0.85');
$Graph->done();
}
function grafico_db_agentes_paquetes ($width = 380, $height = 300) {
include ("../include/config.php");
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_bar.php");
require ("../include/languages/language_".$language_code.".php");
$data = array();
@ -1256,7 +1257,7 @@ function grafico_db_agentes_paquetes() {
$result3=mysql_query($sql1);
if ($row3=mysql_fetch_array($result3)){
$data[]= $row3[0];
$legend[] = dame_nombre_agente($row[0]);
$legend[] = str_pad(dame_nombre_agente($row[0]),15);
}
}
}
@ -1273,42 +1274,10 @@ function grafico_db_agentes_paquetes() {
$legend[$b] = $temp_label;
}
}
$mayor = 0;
$mayor_data =0;
for ($a=0;$a < sizeof($data); $a++)
if ($data[$a] > $mayor_data){
$mayor = $a;
$mayor_data = $data[$a];
generic_bar_graph ($width, $height, $data, $legend);
}
$ajuste_altura = sizeof($data) * 20;
$graph = new Graph(400,140+$ajuste_altura,'auto');
$graph->SetScale("textlin");
$graph->SetMarginColor('white@0.2');
$graph->title->Set($lang_label["packets_by_agent"]);
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->scale->SetGrace(0);
$graph->yaxis->SetLabelAlign('center','bottom');
$graph->SetAlphaBlending();
$graph->SetFrame(true);
$graph->xaxis->SetLabelMargin(5);
$graph->Set90AndMargin(100,20,50,30);
$p1 = new BarPlot($data);
$p1->value->SetFormat('%.0f ');
$p1->value->Show();
$p1->value->SetAlign('left','center');
$p1->SetFillColor("#0000fd");
$p1->SetWidth(0.6);
$p1->SetShadow();
$graph->yaxis->SetLabelFormat('%d');
$graph->xaxis->SetTickLabels($legend);
$graph->legend->Pos(0.05,0.49,"right","center");
$graph->Add($p1);
$graph->img->SetAntiAliasing();
$graph->Stroke();
}
function grafico_db_agentes_purge ($id_agente, $width, $height) {
function grafico_db_agentes_purge ($id_agent, $width, $height) {
include ("../include/config.php");
require_once 'Image/Graph.php';
require ("../include/languages/language_".$language_code.".php");
@ -1334,77 +1303,23 @@ function grafico_db_agentes_purge ($id_agente, $width, $height) {
for ($a=0; $a < sizeof ($fechas); $a++){
// 4 x intervals will be enought, increase if your database is very very fast :)
if ($a==3)
if ($a==3){
if ($id_agent == -1)
$sql1="SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp >= ".$fechas[$a];
else
$sql1="SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE id_agente = $id_agent AND utimestamp >= ".$fechas[$a];
} else {
if ($id_agent == -1)
$sql1="SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE utimestamp >= ".$fechas[$a]." AND utimestamp < ".$fechas[$a+1];
else
$sql1="SELECT COUNT(id_agente_datos) FROM tagente_datos WHERE id_agente = $id_agent AND 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]." )";
$legend[]=$fechas_label[$a]." ( ".format_for_graph($row[0],0)." )";
}
$mayor = 0;
$mayor_data =0;
for ($a=0;$a < sizeof($data); $a++)
if ($data[$a] > $mayor_data){
$mayor = $a;
$mayor_data = $data[$a];
}
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 ();
generic_pie_graph ($width, $height, $data, $legend);
}
function drawWarning($width,$height) {
@ -1485,6 +1400,8 @@ function progress_bar($progress,$width,$height) {
drawRating($progress,$width,$height);
}
/*NOT USED !
function graphic_test ($id, $period, $interval, $label, $width, $height){
require_once 'Image/Graph.php';
include ("../include/config.php");
@ -1571,6 +1488,7 @@ function graphic_test ($id, $period, $interval, $label, $width, $height){
$Graph->done();
}
*/
function odo_tactic ($value1, $value2, $value3){
require_once 'Image/Graph.php';
@ -1800,15 +1718,15 @@ if (isset($_GET["tipo"])){
elseif ($_GET["tipo"] =="prioridad_incidente")
grafico_incidente_prioridad();
elseif ($_GET["tipo"]=="db_agente_modulo")
grafico_db_agentes_modulos();
grafico_db_agentes_modulos($width, $height);
elseif ($_GET["tipo"]=="db_agente_paquetes")
grafico_db_agentes_paquetes();
grafico_db_agentes_paquetes($width, $height);
elseif ($_GET["tipo"] =="db_agente_purge")
grafico_db_agentes_purge(-1, $width, $height);
grafico_db_agentes_purge($id, $width, $height);
elseif ($_GET["tipo"] =="group_events")
grafico_eventos_grupo($width, $height);
elseif ($_GET["tipo"] =="user_events")
grafico_eventos_usuario();
grafico_eventos_usuario($width, $height);
elseif ($_GET["tipo"] =="total_events")
grafico_eventos_total();
elseif ($_GET["tipo"] =="group_incident")
@ -1823,8 +1741,8 @@ if (isset($_GET["tipo"])){
graphic_agentaccess($_GET["id"], $_GET["periodo"], $width, $height);
elseif ($_GET["tipo"] == "agentmodules")
graphic_agentmodules($_GET["id"], $width, $height);
elseif ($_GET["tipo"] == "gdirect")
graphic_test ($id, $period, $intervalo, $label, $width, $height);
//elseif ($_GET["tipo"] == "gdirect")
// graphic_test ($id, $period, $intervalo, $label, $width, $height);
elseif ( $_GET["tipo"] =="progress"){
$percent= $_GET["percent"];
progress_bar($percent,$width,$height);