2008-04-24 Sancho Lerena <slerena@artica.es>

* operation/reporting/reporting_viewer.php,
    operation/reporting/graph_viewer.php
    include/functions_reporting_pdf.php: Render stacked custom graphs.

    * include/styles/pandora_red.css: Improved RED style :-)

    * include/styles/pandora.css: Added background.

    * include/languages/language_en.php: Added stacked token.

    * pandoradb.sql: Added field "stacked" to custom graphs.

    * images/backgrounds/background_red.gif: Added cool background ;)

    * reporting/fgraph.php: stacked custom graph support.

    * godmode/db/db_main.php: Uses new config tokens.

    * godmode/db/db_purge.php: Works also with "all" agents (like 1.1)

    * godmode/reporting/graph_builder.php: Able to define stacked or not.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@819 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2008-04-23 23:29:50 +00:00
parent d7ec1d3bcf
commit 71b4261d5d
15 changed files with 127 additions and 58 deletions

View File

@ -1,6 +1,29 @@
2008-04-24 Sancho Lerena <slerena@artica.es>
* pandoradb_data.sql: Added several modules by Guguevi.
* operation/reporting/reporting_viewer.php,
operation/reporting/graph_viewer.php
include/functions_reporting_pdf.php: Render stacked custom graphs.
* include/styles/pandora_red.css: Improved RED style :-)
* include/styles/pandora.css: Added background.
* include/languages/language_en.php: Added stacked token.
* pandoradb.sql: Added field "stacked" to custom graphs.
* images/backgrounds/background_red.gif: Added cool background ;)
* reporting/fgraph.php: stacked custom graph support.
* godmode/db/db_main.php: Uses new config tokens.
* godmode/db/db_purge.php: Works also with "all" agents (like 1.1)
* godmode/reporting/graph_builder.php: Able to define stacked or not.
* pandoradb_data.sql: Added several template modules contributed by
Guguevi.
* operation/events/events_rss.php: Added RSS events page, contributed
by guruevi.

View File

@ -1,15 +1,24 @@
<?php
// Pandora - The Free Monitoring System
// This code is protected by GPL license.
// Este codigo esta protegido por la licencia GPL.
// Sancho Lerena <slerena@gmail.com>, 2003-2006
// Raul Mateos <raulofpandora@gmail.com>, 2005-2006
// Pandora FMS - the Free monitoring system
// ========================================
// Copyright (c) 2004-2008 Sancho Lerena, slerena@openideas.info
// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas
// 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, U
// Load global vars
require("include/config.php");
//require("include/functions.php");
//require("include/functions_db.php");
global $config;
if (comprueba_login() == 0)
if ((give_acl($id_user, 0, "DM")==1) or (dame_admin($id_user)==1)) {
// Todo for a good DB maintenance
@ -26,8 +35,8 @@ if (comprueba_login() == 0)
<?php echo $lang_label["current_dbsetup"] ?></h2>
<table width=550 cellspacing=3 cellpadding=3 border=0>
<tr><td>
<i><?php echo $lang_label["days_compact"]; ?>:</i>&nbsp;<b><?php echo $days_compact; ?></b><br><br>
<i><?php echo $lang_label["days_purge"]; ?>:</i>&nbsp;<b><?php echo $days_purge; ?></b><br><br>
<i><?php echo $lang_label["days_compact"]; ?>:</i>&nbsp;<b><?php echo $config["days_compact"]; ?></b><br><br>
<i><?php echo $lang_label["days_purge"]; ?>:</i>&nbsp;<b><?php echo $config["days_purge"]; ?></b><br><br>
<tr><td>
<div align='justify'>
<?php echo $lang_label["dbsetup_info"]; ?>
@ -39,4 +48,4 @@ if (comprueba_login() == 0)
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Database Management");
require ("general/noaccess.php");
}
?>
?>

View File

@ -1,11 +1,8 @@
<?php
// Pandora FMS - the Free monitoring system
// ========================================
// Copyright (c) 2004-2007 Sancho Lerena, slerena@openideas.info
// Copyright (c) 2004-2008 Sancho Lerena, slerena@openideas.info
// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas
// 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
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -19,18 +16,12 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, U
// Load global vars
require("include/config.php");
global $config;
if (comprueba_login() == 0)
$id_usuario= $_SESSION["id_usuario"];
if (give_acl($id_usuario, 0, "DM")==1){
// Todo for a good DB maintenance
/*
- A function to "compress" data, and interpolate big chunks of data (1 month - 60000 registers)
onto a small chunk of interpolated data (1 month - 600 registers)
- A more powerful selection (by Agent, by Module, etc).
*/
if (isset($_POST["agent"])){
$id_agent =$_POST["agent"];
} else
@ -101,7 +92,10 @@ if (comprueba_login() == 0)
if ($id_agent != -1) {
echo $lang_label["purge_task"].$id_agent." / ".$from_date;
echo "<h3>".$lang_label["please_wait"]."<br>",$lang_label["while_delete_data"].$lang_label["agent"]."</h3>";
$sql_2='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_agent;
if ($id_agent == 0)
$sql_2='SELECT * FROM tagente_modulo';
else
$sql_2='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_agent;
$result_t=mysql_query($sql_2);
while ($row=mysql_fetch_array($result_t)){
echo $lang_label["deleting_records"].dame_nombre_modulo_agentemodulo($row["id_agente_modulo"]);
@ -140,9 +134,15 @@ if (comprueba_login() == 0)
<select name='agent' class='w130'>
<?php
if (isset($_POST["agent"]) and ($id_agent !=-1))
if (isset($_POST["agent"]) and ($id_agent > 0))
echo "<option value='".$_POST["agent"]."'>".dame_nombre_agente($_POST["agent"]);
echo "<option value=-1>".$lang_label["choose_agent"];
if (isset($_POST["agent"]) and ($id_agent == 0)){
echo "<option value=0>".$lang_label["all_agents"];
echo "<option value=-1>".$lang_label["choose_agent"];
} else {
echo "<option value=-1>".$lang_label["choose_agent"];
echo "<option value=0>".$lang_label["all_agents"];
}
$result_t=mysql_query("SELECT * FROM tagente");
while ($row=mysql_fetch_array($result_t)){
echo "<option value='".$row["id_agente"]."'>".$row["nombre"];
@ -159,7 +159,10 @@ if (comprueba_login() == 0)
if (isset($_POST["agent"]) and ($id_agent !=-1)){
echo "<h3>".$lang_label["db_agent_bra"].dame_nombre_agente($id_agent).$lang_label["db_agent_ket"]."</h3>";
$sql_2='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_agent;
if ($id_agent == 0)
$sql_2='SELECT * FROM tagente_modulo';
else
$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();

View File

@ -26,6 +26,7 @@ $period = 86401;
$events = "";
$factor = 1;
$render=1; // by default
$stacked = 0;
// Login check
$id_usuario=$_SESSION["id_usuario"];
@ -51,12 +52,13 @@ if (isset($_GET["store_graph"])){
$width = entrada_limpia($_POST["width"]);
$height = entrada_limpia($_POST["height"]);
$events = entrada_limpia($_POST["events"]);
$stacked = get_parameter ("stacked",0);
if ($events == "") // Temporal workaround
$events = 0;
$period = entrada_limpia($_POST["period"]);
// Create graph
$sql = "INSERT INTO tgraph
(id_user, name, description, period, width, height, private, events) VALUES
(id_user, name, description, period, width, height, private, events, stacked) VALUES
('$id_user',
'$name',
'$description',
@ -64,7 +66,8 @@ if (isset($_GET["store_graph"])){
$width,
$height,
$private,
$events)";
$events,
$stacked)";
//echo "DEBUG $sql<br>";
$res = mysql_query($sql);
if ($res){
@ -147,6 +150,7 @@ if ( (isset($_GET["add_module"]))){
$factor = 1;
$period = $_POST["period"];
$render = $_POST["render"];
$stacked = get_parameter ("stacked",0);
// $alerts = $_POST["alerts"];
if (isset($_POST["chunk"]))
$chunkdata = $_POST["chunk"];
@ -249,7 +253,7 @@ if (($render == 1) && (isset($modules))) {
echo "<h3>".$lang_label["combined_image"]."</h3>";
echo "<table class='databox'>";
echo "<tr><td>";
echo "<img src='reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&label=Combined%20Sample%20Graph&height=$height&width=$width&period=$period' border=1 alt=''>";
echo "<img src='reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&label=Combined%20Sample%20Graph&height=$height&width=$width&stacked=$stacked&period=$period' border=1 alt=''>";
echo "</td></tr></table>";
}
@ -413,6 +417,21 @@ if ($events == 1){
}
echo "</select></td>";
echo "<tr>";
echo "<td class='datos2'>";
echo "<b>".lang_string ("Stacked")."</b></td>";
echo "<td class='datos2'>";
echo "<select name='stacked'>";
if ($stacked == 1){
echo "<option value=1>Yes</option>";
echo "<option value=0>No</option>";
} else {
echo "<option value=0>No</option>";
echo "<option value=1>Yes</option>";
}
echo "</select></td>";
/*
echo "<td class='datos'>";
echo "<b>Show alert limit</b>";
@ -450,6 +469,7 @@ if (isset($module_array)){
echo "<input type='hidden' name='height' value='$height'>";
echo "<input type='hidden' name='period' value='$period'>";
echo "<input type='hidden' name='events' value='$events'>";
echo "<input type='hidden' name='stacked' value='$stacked'>";
for ($a=0; $a < count($module_array); $a++){
$id_agentemodulo = $module_array[$a];

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -2,10 +2,10 @@
// Begin of automatic config file
$config["dbname"]="pandora"; // MySQL DataBase name
$config["dbuser"]="pandora"; // DB User
$config["dbpass"]="pfnfkudt"; // DB Password
$config["dbpass"]="swfvnldt"; // DB Password
$config["dbhost"]="localhost"; // DB Host
$config["homedir"]="/var/www/pandora_console/"; // Config homedir
$config["homeurl"]="http://localhost/pandora_console"; // Base URL
$config["homedir"]="/var/www/pandora/"; // Config homedir
$config["homeurl"]="http://localhost/pandora"; // Base URL
// End of automatic config file
?><?php
// Pandora FMS - the Free Monitoring System
@ -40,7 +40,7 @@ $config["homeurl"]="http://localhost/pandora_console"; // Base URL
//error_reporting(0); // Need to use active console at this moment
// Display ALL errors
error_reporting(E_ALL);
error_reporting(E_ERROR);
// This is directory where placed "/attachment" directory, to upload files stores.
// This MUST be writtable by http server user, and should be in pandora root.

View File

@ -227,7 +227,9 @@ function general_report ($id_report){
break;
case 1: // Custom/Combined graph
$graph_name = give_db_value ("name", "tgraph", "id_graph", $id_gs);
$graph = get_db_row ("tgraph", "id_graph", $id_gs);
$graph_name = $graph["name"];
$stacked = $graph["stacked"];
$sql2="SELECT * FROM tgraph_source WHERE id_graph = $id_gs";
$res2=mysql_query($sql2);
while ( $row2 = mysql_fetch_array($res2)){
@ -243,8 +245,7 @@ function general_report ($id_report){
}
doTitle($pdf, lang_string("Custom graph").": $graph_name");
$pdf->ezText (human_time_description($period)."\n",8);
$image = $config["homeurl"]."/reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&height=230&width=720&period=$period&pure=1";
//ezImage(image,[padding],[width],[resize],[justification],[array border])
$image = $config["homeurl"]."/reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&height=230&width=720&stacked=$stacked&period=$period&pure=1";
$pdf->ezImage($image,0,470,'none','left');
$pdf->ezText ("\n",8);
break;
@ -326,4 +327,4 @@ function general_report ($id_report){
}
// End code
?>
?>

View File

@ -920,6 +920,8 @@ $lang_label["info"]="info";
$lang_label["Operation"]="Operation";
$lang_label["Source Agent/Alert"]="Source Agent/Alert";
$lang_label["Stacked"]="Stacked";
global $lang_label;
global $help_label;

View File

@ -192,6 +192,7 @@ div#main {
padding-bottom: 20px;
margin-bottom: 25px;
background-color: #fefefe;
background-image: url(../../images/backgrounds/background4.jpg);
margin-top: 0px;
margin-left: 0px;
margin-right: 0px;
@ -637,4 +638,4 @@ span#logo_text2 {
}
.bt0 {
border-top: 0px;
}
}

View File

@ -179,6 +179,7 @@ div#main {
padding-bottom: 20px;
margin-bottom: 25px;
background-color: #fefefe;
background-image: url(../../images/backgrounds/background_red.gif);
margin-top: 0px;
margin-left: 0px;
margin-right: 0px;
@ -218,6 +219,8 @@ label {
float: left;
padding-top: 4px;
}
th > label {
padding-top: 7px;
}
@ -279,8 +282,11 @@ td.lb, td.lb_view {
padding-left: 3px;
font-weight: bold;
}
th {
background-color: #CC3333;
}
td.datos, td.datost, td.datosb , td.datos_id, td.datosf9 {
background-color: #f9f9f9;
background-color: #fff0f0;
}
td.datos2, td.datos2t, td.datos2b, td.datos2_id , td.datos2f9 {
background-color: #efefef;
@ -546,7 +552,7 @@ span.rmess, span.nrmess {
background-color: #fafafa;
}
.databox_color {
border-left: 4px solid #786;
border-left: 4px solid #FF7863;
}
#head_l {
float: left;

View File

@ -64,6 +64,7 @@ if (isset($_GET["view_graph"])){
$period = $_POST["period"];
$events = $row["events"];
$description = $row["description"];
$stacked = $row["stacked"];
$name = $row["name"];
if (($row["private"]==1) && ($row["id_user"] != $id_user)){
audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access to a custom graph not allowed");
@ -88,7 +89,7 @@ if (isset($_GET["view_graph"])){
echo $lang_label["combined_image"]."</h2>";
echo "<table class='databox_frame'>";
echo "<tr><td>";
echo "<img src='reporting/fgraph.php?tipo=combined&height=$height&width=$width&id=$modules&period=$period&weight_l=$weights' border=1 alt=''>";
echo "<img src='reporting/fgraph.php?tipo=combined&height=$height&width=$width&id=$modules&period=$period&stacked=$stacked&weight_l=$weights' border=1 alt=''>";
echo "</td></tr></table>";
switch ($period) {
case 3600: $period_label = $lang_label["hour"];

View File

@ -111,7 +111,7 @@ if (($report_user == $id_user) OR (dame_admin($id_user)==1) OR ($report_private
echo "</tr>";
break;
case 1: // Custom/Combined graph
$graph_name = give_db_value ("name", "tgraph", "id_graph", $id_gs);
$graph = get_db_row ("tgraph", "id_graph", $id_gs);
$sql2="SELECT * FROM tgraph_source WHERE id_graph = $id_gs";
$res2=mysql_query($sql2);
while ( $row2 = mysql_fetch_array($res2)){
@ -128,11 +128,12 @@ if (($report_user == $id_user) OR (dame_admin($id_user)==1) OR ($report_private
echo "<tr><td class=datos3 >";
echo "<h4>".$lang_label["custom_graph"]."</h4>";
echo "<td class=datos3>";
echo "<h4>$graph_name</h4>";
echo "<h4>".$graph["name"]."</h4>";
$stacked = $graph["stacked"];
echo "<td class=datos3>";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr><td colspan=3 class=datos valign='top' align='right'>";
echo "<img src='reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&height=230&width=720&period=$period&pure=1' border=1 alt=''>";
echo "<img src='reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&height=230&width=720&period=$period&stacked=$stacked&pure=1' border=1 alt=''>";
echo "</tr>";
break;
case 6: // AVG value

View File

@ -561,6 +561,7 @@ CREATE TABLE `tgraph` (
`height` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
`private` tinyint(1) UNSIGNED NOT NULL default 0,
`events` tinyint(1) UNSIGNED NOT NULL default 0,
`stacked` tinyint(1) UNSIGNED NOT NULL default 0,
PRIMARY KEY(`id_graph`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;

View File

@ -214,8 +214,6 @@ INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `t
INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`) VALUES (51,'OS Raw Interrupts','Get system raw interrupts from SO',13,16,0,0,180,0,'','','public','UCD-SNMP-MIB::ssRawInterrupts.0',4);
INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`) VALUES (52,'OS IO Signals sent','IO Signals sent by Kernel',13,16,0,0,180,0,'','','public','UCD-SNMP-MIB::ssIOSent.0',4);
INSERT INTO `tnetwork_component` (`id_nc`, `name`, `description`, `id_group`, `type`, `max`, `min`, `module_interval`, `tcp_port`, `tcp_send`, `tcp_rcv`, `snmp_community`, `snmp_oid`, `id_module_group`) VALUES (53,'System Uptime','Sistem uptime in timeticks',1,15,0,0,180,0,'','','public','HOST-RESOURCES-MIB::hrSystemUptime.0',4);
INSERT INTO `tnetwork_component` VALUES (53,'Sytem IO Sent','Linux System IO Sent ',5,15,0,0,180,0,'','','public','.1.3.6.1.4.1.2021.11.5.0',4);
INSERT INTO `tnetwork_component` VALUES (54,'System IO Recv','Linux System IO Recv ',5,15,0,0,180,0,'','','public','.1.3.6.1.4.1.2021.11.6.0',4);
INSERT INTO `tnetwork_component` VALUES (55,'System SwapIn ','Linux System Swap In',5,15,0,0,180,0,'','','public','.1.3.6.1.4.1.2021.11.3.0',1);
INSERT INTO `tnetwork_component` VALUES (56,'System Buffer Memory','Linux System Buffer Memory (used as available\nmemory)',5,15,0,0,180,0,'','','public','.1.3.6.1.4.1.2021.4.14.0',4);

View File

@ -78,7 +78,7 @@ function dame_fecha_grafico_timestamp ($timestamp) {
* @param int Pure mode (without titles) (set to 1)
*/
function graphic_combined_module ( $module_list, $weight_list, $periodo, $width, $height, $title, $unit_name, $show_event=0, $show_alert=0, $pure =0 ){
function graphic_combined_module ( $module_list, $weight_list, $periodo, $width, $height, $title, $unit_name, $show_event=0, $show_alert=0, $pure =0, $stacked = 0){
include ("../include/config.php");
require ("../include/languages/language_".$config['language'].".php");
@ -317,10 +317,13 @@ function graphic_combined_module ( $module_list, $weight_list, $periodo,
// create the 1st plot as smoothed area chart using the 1st dataset
if ($stacked == 0){
// Non-stacked
// $Plot =& $Plotarea->addNew('area', array(&$dataset));
// Stacked (v1.4)
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Area', array(&$dataset, 'stacked'));
$Plot =& $Plotarea->addNew('area', array(&$dataset));
} else {
// Stacked (> 2.0)
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Area', array(&$dataset, 'stacked'));
}
$Plot->setLineColor('gray@0.4');
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
// $AxisX->Hide();
@ -1292,6 +1295,8 @@ function grafico_db_agentes_purge ($id_agent, $width, $height) {
require_once 'Image/Graph.php';
require ("../include/languages/language_".$config['language'].".php");
if ($id_agent == 0)
$id_agent = -1;
// All data (now)
$purge_all=date("Y-m-d H:i:s",time());
@ -2012,11 +2017,9 @@ if ( isset($_GET["value2"]))
$value2 = $_GET["value2"];
else
$value2 = 0;
if ( isset($_GET["value3"]))
$value3 = $_GET["value3"];
else
$value3 = 0;
$value3 = get_parameter("value3",0);
$stacked = get_parameter ("stacked", 0);
// Image handler
// *****************
@ -2071,7 +2074,7 @@ if (isset($_GET["tipo"])){
$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, $draw_events, $draw_alerts, $pure);
graphic_combined_module ($module_list, $weight_list, $period, $width, $height , $label, $unit_name, $draw_events, $draw_alerts, $pure, $stacked);
}
else
graphic_error ();