2009-01-21 Evi Vanoost <vanooste@rcbi.rochester.edu>

* include/functions_db.php: Removed auth init because I fixed stat_win.php
	
	* include/functions_html.php: Added border and onclick. Fixed double quote

	* reporting/fgraph.php: Fixed some minor bugs
	
	* reporting/stat_win.php: Added authentication there too

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1387 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
guruevi 2009-01-21 18:55:29 +00:00
parent 91e66a0b5d
commit 84d1863854
5 changed files with 168 additions and 205 deletions

View File

@ -1,3 +1,13 @@
2009-01-21 Evi Vanoost <vanooste@rcbi.rochester.edu>
* include/functions_db.php: Removed auth init because I fixed stat_win.php
* include/functions_html.php: Added border and onclick. Fixed double quote
* reporting/fgraph.php: Fixed some minor bugs
* reporting/stat_win.php: Added authentication there too
2009-01-21 Esteban Sanchez <estebans@artica.es> 2009-01-21 Esteban Sanchez <estebans@artica.es>
* godmode/agentes/alert_manager.php: Fixed a little bug that avoids * godmode/agentes/alert_manager.php: Fixed a little bug that avoids

View File

@ -17,12 +17,6 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
if (!isset ($config["auth"])) {
require_once ($config["homedir"]."/include/auth/mysql.php");
} else {
require_once ($config["homedir"]."/include/auth/".$config["auth"]["scheme"].".php");
}
/** /**
* Check if login session variables are set. * Check if login session variables are set.
* *

View File

@ -686,12 +686,15 @@ function print_help_tip ($text, $return = false) {
* @return string HTML code if return parameter is true. * @return string HTML code if return parameter is true.
*/ */
function print_image ($src, $return = false, $options = false) { function print_image ($src, $return = false, $options = false) {
$output = '<img src="'.$src.'"" '; $output = '<img src="'.$src.'" ';
if ($options) { if ($options) {
if (isset ($options['alt'])) if (isset ($options['alt']))
$output .= 'alt="'.$options['alt'].'" '; $output .= 'alt="'.$options['alt'].'" ';
if (isset ($options['border']))
$output .= 'border="'.$options['border'].'" ';
if (isset ($options['style'])) if (isset ($options['style']))
$output .= 'style="'.$options['style'].'" '; $output .= 'style="'.$options['style'].'" ';
@ -709,6 +712,10 @@ function print_image ($src, $return = false, $options = false) {
if (isset ($options['id'])) if (isset ($options['id']))
$output .= 'id="'.$options['id'].'" '; $output .= 'id="'.$options['id'].'" ';
if (isset ($options['onclick'])) {
$output .= 'onclick="'.$options['onclick'].'" ';
}
} }
$output .= '/>'; $output .= '/>';

View File

@ -432,11 +432,11 @@ function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event,
$alert_low = false; $alert_low = false;
// If we want to show alerts limits // If we want to show alerts limits
$alert_high = get_db_value ('MAX(max_value)', 'talert_template_modules', 'id_agent_module', (int) $id_agente_modulo); $alert_high = (int) get_db_value ('MAX(max_value)', 'talert_template_modules', 'id_agent_module', (int) $id_agente_modulo);
$alert_low = get_db_value ('MIN(max_value)', 'talert_template_modules', 'id_agent_module', (int) $id_agente_modulo); $alert_low = (int) get_db_value ('MIN(max_value)', 'talert_template_modules', 'id_agent_module', (int) $id_agente_modulo);
// if no valid alert defined to render limits, disable it // if no valid alert defined to render limits, disable it
if (($alert_low === false) && ($alert_high === false)) { if (($alert_low == 0) && ($alert_high == 0)) {
$show_alert = 0; $show_alert = 0;
} }
} }
@ -461,6 +461,10 @@ function grafico_modulo_sparse ($id_agente_modulo, $periodo, $show_event,
// If we want to show events in graphs // If we want to show events in graphs
$sql = sprintf ('SELECT utimestamp FROM tevento WHERE id_agente = %d AND utimestamp > %d', $id_agente, $fechatope); $sql = sprintf ('SELECT utimestamp FROM tevento WHERE id_agente = %d AND utimestamp > %d', $id_agente, $fechatope);
$eventos = get_db_all_rows_sql ($sql); $eventos = get_db_all_rows_sql ($sql);
if ($eventos === false) {
$eventos = array ();
}
foreach ($eventos as $row) { foreach ($eventos as $row) {
$utimestamp = $row[0]; $utimestamp = $row[0];
for ($i = 0; $i <= $resolution; $i++) { for ($i = 0; $i <= $resolution; $i++) {

View File

@ -18,6 +18,12 @@
// Global & session management // Global & session management
require_once ('../include/config.php'); require_once ('../include/config.php');
if (!isset ($config["auth"])) {
require_once ($config["homedir"]."/include/auth/mysql.php");
} else {
require_once ($config["homedir"]."/include/auth/".$config["auth"]["scheme"].".php");
}
if (! isset($_SESSION["id_user"])) { if (! isset($_SESSION["id_user"])) {
session_start(); session_start();
session_write_close(); session_write_close();
@ -29,118 +35,39 @@ require_once ('../include/functions_db.php');
check_login (); check_login ();
// Parsing the refresh before sending any header // Parsing the refresh before sending any header
$refresh = get_parameter ("refresh", -1); $refresh = (int) get_parameter ("refresh", -1);
if ($refresh != -1) if ($refresh > 0) {
header( 'refresh: ' . $_GET['refresh'] ); header('Refresh: '.$refresh);
echo '<html>
<head><title>Pandora FMS Graph</title>
<link rel="stylesheet" href="../include/styles/pandora_minimal.css" type="text/css">';
echo "<script type='text/javaScript' src='../include/javascript/calendar.js'></script>";
echo "</head><body>";
// Get input parameters
$label = get_parameter ("label","");
if (!isset($_GET["period"]) OR (!isset($_GET["id"]))) {
echo "<h3 class='error'>".__('There was a problem locating the source of the graph')."</h3>";
exit;
} }
$period = get_parameter ( "period", 3600);
switch ($period) {
case 3600: $period_label = __('1 hour');
break;
case 7200: $period_label = __('2 hours');
break;
case 21600: $period_label = __('6 hours');
break;
case 43200: $period_label = __('12 hours');
break;
case 86400: $period_label = __('1 day');
break;
case 172800: $period_label = __('2 days');
break;
case 432000: $period_label = __('5 days');
break;
case 604800: $period_label = __('1 week');
break;
case 1296000: $period_label = __('15 days');
break;
case 2592000: $period_label = __('1 month');
break;
case 5184000: $period_label = __('2 months');
break;
case 15552000: $period_label = __('6 months');
break;
default: $period_label = human_time_description_raw ($period);
}
$draw_alerts = get_parameter("draw_alerts", 0);
$avg_only = get_parameter ("avg_only", 0);
$period = get_parameter ("period", 86400);
$id = get_parameter ("id", 0);
$width = get_parameter ("width", 555);
$height = get_parameter ("height", 245);
$label = get_parameter ("label", "");
$start_date = get_parameter ("start_date", date("Y-m-d"));
$draw_events = get_parameter ("draw_events", 0);
$graph_type = get_parameter ("type", "sparse");
$zoom = get_parameter ("zoom", 1);
if ($zoom > 1){
$height=$height*($zoom/2.1);
$width=$width*($zoom/1.4);
}
if ($zoom > 1) {
echo "
<script type='text/javascript'>
window.resizeTo($width + 10, $height + 80);
</script>
";
}
$current = date("Y-m-d");
if ($start_date != $current){
$utime = strtotime ($start_date);
echo "<img src='fgraph.php?tipo=$graph_type&draw_alerts=$draw_alerts&draw_events=$draw_events&id=$id&zoom=$zoom&label=$label&height=$height&width=$width&period=$period&avg_only=$avg_only&date=$utime' border=0 alt=''>";
} else
echo "<img src='fgraph.php?tipo=$graph_type&draw_alerts=$draw_alerts&draw_events=$draw_events&id=$id&zoom=$zoom&label=$label&height=$height&width=$width&period=$period&avg_only=$avg_only' border=0 alt=''>";
echo "<table width=450 cellspacing=1 cellpadding=1 class='databox' style='margin-left: 20px'>";
echo "<tr><td><b>";
echo __('Max. Value')." </b>: ". format_for_graph(get_agentmodule_data_max ($id, $period));
echo "</td><td><b>";
echo __('Avg. Value')." </b>: ". format_for_graph(get_agentmodule_data_average ($id, $period));
echo "</td><td><b>";
echo __('Min. Value')." </b>: ". format_for_graph(get_agentmodule_data_min ($id, $period));
echo "</td></tr>";
echo "</table>";
?> ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pandora FMS Graph</title>
<link rel="stylesheet" href="../include/styles/pandora_minimal.css" type="text/css" />
<script type='text/javaScript' src='../include/javascript/calendar.js'></script>
<script type='text/javascript' src='../include/javascript/x_core.js'></script> <script type='text/javascript' src='../include/javascript/x_core.js'></script>
<script type='text/javascript' src='../include/javascript/x_event.js'></script> <script type='text/javascript' src='../include/javascript/x_event.js'></script>
<script type='text/javascript' src='../include/javascript/x_slide.js'></script> <script type='text/javascript' src='../include/javascript/x_slide.js'></script>
<script type='text/javascript'><!-- <script type='text/javascript'><!--
var defOffset = 2; var defOffset = 2;
var defSlideTime = 220; var defSlideTime = 220;
var tnActive = 0; var tnActive = 0;
var visibleMargin = 15; var visibleMargin = 15;
var menuW = 325; var menuW = 325;
var menuH = 310; var menuH = 310;
window.onload = function() { window.onload = function() {
var d; var d;
d = xGetElementById('divmenu'); d = xGetElementById('divmenu');
d.termNumber = 1; d.termNumber = 1;
xMoveTo(d, visibleMargin - menuW, 0); xMoveTo(d, visibleMargin - menuW, 0);
xShow(d); xShow(d);
xAddEventListener(document, 'mousemove', docOnMousemove, false); xAddEventListener(document, 'mousemove', docOnMousemove, false);
} }
function docOnMousemove(evt) { function docOnMousemove(evt) {
var e = new xEvent(evt); var e = new xEvent(evt);
var d = getTermEle(e.target); var d = getTermEle(e.target);
if (!tnActive) { // no def is active if (!tnActive) { // no def is active
@ -155,107 +82,128 @@ if ($start_date != $current){
tnActive = 0; tnActive = 0;
} }
} }
} }
function getTermEle(ele) { function getTermEle(ele) {
//window.status = ele; //window.status = ele;
while(ele && !ele.termNumber) { while(ele && !ele.termNumber) {
if (ele == document) return null; if (ele == document) return null;
ele = xParent(ele); ele = xParent(ele);
} }
return ele; return ele;
} }
//--> //-->
</script> </script>
</head> </head><body>
<body> <?php
<div id='divmenu' class='menu'> // Get input parameters
<b>Pandora FMS Graph configuration menu</b><br>Please, make your changes and apply with <i>Reload</i> button $label = get_parameter ("label","");
if (!isset($_GET["period"]) OR (!isset($_GET["id"]))) {
echo "<h3 class='error'>".__('There was a problem locating the source of the graph')."</h3>";
exit;
}
<form method='get' action='stat_win.php'> $period = get_parameter ( "period", 3600);
<?php $draw_alerts = get_parameter("draw_alerts", 0);
echo "<input type='hidden' name='id' value='$id'>"; $avg_only = get_parameter ("avg_only", 0);
echo "<input type='hidden' name='label' value='$label'>"; $period = get_parameter ("period", 86400);
if (isset($_GET["type"])) $id = get_parameter ("id", 0);
echo "<input type='hidden' name='type' value='".$_GET["type"]."'>"; $width = get_parameter ("width", 555);
?> $height = get_parameter ("height", 245);
<TABLE class='databox_frame' cellspacing=5> $label = get_parameter ("label", "");
</td><td> $start_date = get_parameter ("start_date", date("Y-m-d"));
<?php $draw_events = get_parameter ("draw_events", 0);
echo "<tr><td>"; $graph_type = get_parameter ("type", "sparse");
echo __('Refresh time'); $zoom = get_parameter ("zoom", 1);
echo "<td colspan=2>";
echo "<input type='text' size=5 name='refresh' value='" . $refresh . "'>";
echo "&nbsp;&nbsp;&nbsp;".__('Avg. Only'); if ($zoom > 1) {
if ($avg_only == 1) $height = $height * ($zoom / 2.1);
echo "<input type='checkbox' name='avg_only' value=1 CHECKED>"; $width = $width * ($zoom / 1.4);
else
echo "<input type='checkbox' name='avg_only' value=1>";
echo "<tr><td>"; echo "<script type='text/javascript'>window.resizeTo($width + 10, $height + 80);</script>";
echo __('Begin date'); }
echo "<td>";
echo "<input type='text' id='start_date' name='start_date' size=10 value='".substr($start_date,0,10)."'><img src='../images/calendar_view_day.png' onclick='scwShow(scwID(\"start_date\"),this);'> ";
echo "<tr><td>"; $utime = get_system_time ();
echo __('Zoom factor'); $current = date("Y-m-d", $utime);
echo "<td>"; $image = "fgraph.php?tipo=".$graph_type."&draw_alerts=".$draw_alerts."&draw_events=".$draw_events."&id=".$id."&zoom=".$zoom."&label=".$label."&height=".$height."&width=".$width."&period=".$period."&avg_only=".$avg_only;
echo "<select name=zoom>";
echo "<option value='$zoom'>"."x".$zoom;
echo "<option value='1'>"."x1";
echo "<option value='2'>"."x2";
echo "<option value='3'>"."x3";
echo "<option value='4'>"."x4";
echo "</select>";
echo "<tr><td>"; if ($start_date != $current){
echo __('Time range'); $image .= "&date=".$utime;
echo "<td>"; print_image ($image, false, array ("border" => 0));
echo "<select name='period'>"; } else {
echo "<option value=$period>".$period_label; print_image ($image, false, array ("border" => 0));
echo "<option value=3600>".__('1 hour');
echo "<option value=7200>".__('2 hours');
echo "<option value=21600>".__('6 hours');
echo "<option value=43200>".__('12 hours');
echo "<option value=86400>".__('1 day');
echo "<option value=172800>".__('2 days');
echo "<option value=432000>".__('5 days');
echo "<option value=604800>".__('1 week');
echo "<option value=1296000>".__('15 days');
echo "<option value=2592000>".__('1 month');
echo "<option value=5184000>".__('2 months');
echo "<option value=15552000>".__('6 months');
echo "</select>";
echo "<tr><td>"; echo '<table width="450" cellspacing="1" cellpadding="1" class="databox" style="margin-left: 20px">';
echo __('Show events'); echo '<tr><td><b>'.__('Max. Value').'</b>: '.format_for_graph (get_agentmodule_data_max ($id, $period));
echo "<td>"; echo '</td><td><b>'.__('Avg. Value').'</b>: '.format_for_graph (get_agentmodule_data_average ($id, $period));
if ($draw_events == 1) echo '</td><td><b>'.__('Min. Value').'</b>: '.format_for_graph (get_agentmodule_data_min ($id, $period));
echo "<input type='checkbox' name='draw_events' CHECKED value=1>"; echo '</td></tr></table>';
else }
echo "<input type='checkbox' name='draw_events' value=1>";
echo '<div id="divmenu" class="menu"><b>'.__('Pandora FMS Graph configuration menu').'</b><br />'.__('Please, make your changes and apply with the <i>Reload</i> button');
echo '<form method="get" action="stat_win.php">';
print_input_hidden ("id", $id);
print_input_hidden ("label", $label);
echo "<tr><td>"; if (isset($_GET["type"])) {
echo __('Show alert'); $type = get_parameter_get ("type");
echo "<td>"; print_input_hidden ("type", $type);
if ($draw_alerts == 1) }
echo "<input type='checkbox' name='draw_alerts' value=1 CHECKED>"; echo '<table class="databox_frame" cellspacing="5">';
else echo '<tr><td>'.__('Refresh time').'</td><td colspan="2">';
echo "<input type='checkbox' name='draw_alerts' value=1>";
print_input_text ("refresh", $refresh, '', 5);
echo "<td>"; echo '&nbsp;&nbsp;&nbsp;'.__('Avg. Only');
echo "<input type='submit' class='sub next' value='GO'>";
echo "<br>";
?>
</td></tr>
</table>
</form>
</div> print_checkbox ("avg_only", 1, (bool) $avg_only);
</body>
</html>
echo '<tr><td>'.__('Begin date').'</td><td>';
print_input_text ("start_date", substr ($start_date, 0, 10),'', 10);
print_image ("../images/calendar_view_day.png", false, array ("onclick" => "scwShow(scwID('text-start_date'),this);"));
echo '</td></tr><tr><td>'.__('Zoom factor').'</td>';
echo '<td>';
$options = array ();
$options[$zoom] = 'x'.$zoom;
$options[1] = 'x1';
$options[2] = 'x2';
$options[3] = 'x3';
$options[4] = 'x4';
print_select ($options, "zoom", $zoom);
echo '</td></tr><tr><td>'.__('Time range').'</td><td>';
$options = array ();
$options[3600] = human_time_description_raw (3600);
$options[7200] = human_time_description_raw (7200);
$options[21600] = human_time_description_raw (21600);
$options[43200] = human_time_description_raw (43200);
$options[86400] = human_time_description_raw (86400);
$options[172800] = human_time_description_raw (172800);
$options[432000] = human_time_description_raw (432000);
$options[604800] = human_time_description_raw (604800);
$options[1296000] = human_time_description_raw (1296000);
$options[2592000] = human_time_description_raw (2592000);
$options[5184000] = human_time_description_raw (5184000);
$options[15552000] = human_time_description_raw (15552000);
print_select ($options, "period", $period);
echo '</td></tr><tr><td>'.__('Show events').'</td><td>';
print_checkbox ("draw_events", 1, (bool) $draw_events);
echo '</td></tr><tr><td>'.__('Show alerts').'</td><td>';
print_checkbox ("draw_alerts", 1, (bool) $draw_alerts);
echo '</td><td>';
print_submit_button ('GO', "submit", false, 'class="sub next"');
echo '</td></tr></table></form></div></body></html>';