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

* include/styles/god.css: Added god51 (reporting).

        * include/styles/pandora.css: Added h4 (for reporting).

        * include/functions_db.php:

        * include/functions_reporting.php: Reporting functions should be
        here. Now is SLA, tomorrow will be more ;)

        * include/functions.php: Added generic POST/GET parameter
        management, and a few functions to mangle dates.

        * pandoradb.sql: A few changes on treport_content table.

        * operation/agentes/datos_agente.php: Added option to delete
        individual data from here. Useful to purge bad data.

        * operation/reporting/reporting_viewer.php: New report viewer on
        HTML.

        * operation/reporting/custom_reporting.php: Moved.

        * operation/reporting/graph_builder.php: Moved to godmode
        directory.

        * operation/menu.php: Added few options and removed other
        (Reporting)

        * reporting/fgraph.php: Few changes to use graphs in reports
        without titles.

        * godmode/reporting: Added.

        * godmode/reporting/reporting_builder.php: The Pandora FMS report
        editor :-)

        * godmode/reporting/graph_builder.php: Graph builder almost done,
        only a few bugs to finish.

        * godmode/menu.php: New reporting options in godmode menu.





git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@494 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2007-06-07 17:46:38 +00:00
parent 8bd7e3d589
commit 47579d155d
17 changed files with 1018 additions and 176 deletions

View File

@ -1,3 +1,47 @@
2007-06-07 Sancho Lerena <slerena@artica.es>
* include/styles/god.css: Added god51 (reporting).
* include/styles/pandora.css: Added h4 (for reporting).
* include/functions_db.php:
* include/functions_reporting.php: Reporting functions should be
here. Now is SLA, tomorrow will be more ;)
* include/functions.php: Added generic POST/GET parameter
management, and a few functions to mangle dates.
* pandoradb.sql: A few changes on treport_content table.
* operation/agentes/datos_agente.php: Added option to delete
individual data from here. Useful to purge bad data.
* operation/reporting/reporting_viewer.php: New report viewer on
HTML.
* operation/reporting/custom_reporting.php: Moved.
* operation/reporting/graph_builder.php: Moved to godmode
directory.
* operation/menu.php: Added few options and removed other
(Reporting)
* reporting/fgraph.php: Few changes to use graphs in reports
without titles.
* godmode/reporting: Added.
* godmode/reporting/reporting_builder.php: The Pandora FMS report
editor :-)
* godmode/reporting/graph_builder.php: Graph builder almost done,
only a few bugs to finish.
* godmode/menu.php: New reporting options in godmode menu.
2007-06-06 Raul Mateos <raulofpandora@gmail.com>
* godmode/*.php: Closed a lot of unclosed html tags. Updated near all of

View File

@ -102,20 +102,55 @@ if (comprueba_login() == 0){
else echo '<div id="god3">';
echo '<ul class="mn"><li><a href="index.php?sec=gusuarios&amp;sec2=godmode/users/user_list" class="mn">'.$lang_label["manage_users"].'</a></li></ul></div>';
}
// Reporting
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ((give_acl($id_user, 0, "AW")==1)){
echo '<div id="god51">';
echo '<ul class="mn"><li><a href="index.php?sec=greporting&sec2=godmode/reporting/reporting_builder" class="mn">'. $lang_label["manage_reporting"].'</a></li></ul></div>';
// Custom report builder
if (isset($_GET["sec"]) && $_GET["sec"] == "greporting"){
if (isset($_GET["sec2"]) && $_GET["sec2"] == "godmode/reporting/reporting_builder"){
echo "<div class='arrowgs'>";
} else {
echo "<div class='arrowg'>";
}
echo "<ul class='mn'><li><a href='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder' class='mn'>".$lang_label["report_builder"]."</a></li></ul></div>";
}
// Custom graph builder
if (isset($_GET["sec"]) && $_GET["sec"] == "greporting"){
if (isset($_GET["sec2"]) && $_GET["sec2"] == "godmode/reporting/graph_builder"){
echo "<div class='arrowgs'>";
} else {
echo "<div class='arrowg'>";
}
echo "<ul class='mn'><li><a href='index.php?sec=greporting&sec2=godmode/reporting/graph_builder' class='mn'>".$lang_label["graph_builder"]."</a></li></ul></div>";
}
}
// Manage profiles
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ( (give_acl($id_user, 0, "PM")==1)){
if (isset($_GET["sec2"]) && $_GET["sec2"] == "godmode/profiles/profile_list"){
echo '<div id="god4s">';
}
else echo '<div id="god4">';
echo '<ul class="mn"><li><a href="index.php?sec=gperfiles&amp;sec2=godmode/profiles/profile_list" class="mn">'.$lang_label["manage_profiles"].'</a></li></ul></div>';
// SERVERS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (isset($_GET["sec2"]) && $_GET["sec2"] == "godmode/servers/modificar_server"){
echo '<div id="god5s">';
} else
echo '<div id="god5">';
echo '<ul class="mn"><li><a href="index.php?sec=gservers&amp;sec2=godmode/servers/modificar_server" class="mn">'.$lang_label["manage_servers"].'</a></li></ul></div>';
if (isset($_GET["sec"]) && $_GET["sec"] == "gservers"){
if (isset($_GET["sec2"]) && $_GET["sec2"] == "godmode/servers/manage_recontask"|| $_GET["sec2"] == "godmode/servers/manage_recontask_form"){
echo "<div class='arrowgs'>";
@ -123,13 +158,16 @@ if (comprueba_login() == 0){
echo "<div class='arrowg'>";
echo "<ul class='mn'><li><a href='index.php?sec=gservers&sec2=godmode/servers/manage_recontask' class='mn'>".$lang_label["manage_recontask"]."</a></li></ul></div>";
}
// AUDIT
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (isset($_GET["sec2"]) && $_GET["sec2"] == "godmode/admin_access_logs"){
echo '<div id="god6s">';
}
else echo '<div id="god6">';
echo '<ul class="mn"><li><a href="index.php?sec=glog&amp;sec2=godmode/admin_access_logs" class="mn">'.$lang_label["system_audit"].'</a></li></ul></div>';
// Main SETUP
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (isset($_GET["sec2"]) && $_GET["sec2"] == "godmode/setup/setup"){
echo '<div id="god7s">';
}

View File

@ -193,7 +193,7 @@ if (! isset($_GET["delete_module"])){
echo "<h2>".$lang_label["reporting"]." &gt; ";
if (isset($chunk1)) {
echo $lang_label["graph_builder_modulelist"]."</h2>";
echo "<form method='post' action='index.php?sec=reporting&sec2=operation/reporting/graph_builder&delete_module=1'>";
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/graph_builder&delete_module=1'>";
if (isset($chunkdata))
echo "<input type='hidden' name='chunk' value='$chunkdata'>";
if (isset($id_agent))
@ -247,7 +247,7 @@ if (($render == 1) && (isset($modules))) {
// -----------------------
echo $lang_label["graph_builder"]."</h2>";
echo "<table width='500' cellpadding=4 cellpadding=4 class='databox_frame'>";
echo "<form method='post' action='index.php?sec=reporting&sec2=operation/reporting/graph_builder&get_agent=1'>";
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/graph_builder&get_agent=1'>";
if (isset($period))
echo "<input type='hidden' name='period' value='$period'>";
@ -276,7 +276,7 @@ echo "</form>";
// -----------------------
// SOURCE MODULE FORM
// -----------------------
echo "<form method='post' action='index.php?sec=reporting&sec2=operation/reporting/graph_builder&add_module=1'>";
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/graph_builder&add_module=1'>";
if (isset($chunkdata))
echo "<input type='hidden' name='chunk' value='$chunkdata'>";
@ -423,7 +423,7 @@ echo "</table>";
if (isset($module_array)){
echo "<h3>".$lang_label["graph_store"]."</h3>";
echo "<table width='500' cellpadding=4 cellpadding=4 class='databox_frame'>";
echo "<form method='post' action='index.php?sec=reporting&sec2=operation/reporting/graph_builder&store_graph=1'>";
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/graph_builder&store_graph=1'>";
// hidden fields with data begin
echo "<input type='hidden' name='module_number' value='".count($module_array)."'>";

View File

@ -0,0 +1,420 @@
<?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.
// Login check
$id_user=$_SESSION["id_usuario"];
global $REMOTE_ADDR;
if (comprueba_login() != 0) {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access report builder");
include ("general/noaccess.php");
exit;
}
$form_report_name = "";
$form_report_private=0;
$form_report_description = "";
$createmode = 1;
if (isset($_GET["get_agent"])) {
$id_agent = $_POST["id_agent"];
}
// Delete module SQL code
if (isset($_GET["delete"])){
$id_content = $_GET["delete"];
$sql = "DELETE FROM treport_content WHERE id_rc = $id_content";
if ($res=mysql_query($sql))
$result = "<h2 class=suc>".$lang_label["delete_ok"]."</h2>";
else
$result = "<h2 class=error>".$lang_label["delete_no"]."</h2>";
echo $result;
}
// Delete module SQL code
if (isset($_GET["delete_report"])){
$id = $_GET["delete_report"];
$sql = "DELETE FROM treport_content WHERE id_report = $id";
$sql2 = "DELETE FROM treport WHERE id_report = $id";
$res=mysql_query($sql);
$res2=mysql_query($sql2);
if ($res AND $res2)
$result = "<h2 class=suc>".$lang_label["delete_ok"]."</h2>";
else
$result = "<h2 class=error>".$lang_label["delete_no"]."</h2>";
echo $result;
}
// Create new report. First step
if (isset($_GET["create_report"])){
$createmode = 2;
}
// Add module SQL code
if (isset($_GET["add_module"])){
if (isset($_POST["id_report"]))
$id_report = $_POST["id_report"];
else {
audit_db($id_user,$REMOTE_ADDR, "Hack attempt","Parameter trash in report builder");
include ("general/noaccess.php");
exit;
}
$my_id_agent = entrada_limpia($_POST["id_agent"]);
$my_id_module = entrada_limpia($_POST["id_module"]);
$my_period = entrada_limpia($_POST["period"]);
$my_type = entrada_limpia($_POST["type"]);
$my_cg = entrada_limpia($_POST["id_custom_graph"]);
$my_slamax = entrada_limpia($_POST["sla_max"]);
$my_slamin = entrada_limpia($_POST["sla_min"]);
$my_slalimit = entrada_limpia($_POST["sla_limit"]);
$sql = "INSERT INTO treport_content (id_report, id_gs, id_agent_module, type, sla_max, sla_min, sla_limit, period) VALUES ('$id_report', '$my_cg', '$my_id_module', '$my_type', '$my_slamax', '$my_slamin', '$my_slalimit', '$my_period')";
if ($res=mysql_query($sql))
$result = "<h2 class=suc>".$lang_label["create_ok"]."</h2>";
else
$result = "<h2 class=error>".$lang_label["create_no"]."</h2>";
echo $result;
}
// Create item SQL code
if (isset($_POST["createmode"])){
$createmode = $_POST["createmode"];
$form_report_name = entrada_limpia($_POST["report_name"]);
$form_report_description = entrada_limpia($_POST["report_description"]);
if (isset($_POST["report_private"]))
$form_report_private = entrada_limpia($_POST["report_private"]);
else
$form_report_private = 0;
// INSERT REPORT DATA
if ($createmode == 1){
$form_id_user = $id_user;
$sql = "INSERT INTO treport (name, description, id_user, private) VALUES ('$form_report_name', '$form_report_description', '$form_id_user', '$form_report_private')";
if ($res=mysql_query($sql))
$result = "<h1 class=suc>".$lang_label["create_ok"]."</h1>";
else
$result = "<h1 class=error>".$lang_label["create_no"]."</h1>";
$id_report = mysql_insert_id();
// UPDATE REPORT DATA
} else {
$form_id_report = entrada_limpia($_POST["id_report"]);
$id_report = $form_id_report;
$sql = "UPDATE treport SET name = '$form_report_name', description = '$form_report_description', private = '$form_report_private' WHERE id_report = $form_id_report";
if ($res=mysql_query($sql))
$result = "<h2 class=suc>".$lang_label["modify_ok"]."</h2>";
else
$result = "<h2 class=error>".$lang_label["modify_no"]."</h2>";
}
echo $result;
if ($id_report != ""){
$_GET["id"]=$id_report;
$createmode=0;
}
}
// GET DATA OF REPORT
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ($createmode==2 OR isset($_GET["id"]) OR (isset($_POST["id_report"]))) {
if (isset($_GET["id"]))
$id_report = $_GET["id"];
elseif (isset($_POST["id_report"]))
$id_report = $_POST["id_report"];
else
$id_report = -1;
if (isset($_POST["id_agent"]))
$id_agent = $_POST["id_agent"];
else
$id_agent = 0;
if ($createmode != 2){
$createmode = 0;
$sql = "SELECT * FROM treport WHERE id_report = $id_report";
$res=mysql_query($sql);
if ($row = mysql_fetch_array($res)){
$form_report_name = $row["name"];
$form_report_description = $row["description"];
$form_report_private = $row["private"];
$form_id_user = $row["id_user"];
}
} else {
$form_report_name = "";
$form_report_description = "";
$form_report_private = 0;
$form_id_user = $id_user;
$createmode = 1;
}
echo "<h1>".$lang_label["custom_reporting_builder"]."</h1>";
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder'>";
echo "<input type='hidden' name=createmode value='$createmode'>";
if ($createmode == 0){
echo "<input type='hidden' name=id_report value='$id_report'>";
}
echo "<table width=500 cellspacing=4 cellpading=4 class='databox_color'>";
echo "<tr><td class='datos2'>";
echo $lang_label["report_name"];
echo "<td class='datos2'>";
echo "<input type=text size=35 name='report_name' value='$form_report_name'>";
echo "<tr><td class='datos'>";
echo $lang_label["private"];
echo "<td class='datos'>";
if ($form_report_private == 1)
echo "<input type=checkbox name='report_private' value=1 CHECKED>";
else
echo "<input type=checkbox name='report_private' value=1>";
echo "<tr><td class='datos2' valign='top'>";
echo $lang_label["description"];
echo "<td class='datos2'>";
echo "<textarea name='report_description' cols=40 rows=3>";
echo $form_report_description;
echo "</textarea>";
// Button
echo "</table>";
echo "<table width=500 cellspacing=4 cellpading=4'>";
echo "<tr><td align='right'>";
if ($createmode == 0)
echo "<input type='submit' class='sub next' value='".$lang_label["update"]."'>";
else
echo "<input type='submit' class='sub wand' value='".$lang_label["create"]."'>";
echo "</table>";
echo "</form>";
if ($createmode == 0){
// Part 2 - Add new items to report
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo "<h2>".$lang_label["reporting_item_add"]."</h2>";
// Show combo with agents
// ----------------------
echo "<table width='500' cellpadding=4 cellpadding=4 class='databox_color'>";
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&get_agent=1'>";
echo "<input type='hidden' name=id_report value='$id_report'>";
echo "<tr>";
echo "<td class='datos'><b>".$lang_label["source_agent"];
echo "</b>";
echo "<td class='datos' colspan=2><select name='id_agent' style='width:180px;'>";
if ($id_agent != 0)
echo "<option value='$id_agent'>".dame_nombre_agente($id_agent);
$sql1='SELECT * FROM tagente order by nombre';
$result=mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
if ( $id_agent != $row["id_agente"])
echo "<option value=".$row["id_agente"].">".$row["nombre"];
}
echo '</select>';
echo "<td class='datos' colspan=1 align='right'><input type=submit name='update_agent' class='sub upd' value='".$lang_label["get_info"]."'>";
echo "</form>";
// Modules combo
// -----------------------
echo "<form method='post' action='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&add_module=1'>";
echo "<input type='hidden' name=id_report value='$id_report'>";
if (isset($id_agent))
echo "<input type='hidden' name='id_agent' value='$id_agent'>";
echo "<tr><td class='datos2'>";
echo "<b>".$lang_label["modules"]."</b>";
echo "<td 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>";
// Component type
echo "<tr><td class='datos'>";
echo "<b>".$lang_label["reporting_type"]."</b>";
echo "<td class='datos' colspan=3>";
echo "<select name='type' size=1 style='width:180px;'>";
echo "<option value=0>".$lang_label["simple_graph"];
echo "<option value=1>".$lang_label["custom_graph"];
echo "<option value=2>".$lang_label["SLA"];
echo "<option value=3>".$lang_label["event_report"];
echo "<option value=4>".$lang_label["alert_report"];
echo "<option value=5>".$lang_label["monitor_report"];
echo "<option value=6>".$lang_label["avg_value"];
echo "<option value=7>".$lang_label["max_value"];
echo "<option value=8>".$lang_label["min_value"];
echo "</select>";
// Custom graph
// -----------------------
echo "<tr><td class='datos2'>";
echo "<b>".$lang_name["custom_graph_name"]."</b>";
echo "<td class='datos2' colspan=3>";
echo "<select name='id_custom_graph' size=1 style='width:180px;'>";
$sql1="SELECT * FROM tgraph";
$result = mysql_query($sql1);
while ($row=mysql_fetch_array($result)){
echo "<option value=".$row["id_graph"].">".$row["name"];
}
echo "</select>";
// Period
echo "<tr><td class='datos'>";
echo "<b>".$lang_label["period"]."</b>";
echo "<td class='datos' colspan=3>";
echo "<select name='period'>";
echo "<option value=3600>"."Hour";
echo "<option value=7200>"."2 Hours";
echo "<option value=10800>"."3 Hours";
echo "<option value=21600>"."6 Hours";
echo "<option value=43200>"."12 Hours";
echo "<option value=86400>"."Last day";
echo "<option value=172800>"."Two days";
echo "<option value=604800>"."Last Week";
echo "<option value=1296000>"."15 days";
echo "<option value=2592000>"."Last Month";
echo "<option value=5184000>"."Two Month";
echo "<option value=15552000>"."Six Months";
echo "</select>";
// SLA Max
echo "<tr><td class='datos2'>";
echo "<b>".$lang_label["sla_max"]."</b>";
echo "<td class='datos2'>";
echo "<input type=text size=6 name='sla_max'>";
// SLA Min
echo "<td class='datos2'>";
echo "<b>".$lang_label["sla_min"]."</b>";
echo "<td class='datos2'>";
echo "<input type=text size=6 name='sla_min'>";
// SLA limit
echo "<tr><td class='datos'>";
echo "<b>".$lang_label["sla_limit"]."</b>";
echo "<td class='datos'>";
echo "<input type=text size=6 name='sla_limit'>";
echo "</table>";
echo "<table width=500 cellspacing=4 cellpading=4'>";
echo "<tr><td align='right'>";
echo "<input type='submit' class='sub wand' value='".$lang_label["add"]."'>";
echo "</table>";
echo "</form>";
// Part 3 - List of already assigned report items
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo "<h2>".$lang_label["report_items"]."</h2>";
echo "<table width=500 cellspacing=4 cellpadding=4 class='databox'>";
echo "<tr><th>".$lang_label["type"]."<th>".$lang_label["agent_name"]."<th>".$lang_label["module_name"]."<th>".$lang_label["period"]."<th>".$lang_label["delete"];
$sql = "SELECT * FROM treport_content WHERE id_report = $id_report";
$res=mysql_query($sql);
$color = 0;
while ($row = mysql_fetch_array($res)){
// Calculate table line color
if ($color == 1){
$tdcolor = "datos";
$color = 0;
}
else {
$tdcolor = "datos2";
$color = 1;
}
$id_rc = $row["id_rc"];
$type = $row["type"];
switch ($type){
case "0": $type_desc = "Graph"; break;
case "1": $type_desc = "User graph"; break;
case "2": $type_desc = "SLA"; break;
case "3": $type_desc = "Event report"; break;
case "4": $type_desc = "Alert report"; break;
case "5": $type_desc = "Monitor report"; break;
case "6": $type_desc = "Avg.Value"; break;
case "7": $type_desc = "Max.Value"; break;
case "8": $type_desc = "Min.Value"; break;
}
$period = $row["period"];
$id_am = $row["id_agent_module"];
$name = "N/A";
$agent_name = "N/A";
if ($id_am != ""){
$agent_name = dame_nombre_agente_agentemodulo ($id_am);
$module_name = dame_nombre_modulo_agentemodulo ($id_am);
}
echo "<tr>";
echo "<td class='$tdcolor'>".$type_desc;
echo "<td class='$tdcolor'>".$agent_name;
echo "<td class='$tdcolor'>".$module_name;
echo "<td class='$tdcolor'>".$period;
echo "<td class='$tdcolor' align='center'>";
if ($form_id_user == $id_user){
echo "<a href='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id=1&delete=$id_rc'><img src='images/cancel.gif'></A>";
}
}
echo "</table>";
}
} else {
// Report item editor / add
// Report LIST
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo "<h3>".$lang_label["custom_reporting"]."</h3>";
echo "<table width='500' cellpadding=4 cellpadding=4 class='databox'>";
echo "<tr><th>".$lang_label["report_name"]."<th>".$lang_label["description"]."<th>".$lang_label["Manage"]."<th>".$lang_label["delete"];
$color=1;
$sql="SELECT * FROM treport";
$res=mysql_query($sql);
while ($row = mysql_fetch_array($res)){
if (($row["private"]==0) || ($row["id_user"] == $id_user)){
// Calculate table line color
if ($color == 1){
$tdcolor = "datos";
$color = 0;
}
else {
$tdcolor = "datos2";
$color = 1;
}
echo "<tr>";
echo "<td valign='top' class='$tdcolor'>".$row["name"];
echo "<td class='$tdcolor'>".$row["description"];
$id_report = $row["id_report"];
echo "<td valign='middle' class='$tdcolor' align='center'><a href='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&id=$id_report'><img src='images/setup.png'></A>";
echo "<td valign='middle' class='$tdcolor' align='center'><a href='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&delete_report=$id_report'><img src='images/cancel.gif'></A>";
}
}
echo "</table>";
echo "<table width=500 cellpadding=4 cellpadding=4>";
echo "<form method=post action='index.php?sec=greporting&sec2=godmode/reporting/reporting_builder&create_report=1'>";
echo "<tr><td align='right'>";
echo "<input type=submit class='sub wizard' value='".$lang_label["add"]."'>";
echo "</form>";
echo "</table>";
}
?>

View File

@ -96,7 +96,7 @@ if($result2=mysql_query("SELECT * FROM tconfig")){
case "bgimage": $config_bgimage=$row2["value"];
break;
case "style": $config_style=$row2["value"];
break;
break;
}
}
} else {

View File

@ -397,5 +397,69 @@ function format_for_graph ( $number , $decimals=2, $dec_point=".", $thousands_se
return number_format ($number, 0, $dec_point, $thousands_sep);
}
function give_parameter_get ( $name, $default = "" ){
$output = $default;
if (isset ($_GET[$name])){
$output = $_GET[$name];
}
return $output;
}
?>
function give_parameter_post ( $name, $default = "" ){
$output = $default;
if (isset ($_POST[$name])){
$output = $_POST[$name];
}
return $output;
}
function human_time_comparation ( $timestamp ){
global $config;
require ("include/languages/language_".$config["language_code"].".php");
$ahora=date("Y/m/d H:i:s");
$seconds = strtotime($ahora) - strtotime($timestamp);
if ($seconds < 3600)
$render = format_numeric($seconds/60,2)." ".$lang_label["minutes"];
elseif (($seconds >= 3600) and ($seconds < 86400))
$render = format_numeric ($seconds/3600,2)." ".$lang_label["hours"];
elseif ($seconds >= 86400)
$render = format_numeric ($seconds/86400,2)." ".$lang_label["days"];
return $render;
}
function human_time_description ($period){
switch ($period) {
case 3600: $period_label = "Hour";
break;
case 7200: $period_label = "2 Hours";
break;
case 10800: $period_label = "3 Hours";
break;
case 21600: $period_label = "6 Hours";
break;
case 43200: $period_label = "12 Hours";
break;
case 86400: $period_label = "Day";
break;
case 172800: $period_label = "Two days";
break;
case 345600: $period_label = "Four days";
break;
case 604800: $period_label = "Last Week";
break;
case 1296000: $period_label = "15 Days";
break;
case 2592000: $period_label = "Last Month";
break;
case 5184000: $period_label = "Two Month";
break;
case 15552000: $period_label = "Six Months";
break;
case 31104000: $period_label = "One year";
break;
default: $period_label = "Day";
}
return $period_label;
}
?>

View File

@ -6,10 +6,8 @@
// 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
// Additions to Pandora FMS 1.2 graph code
// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es
//
// This program is free software; you can redistribute it and/or
@ -1191,4 +1189,6 @@ function return_moduledata_min_value ($id_agent_module, $period){
}
?>

View File

@ -0,0 +1,44 @@
<?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
function return_module_SLA ($id_agent_module, $period, $min_value, $max_value){
require("config.php");
$datelimit = time() - $period; // limit date
$id_agent = give_db_value ("id_agente", "tagente_modulo", "id_agente_modulo", $id_agent_module);
// Get the whole interval of data
$query1="SELECT * FROM tagente_datos WHERE id_agente = $id_agent AND id_agente_modulo = $id_agent_module AND utimestamp > $datelimit";
$resq1=mysql_query($query1);
$last_data = "";
$total_badtime = 0;
$interval_begin = 0;
$interval_last = 0;
if ($resq1 != 0){
while ($row=mysql_fetch_array($resq1)){
if ( ($row["datos"] > $max_value) OR ($row["datos"] < $min_value)){
if ($interval_begin == 0){
$interval_begin = $row["utimestamp"];
}
} elseif ($interval_begin != 0){
// Here ends interval with data outside valid values,
// Need to add this time to counter
$interval_last = $row["utimestamp"];
$temp_time = $interval_last - $interval_begin;
$total_badtime = $total_badtime + $temp_time;
$interval_begin = 0;
$interval_last = 0;
}
}
} else
return 100;
$result = 100 - ($total_badtime / $period ) * 100;
return $result;
}
?>

View File

@ -792,9 +792,35 @@ $lang_label["min_valid_value_help"]="Min. possible value to consider 'valid' val
$lang_label["max_valid_value_help"]="Max. possible value to consider 'valid' values, above this limit, Pandora FMS will fire the alert";
$lang_label["alert_time_threshold_help"]="This value must be al least Module Interval * (Min.Number of Alerts + 1)";
$lang_label["style_template"]="Style template";
$lang_label["report_name"]="Report name";
$lang_label["custom_reporting_builder"]="Custom reporting builder";
$lang_label["report_builder"]="Report builder";
$lang_label["manage_reporting"]="Manage reports";
$lang_label["report_items"]="Report items";
$lang_label["period"]="Period";
$lang_label["reporting_item_add"]="Add item to report";
$lang_label["template"]="Template";
$lang_label["add_mod_ok"]="Modules added successfully";
$lang_label["simple_graph"] = "Simple graph";
$lang_label["custom_graph"] = "Custom graph";
$lang_label["SLA"] = "S.L.A";
$lang_label["event_report"] = "Event report";
$lang_label["alert_report"] = "Alert report";
$lang_label["monitor_report"] = "Monitor report";
$lang_label["avg_value"]="Avg. Value";
$lang_label["max_value"]="Max. Value";
$lang_label["min_value"]="Min. Value";
$lang_label["reporting_type"]="Reporting type";
$lang_label["sla_max"] = "SLA Max. (value)";
$lang_label["sla_min"] = "SLA Min. (value)";
$lang_label["sla_limit"] = "SLA Limit (%)";
$lang_label["up"]="Up";
$lang_label["down"]="Down";
global $lang_label;
global $help_label;
?>

View File

@ -15,13 +15,10 @@ div.menug {
width: 155px;
margin-bottom: 5px;
}
#god1 li, #god2 li, #god3 li, #god4 li, #god5 li, #god6 li, #god7 li, #god8 li, #god1s li,
#god2s li, #god3s li, #god4s li, #god5s li, #god6s li, #god7s li, #god8s li, #god_module li, #god_module_sel li {
#god1 li, #god2 li, #god3 li, #god4 li, #god5 li, #god51 li, #god6 li, #god7 li, #god8 li, #god1s li, #god2s li, #god3s li, #god4s li, #god5s li, #god51s li, #god6s li, #god7s li, #god8s li, #god_module li, #god_module_sel li {
padding: 0px 0px 0px 30px;
}
div#god1>ul, div#god2>ul, div#god3>ul, div#god4>ul, div#god5>ul, div#god6>ul,
div#god7>ul, div#god8>ul, div#god1s>ul, div#god2s>ul, div#god3s>ul, div#god4s>ul,
div#god5s>ul, div#god6s>ul, div#god7s>ul, div#god8s>ul, div#god_module>ul, div#god_module_sel>ul {
div#god1>ul, div#god2>ul, div#god3>ul, div#god4>ul, div#god5>ul, div#god51>ul, div#god6>ul, div#god7>ul, div#god8>ul, div#god1s>ul, div#god2s>ul, div#god3s>ul, div#god4s>ul, div#god5s>ul, div#god51s>ul, div#god6s>ul, div#god7s>ul, div#god8s>ul, div#god_module>ul, div#god_module_sel>ul {
width: 124px;
}
#god1 li, #god1 li:hover, #god1s li {
@ -39,6 +36,9 @@ div#god5s>ul, div#god6s>ul, div#god7s>ul, div#god8s>ul, div#god_module>ul, div#g
#god5 li, #god5 li:hover, #god5s li {
background: url(../../images/god5.gif) no-repeat 3px 3px;
}
#god51 li, #god51 li:hover, #god51s li {
background: url(../../images/reporting.png) no-repeat 4px 4px;
}
#god6 li, #god6 li:hover, #god6s li {
background: url(../../images/god6.gif) no-repeat 4px 3px;
}
@ -62,7 +62,7 @@ div.arrowg>ul, div.arrowgs>ul {
#god a:hover,
#god1 li:hover, #god1s li, #god2 li:hover, #god2s li, #god3 li:hover, #god3s li,
#god4 li:hover, #god4s li, #god5 li:hover, #god5s li, #god6 li:hover, #god6s li,
#god7 li:hover, #god7s li, #god8 li:hover, #god8s li, #god_module li:hover, #god_module_sel li,
#god7 li:hover, #god7s li, #god8 li:hover, #god8s li, #god_module li:hover, #god_module_sel li, #god51 li:hover, #god51s li,
.arrowg li:hover, .arrowgs li
{
background-color: #efefbd;

View File

@ -66,11 +66,11 @@ checkbox {
padding: 4px;
border:1px solid #eee;
}
h1, h2, h3 {
h1, h2, h3, h4 {
font: bold 1em Arial, Sans-serif;
text-transform: uppercase;
color: #786;
padding-bottom: 5px;
padding-bottom: 4px;
padding-top: 7px;
}
h1 {
@ -80,8 +80,16 @@ h2 {
font-size: 15px;
}
h3 {
font-size: 13px;
font-size: 14px;
}
h4 {
margin-bottom: 2px;
padding-bottom: 0px;
padding-top: 5px;
font-size: 13px;
color: #000;
}
a {
color: #486787;
text-decoration: none;

View File

@ -23,6 +23,8 @@ require("include/config.php");
function datos_raw($id_agente_modulo, $periodo){
require("include/config.php");
require("include/languages/language_".$language_code.".php");
$id_user = $_SESSION["id_usuario"];
$periodo_label = $periodo;
switch ($periodo) {
case "mes":
$periodo = 86400*30;
@ -39,6 +41,7 @@ function datos_raw($id_agente_modulo, $periodo){
}
$periodo = time() - $periodo;
$id_agent = give_agent_id_from_module_id ($id_agente_modulo);
$id_group = give_db_value ("id_grupo", "tagente", "id_agente", $id_agent);
// 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
@ -65,6 +68,7 @@ function datos_raw($id_agente_modulo, $periodo){
if (mysql_num_rows($result)){
echo "<table cellpadding='3' cellspacing='3' width='600' class='databox'>";
$color=1;
echo "<th witdh=20>";
echo "<th>".$lang_label["timestamp"]."</th>";
echo "<th>".$lang_label["data"]."</th>";
while ($row=mysql_fetch_array($result)){
@ -76,7 +80,13 @@ function datos_raw($id_agente_modulo, $periodo){
$tdcolor = "datos2";
$color = 1;
}
echo "<tr>";
echo "<tr>";
if (give_acl($id_user, $id_group, "AW") ==1) {
echo "<td class='".$tdcolor."' width=20>";
echo "<a href='index.php?sec=estado&sec2=operation/agentes/datos_agente&tipo=$periodo_label&id=$id_agente_modulo&delete=".$row["id_agente_datos"]."'><img src='images/cancel.gif' border=0>";
} else {
echo "<td class='".$tdcolor."'>";
}
echo "<td class='".$tdcolor."' style='width:150px'>".$row["timestamp"];
echo "<td class='".$tdcolor."'>";
if (is_numeric($row["datos"])) {
@ -119,6 +129,12 @@ if (isset($_GET["tipo"]) AND isset($_GET["id"])) {
exit;
}
if (isset($_GET["delete"])) {
$delete =$_GET["delete"];
$sql = "DELETE FROM tagente_datos WHERE id_agente_datos = $delete";
$result=mysql_query($sql);
}
datos_raw($id,$tipo);
?>

View File

@ -227,7 +227,7 @@ if (give_acl($_SESSION["id_usuario"], 0, "AR")==1) {
} else {
echo '<div id="op8">';
}
echo '<ul class="mn"><li><a href="index.php?sec=reporting&sec2=operation/reporting/custom_reporting" class="mn">'. $lang_label["reporting"].'</a></li></ul></div>';
echo '<ul class="mn"><li><a href="index.php?sec=reporting&sec2=operation/reporting/graph_viewer" class="mn">'. $lang_label["reporting"].'</a></li></ul></div>';
// Custom reporting
if (isset($_GET["sec"]) && $_GET["sec"] == "reporting"){
@ -248,16 +248,7 @@ if (give_acl($_SESSION["id_usuario"], 0, "AR")==1) {
}
echo "<ul class='mn'><li><a href='index.php?sec=reporting&sec2=operation/reporting/graph_viewer' class='mn'>".$lang_label["custom_graphs"]."</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

@ -27,97 +27,10 @@ if (comprueba_login() != 0) {
exit;
}
if (isset($_GET["view_report"])){
$id_report = $_GET["view_report"];
$sql="SELECT * FROM treport WHERE id_report = $id_report";
$res=mysql_query($sql);
if ($row = mysql_fetch_array($res)){
$id_user = $row["id_user"];
$private = $row["private"];
$description = $row["description"];
$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");
include ("general/noaccess.php");
exit;
}
//echo "SLA for Tato: %".return_module_SLA (50, 604800, 1, 1);
$sql2="SELECT * FROM tgraph_source WHERE id_graph = $id_graph";
$res2=mysql_query($sql2);
while ( $row2 = mysql_fetch_array($res2)){
$weight = $row2["weight"];
$id_agent_module = $row2["id_agent_module"];
if (!isset($modules)){
$modules = $id_agent_module;
$weights = $weight;
} else {
$modules = $modules.",".$id_agent_module;
$weights = $weights.",".$weight;
}
}
echo "<h3>".$lang_label["combined_image"]."</h3>";
echo "<table class='databox_frame'>";
echo "<tr><td>";
echo "<img src='reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&label=$name&height=$height&width=$width&period=$period' border=1 alt=''>";
echo "</td></tr></table>";
switch ($period) {
case 3600: $period_label = "Hour";
break;
case 21600: $period_label = "6 Hours";
break;
case 43200: $period_label = "12 Hours";
break;
case 86400: $period_label = "Day";
break;
case 172800: $period_label = "Two days";
break;
case 604800: $period_label = "Last Week";
break;
case 1296000: $period_label = "15 Days";
break;
case 2592000: $period_label = "Last Month";
break;
case 5184000: $period_label = "Two Month";
break;
case 15552000: $period_label = "Six Months";
break;
default: $period_label = "Day";
}
echo "<form method='POST' action='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=$id_graph'>";
echo "<table class='databox_frame'>";
echo "<tr><td class='datos'>";
echo "<b>Period</b>";
echo "<td class='datos'>";
echo "<select name='period'>";
if ($period==0)
echo "<option value=86400>".$period_label;
else
echo "<option value=$period>".$period_label;
echo "<option value=3600>"."Hour";
echo "<option value=21600>"."6 Hours";
echo "<option value=43200>"."12 Hours";
echo "<option value=86400>"."Last day";
echo "<option value=172800>"."Two days";
echo "<option value=604800>"."Last Week";
echo "<option value=1296000>"."15 days";
echo "<option value=2592000>"."Last Month";
echo "<option value=5184000>"."Two Month";
echo "<option value=15552000>"."Six Months";
echo "</select>";
echo "<td class='datos'>";
echo "<input type=submit value='".$lang_label["update"]."' class='sub upd'>";
echo "</table>";
echo "</form>";
}
}
echo "<h3>".$lang_label["custom_report_builder"]."</h3>";
echo "<table width='500' cellpadding=4 cellpadding=4 class='databox_frame'>";
echo "<h3>".$lang_label["custom_reporting"]."</h3>";
echo "<table width='500' cellpadding=4 cellpadding=4 class='databox'>";
echo "<tr><th>".$lang_label["report_name"]."<th>".$lang_label["description"]."<th>".$lang_label["view"];
$color=1;
$sql="SELECT * FROM treport";
@ -136,14 +49,11 @@ while ($row = mysql_fetch_array($res)){
echo "<tr>";
echo "<td valign='top' class='$tdcolor'>".$row["name"];
echo "<td class='$tdcolor'>".$row["description"];
$id_graph = $row["id_graph"];
echo "<td valign='middle' class='$tdcolor' align='center'><a href='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=$id_graph'><img src='images/images.png'></A>";
$id_report = $row["id_report"];
echo "<td valign='middle' class='$tdcolor' align='center'><a href='index.php?sec=reporting&sec2=operation/reporting/reporting_viewer&id=$id_report'><img src='images/reporting.png'></A>";
}
}
echo "</table>";
?>

View File

@ -0,0 +1,239 @@
<?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.
// Login check
$id_user=$_SESSION["id_usuario"];
global $REMOTE_ADDR;
if (comprueba_login() != 0) {
audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access graph builder");
include ("general/noaccess.php");
exit;
}
$id_report = give_parameter_get ( 'id', $default = "");
if ($id_report == ""){
audit_db($id_user,$REMOTE_ADDR, "HACK Attempt","Trying to access graph viewer withoud ID");
include ("general/noaccess.php");
exit;
}
require ("include/functions_reporting.php");
$report_name = give_db_value ("name", "treport", "id_report", $id_report);
$report_description = give_db_value ("description", "treport", "id_report", $id_report);
//echo "SLA for Tato: %".return_module_SLA (50, 604800, 1, 1);
echo "<h1>".$lang_label["custom_reporting"]." - ".$report_name."</h1>";
echo "<table class='databox' cellpadding= 4 cellspacing=4 width=750>";
echo "<tr>";
echo "<td width=50 align='left'><img src='images/reporting.png' width=32 height=32>";
echo "<td>".$report_description."</td>";
echo "</table>";
echo "<table width=750 cellpadding=4 cellspacing=4 class='databox'>";
$sql = "SELECT * FROM treport_content WHERE id_report = $id_report ORDER by type desc";
$res=mysql_query($sql);
while ($row = mysql_fetch_array($res)){
$type = $row["type"];
$sla_max = $row["sla_max"];
$sla_min = $row["sla_min"];
$sla_limit = $row["sla_limit"];
$id_agent_module = $row["id_agent_module"];
$period = $row["period"];
$id_gs = $row["id_gs"];
switch($type){
case 2: // SLA
$module_name = give_db_value ("nombre", "tagente_modulo", "id_agente_modulo", $id_agent_module);
$agent_name = dame_nombre_agente_agentemodulo ($id_agent_module);
$sla_result = format_numeric(return_module_SLA ($id_agent_module, $period, $sla_max, $sla_min), 2);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["SLA"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=2 class=datos>";
echo "<font size='0.6em'>";
echo $lang_label["sla_max"]. " : ".$sla_max. "<br>";
echo $lang_label["sla_min"]. " : ".$sla_min. "<br>";
echo $lang_label["sla_limit"]. " : ".$sla_limit. "<br>";
echo "</font>";
echo "<td class=datos valign='middle' align='right' >";
if ($sla_result >= $sla_limit)
echo "<p style='font: bold 3em Arial, Sans-serif; color: #000000;'>";
else
echo "<p style='font: bold 3em Arial, Sans-serif; color: #ff0000;'>";
echo $sla_result. " %";
echo "</p>";
echo "</td></tr>";
break;
case 0: // Simple graph
$module_name = give_db_value ("nombre", "tagente_modulo", "id_agente_modulo", $id_agent_module);
$agent_name = dame_nombre_agente_agentemodulo ($id_agent_module);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["simple_graph"]."</h4>";
echo "<td class='datos3'>";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' valign='top'>";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr><td colspan=3 class='datos' valign='top'>";
echo "<img src='reporting/fgraph.php?tipo=sparse&id=$id_agent_module&height=230&width=720&period=$period&avg_only=1&pure=1' border=0 alt=''>";
echo "</tr>";
break;
case 1: // Custom/Combined graph
$module_name = give_db_value ("nombre", "tagente_modulo", "id_agente_modulo", $id_agent_module);
$agent_name = dame_nombre_agente_agentemodulo ($id_agent_module);
$graph_name = give_db_value ("name", "tgraph", "id_graph", $id_gs);
$sql2="SELECT * FROM tgraph_source WHERE id_graph = $id_gs";
$res2=mysql_query($sql2);
while ( $row2 = mysql_fetch_array($res2)){
$weight = $row2["weight"];
$id_agent_module = $row2["id_agent_module"];
if (!isset($modules)){
$modules = $id_agent_module;
$weights = $weight;
} else {
$modules = $modules.",".$id_agent_module;
$weights = $weights.",".$weight;
}
}
echo "<tr><td class=datos3 >";
echo "<h4>".$lang_label["custom_graph"]."</h4>";
echo "<td class=datos3>";
echo "<h4>$graph_name</h4>";
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 "</tr>";
break;
case 6: // AVG value
$module_name = give_db_value ("nombre", "tagente_modulo", "id_agente_modulo", $id_agent_module);
$agent_name = dame_nombre_agente_agentemodulo ($id_agent_module);
$avg_value = format_for_graph(return_moduledata_avg_value ($id_agent_module, $period),2);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["avg_value"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=2 class=datos>";
echo "<td class=datos valign='middle' align='right' >";
echo "<p style='font: bold 3em Arial, Sans-serif; color: #000000;'>";
echo $avg_value;
echo "</p>";
echo "</td></tr>";
break;
case 7: // MAX value
$module_name = give_db_value ("nombre", "tagente_modulo", "id_agente_modulo", $id_agent_module);
$agent_name = dame_nombre_agente_agentemodulo ($id_agent_module);
$max_value = format_for_graph(return_moduledata_max_value ($id_agent_module, $period),2);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["max_value"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=2 class=datos>";
echo "<td class=datos valign='middle' align='right' >";
echo "<p style='font: bold 3em Arial, Sans-serif; color: #000000;'>";
echo $max_value;
echo "</p>";
echo "</td></tr>";
break;
case 8: // MIN value
$module_name = give_db_value ("nombre", "tagente_modulo", "id_agente_modulo", $id_agent_module);
$agent_name = dame_nombre_agente_agentemodulo ($id_agent_module);
$min_value = format_for_graph(return_moduledata_min_value ($id_agent_module, $period),2);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["min_value"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=2 class=datos>";
echo "<td class=datos valign='middle' align='right' >";
echo "<p style='font: bold 3em Arial, Sans-serif; color: #000000;'>";
echo $min_value;
echo "</p>";
echo "</td></tr>";
break;
case 5: // Monitor report
$module_name = give_db_value ("nombre", "tagente_modulo", "id_agente_modulo", $id_agent_module);
$agent_name = dame_nombre_agente_agentemodulo ($id_agent_module);
$monitor_value = $sla_result = format_numeric(return_module_SLA ($id_agent_module, $period, 1, 1), 2);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["monitor_report"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=2 class=datos>";
echo "<td class=datos valign='middle' align='right' >";
echo "<p style='font: bold 3em Arial, Sans-serif; color: #000000;'>";
echo $monitor_value." %"."<img src='images/b_green.gif' height=32 width=32>";
echo "</p>";
$monitor_value2 = 100 - $monitor_value ;
echo "<p style='font: bold 3em Arial, Sans-serif; color: #ff0000;'>";
echo $monitor_value2." %"."<img src='images/b_red.gif' height=32 width=32>";
echo "</p>";
echo "</td></tr>";
break;
case 3: // Event report
$module_name = give_db_value ("nombre", "tagente_modulo", "id_agente_modulo", $id_agent_module);
$agent_name = dame_nombre_agente_agentemodulo ($id_agent_module);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["event_report"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=2 class=datos>";
echo "<td class=datos valign='middle' align='right' >";
echo "Not ready yet ;-)";
echo "</td></tr>";
break;
case 4: // Alert report
$module_name = give_db_value ("nombre", "tagente_modulo", "id_agente_modulo", $id_agent_module);
$agent_name = dame_nombre_agente_agentemodulo ($id_agent_module);
echo "<tr><td class='datos3'>";
echo "<h4>".$lang_label["alert_report"]."</h4>";
echo "<td class='datos3' >";
echo "<h4>$agent_name - $module_name</h4>";
echo "<td class='datos3' >";
echo "<h4>".human_time_description($period)."</h4>";
echo "<tr>";
echo "<td colspan=2 class=datos>";
echo "<td class=datos valign='middle' align='right' >";
echo "Not ready yet ;-)";
echo "</td></tr>";
break;
}
}
echo "</table>";
?>

View File

@ -516,9 +516,30 @@ CREATE TABLE `treport_content` (
`id_agent_module` int(11) NOT NULL default 0,
`type` tinyint(1) UNSIGNED NOT NULL default 0,
`period` int(11) NOT NULL default 0,
`sla_max` int(11) NOT NULL default 0,
`sla_min` int(11) NOT NULL default 0,
`sla_limit` int(11) NOT NULL default 0,
PRIMARY KEY(`id_rc`)
) ENGINE = InnoDB;
/*
treport_content descripcion
type valid values
0 - Simple graph
1 - User/Combined graph
2 - SLA
3 - Event report
4 - Alert report
5 - Monitor report
6 - Avg. value
7 - Max. value
8 - Min. value
id_gs is for combined graph pprimary key id
*/
CREATE TABLE `tlayout` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,

View File

@ -6,10 +6,8 @@
// 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
// Additions to Pandora FMS 1.2 graph code
// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es
//
// This program is free software; you can redistribute it and/or
@ -72,7 +70,7 @@ 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 ) {
function graphic_combined_module ($module_list, $weight_list, $periodo, $width, $height, $title, $unit_name, $show_event=0, $show_alert=0, $pure =0 ) {
include ("../include/config.php");
require ("../include/languages/language_".$language_code.".php");
require_once 'Image/Graph.php';
@ -159,7 +157,7 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
while ($row=mysql_fetch_array($result)){
$datos = $row[0];
$utimestamp = $row[1];
if ($datos > 0) {
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;
@ -219,9 +217,7 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
// *************
$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";
@ -233,24 +229,40 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
$title_period = "Last month";
else
$title_period = "Last ".format_numeric(($periodo / (3600*24)),2)." days";
$Graph->add(
Image_Graph::vertical(
if ($pure == 0){
$Font =& $Graph->addNew('font', $config_fontpath);
$Font->setSize(6);
$Graph->setFont($Font);
$Graph->add(
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::vertical(
$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);
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::vertical(
$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);
} else {
$Font =& $Graph->addNew('font', $config_fontpath);
$Font->setSize(6);
$Graph->setFont($Font);
$Graph->add(
Image_Graph::vertical(
$Plotarea = Image_Graph::factory('plotarea'),
$Legend = Image_Graph::factory('legend'),
85
)
);
$Legend->setPlotarea($Plotarea);
}
// Create the dataset
// Merge data into a dataset object (sancho)
// $Dataset =& Image_Graph::factory('dataset');
@ -331,7 +343,7 @@ function graphic_combined_module ($module_list, $weight_list, $periodo, $width,
}
function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $show_event,
$width, $height , $title, $unit_name, $show_alert, $avg_only = 0 ) {
$width, $height , $title, $unit_name, $show_alert, $avg_only = 0, $pure=0 ) {
include ("../include/config.php");
require ("../include/languages/language_".$language_code.".php");
@ -420,7 +432,7 @@ function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $show_event,
while ($row=mysql_fetch_array($result)){
$datos = $row[0];
$utimestamp = $row[1];
if ($datos > 0) {
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;
@ -478,24 +490,27 @@ function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $show_event,
$title_period = "Last month";
else
$title_period = "Last ".format_numeric(($periodo / (3600*24)),2)." days";
$Graph->add(
Image_Graph::vertical(
if ($pure == 0){
$Graph->add(
Image_Graph::vertical(
$Title = Image_Graph::factory('title', array(' Pandora FMS Graph - '.strtoupper($nombre_agente)." - ".$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'),
85
),
15)
);
$Legend->setPlotarea($Plotarea);
$Title->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
$Subtitle->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
Image_Graph::vertical(
$Title = Image_Graph::factory('title', array(' Pandora FMS Graph - '.strtoupper($nombre_agente)." - ".$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'),
85
),
15)
);
$Legend->setPlotarea($Plotarea);
$Title->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
$Subtitle->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
} else { // Pure, without title and legends
$Graph->add($Plotarea = Image_Graph::factory('plotarea'));
}
// Create the dataset
// Merge data into a dataset object (sancho)
// $Dataset =& Image_Graph::factory('dataset');
@ -542,9 +557,9 @@ function grafico_modulo_sparse ( $id_agente_modulo, $periodo, $show_event,
// create the 1st plot as smoothed area chart using the 1st dataset
$Plot =& $Plotarea->addNew('area', array(&$dataset));
if ($avg_only == 1){
$Plot->setLineColor('gray@0.4');
$Plot->setLineColor('black@0.1');
} else {
$Plot->setLineColor('yellow@0.1');
$Plot->setLineColor('yellow@0.2');
}
$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
@ -1731,6 +1746,12 @@ if (isset($_GET["tipo"]))
else
$tipo = ""; // 1 day default period
// Pure (Without title and legend)
if ( isset($_GET["pure"]))
$pure = $_GET["pure"];
else
$pure = 0;
if (isset($_GET["period"]))
$period = entrada_limpia($_GET["period"]);
@ -1816,7 +1837,7 @@ else
if (isset($_GET["tipo"])){
if ($_GET["tipo"] == "sparse"){
grafico_modulo_sparse($id, $period, $draw_events, $width, $height , $label, $unit_name, $draw_alerts, $avg_only);
grafico_modulo_sparse ($id, $period, $draw_events, $width, $height , $label, $unit_name, $draw_alerts, $avg_only, $pure);
}
elseif ($_GET["tipo"] =="estado_incidente")
grafico_incidente_estados();
@ -1858,7 +1879,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 );
graphic_combined_module ($module_list, $weight_list, $period, $width, $height , $label, $unit_name, $draw_events, $draw_alerts, $pure);
}
else
graphic_error ();