summaryrefslogtreecommitdiffstats
path: root/usr/local
diff options
context:
space:
mode:
authorRenato Botelho <renato.botelho@bluepex.com>2010-07-16 14:32:34 -0300
committerRenato Botelho <renato.botelho@bluepex.com>2010-07-16 14:32:34 -0300
commitb2bffb702414260f1e154f73d4c2b7c70816cc94 (patch)
tree0d0054da0db95d2655b389f2c7b8904991ca643c /usr/local
parent6e7d936b7a4523ef5c56b569e0cba8845869f326 (diff)
parent7bc41b1954312c14efe62a3bfc9b6c755d365456 (diff)
downloadpfsense-b2bffb702414260f1e154f73d4c2b7c70816cc94.zip
pfsense-b2bffb702414260f1e154f73d4c2b7c70816cc94.tar.gz
Merge remote branch 'mainline/master'
Diffstat (limited to 'usr/local')
-rwxr-xr-xusr/local/captiveportal/index.php5
-rwxr-xr-xusr/local/www/status_rrd_graph.php89
-rw-r--r--usr/local/www/status_rrd_graph_img.php246
-rwxr-xr-xusr/local/www/vpn_pptp.php5
4 files changed, 245 insertions, 100 deletions
diff --git a/usr/local/captiveportal/index.php b/usr/local/captiveportal/index.php
index 32c8853..7d432e2 100755
--- a/usr/local/captiveportal/index.php
+++ b/usr/local/captiveportal/index.php
@@ -477,6 +477,11 @@ function portal_allow($clientip,$clientmac,$username,$password = null, $attribut
$logouturl = "http://{$ourhostname}/";
}
+ if (isset($attributes['reply_message']))
+ $message = $attributes['reply_message'];
+ else
+ $message = 0;
+
include("{$g['varetc_path']}/captiveportal-logout.html");
} else {
diff --git a/usr/local/www/status_rrd_graph.php b/usr/local/www/status_rrd_graph.php
index f7b5b25..115d12c 100755
--- a/usr/local/www/status_rrd_graph.php
+++ b/usr/local/www/status_rrd_graph.php
@@ -63,6 +63,12 @@ if ($_GET['cat']) {
}
}
+if ($_GET['period']) {
+ $curperiod = $_GET['period'];
+} else {
+ $curperiod = "current";
+}
+
if ($_GET['option']) {
$curoption = $_GET['option'];
} else {
@@ -150,11 +156,62 @@ $ui_databases = array_merge($dbheader, $databases);
$styles = array('inverse' => 'Inverse',
'absolute' => 'Absolute');
-$periods = array("4h", "16h", "48h", "32d", "6m", "1y", "4y");
+$graphs = array("day", "week", "month", "quarter", "year", "4year");
+$periods = array("current" => "Current Period", "previous" => "Previous Period");
$pgtitle = array("Status","RRD Graphs");
include("head.inc");
+function get_dates($curperiod, $graph) {
+ $now = time();
+ $end = $now;
+ $curyear = date('Y', $now);
+ $curmonth = date('m', $now);
+ $curweek = date('W', $now);
+ $curweekday = date('w', $now);
+ $curday = date('d', $now);
+
+ switch($curperiod) {
+ case "previous":
+ $offset = -1;
+ break;
+ default:
+ $offset = 0;
+ }
+ switch($graph) {
+ case "day":
+ $start = mktime(0, 0, 0, $curmonth, ($curday + $offset), $curyear);
+ $end = mktime(0, 0, 0, $curmonth, (($curday + $offset) + 1), $curyear);
+ break;
+ case "week":
+ $start = mktime(0, 0, 0, $curmonth, (($curday + $curweekday) - $offset), $curyear);
+ $end = mktime(0, 0, 0, $curmonth, (($curday + $curweekday) + 7), $curyear);
+ break;
+ case "month":
+ $start = mktime(0, 0, 0, ($curmonth + $offset), 0, $curyear);
+ $end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
+ break;
+ case "quarter":
+ $start = mktime(0, 0, 0, (($curmonth - 2) + $offset), 0, $curyear);
+ $end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
+ break;
+ case "year":
+ $start = mktime(0, 0, 0, 1, 0, ($curyear + $offset));
+ $end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
+ break;
+ case "4year":
+ $start = mktime(0, 0, 0, 1, 0, (($curyear - 3) + $offset));
+ $end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
+ break;
+ }
+ // echo "start $start ". date('l jS \of F Y h:i:s A', $start) .", end $end ". date('l jS \of F Y h:i:s A', $end) ."<br>";
+ $dates = array();
+ $dates['start'] = $start;
+ $dates['end'] = $end;
+ return $dates;
+}
+
+
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
@@ -249,12 +306,24 @@ include("head.inc");
echo ">" . htmlspecialchars($styled) . "</option>\n";
}
?>
+ </select>
+
+ <?=gettext("Period:");?>
+ <select name="period" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
+ <?php
+ foreach ($periods as $period => $value) {
+ echo "<option value=\"$period\"";
+ if ($period == $curperiod) echo " selected";
+ echo ">" . htmlspecialchars($value) . "</option>\n";
+ }
+ ?>
</select>
<?php
- foreach($periods as $period => $interval) {
+ // echo "year $curyear, month $curmonth, week $curweek, day $curday, weekday $curweekday<br>";
+ foreach($graphs as $graph) {
/* check which databases are valid for our category */
foreach($ui_databases as $curdatabase) {
if(! preg_match("/($curcat)/i", $curdatabase)) {
@@ -289,10 +358,13 @@ include("head.inc");
}
}
if(in_array($curdatabase, $databases)) {
+ $dates = get_dates($curperiod, $graph);
+ $start = $dates['start'];
+ $end = $dates['end'];
echo "<tr><td colspan=2 class=\"list\">\n";
- echo "<IMG BORDER='0' name='{$interval}-{$curoption}-{$curdatabase}' ";
- echo "id='{$interval}-{$curoption}-{$curdatabase}' ALT=\"$prettydb Graph\" ";
- echo "SRC=\"status_rrd_graph_img.php?interval=$interval&amp;database={$curdatabase}&amp;style={$curstyle}\" />\n";
+ echo "<IMG BORDER='0' name='{$graph}-{$curoption}-{$curdatabase}' ";
+ echo "id='{$graph}-{$curoption}-{$curdatabase}' ALT=\"$prettydb Graph\" ";
+ echo "SRC=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
echo "<br /><hr><br />\n";
echo "</td></tr>\n";
}
@@ -308,7 +380,7 @@ include("head.inc");
//alert('updating');
var randomid = Math.floor(Math.random()*11);
<?php
- foreach($periods as $period => $interval) {
+ foreach($graphs as $graph) {
/* check which databases are valid for our category */
foreach($databases as $curdatabase) {
if(! stristr($curdatabase, $curcat)) {
@@ -338,9 +410,12 @@ include("head.inc");
continue 2;
}
}
+ $dates = get_dates($curperiod, $graph);
+ $start = $dates['start'];
+ $end = $dates['end'];
/* generate update events utilizing prototype $('') feature */
echo "\n";
- echo "\t\t\$('{$interval}-{$curoption}-{$curdatabase}').src='status_rrd_graph_img.php?interval={$interval}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid;\n";
+ echo "\t\t\$('{$graph}-{$curoption}-{$curdatabase}').src='status_rrd_graph_img.php?start={$start}&end={$end}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid;\n";
}
}
?>
diff --git a/usr/local/www/status_rrd_graph_img.php b/usr/local/www/status_rrd_graph_img.php
index 63657d0..567d272 100644
--- a/usr/local/www/status_rrd_graph_img.php
+++ b/usr/local/www/status_rrd_graph_img.php
@@ -51,12 +51,79 @@ if ($_GET['style']) {
$curstyle = "inverse";
}
-if ($_GET['interval']) {
- $interval = $_GET['interval'];
+/* this is used for temp name */
+if ($_GET['graph']) {
+ $curgraph = $_GET['graph'];
} else {
- $interval = "4h";
+ $curgraph = "custom";
}
+$now = time();
+
+if (is_numeric($_GET['start'])) {
+ if($start < ($now - (3600 * 24 * 365 * 5))) {
+ $start = $now - (4 * 3600);
+ }
+ $start = $_GET['start'];
+} else {
+ $start = $now - (4 * 3600);
+}
+
+if (is_numeric($_GET['end'])) {
+ $end = $_GET['end'];
+} else {
+ $end = $now;
+}
+
+/* this should never happen */
+if($end < $start) {
+ $end = $now;
+}
+
+$seconds = $end - $start;
+
+$scales = array();
+$scales[14400] = "MINUTE:5:MINUTE:10:MINUTE:30:0:%H%:%M";
+$scales[57600] = "MINUTE:30:HOUR:1:HOUR:1:0:%H";
+$scales[172800] = "HOUR:1:HOUR:6:HOUR:2:0:%H";
+$scales[691200] = "HOUR:2:HOUR:12:DAY:1:0:%D %d";
+$scales[2764800] = "DAY:1:WEEK:1:WEEK:1:0:Week %W";
+$scales[16070400] = "WEEK:1:MONTH:1:MONTH:1:0:%b";
+$scales[42854400] = "MONTH:1:MONTH:1:MONTH:1:0:%b";
+
+$archives = array();
+$archives[1] = 1000;
+$archives[5] = 1000;
+$archives[60] = 1000;
+$archives[720] = 3000;
+
+$defOptions = array(
+ 'to' => 1,
+ 'parts' => 1,
+ 'precision' => 'minute',
+ 'distance' => FALSE,
+ 'separator' => ', '
+);
+
+/* always set the average to the highest value as a fallback */
+$average = 720 * 60;
+foreach($archives as $rra => $value) {
+ $archivestart = $end - ($rra * 60 * $value);
+ if($archivestart <= $start) {
+ $average = $rra * 60;
+ break;
+ }
+}
+
+foreach($scales as $scalelength => $value) {
+ if($scalelength >= $seconds) {
+ $scale = $value;
+ break;
+ }
+}
+
+// log_error("start $start, end $end, archivestart $archivestart, average $average, scale $scale, seconds $seconds");
+
/* Deduce a interface if possible and use the description */
$curif = split("-", $curdatabase);
$curif = "$curif[0]";
@@ -68,41 +135,6 @@ $search = array("-", ".rrd", $curif);
$replace = array(" :: ", "", $friendly);
$prettydb = ucwords(str_replace($search, $replace, $curdatabase));
-$periods = array("4h", "16h", "48h", "32d", "6m", "1y", "4y");
-
-$found = 0;
-foreach($periods as $period) if($period == $interval) $found = 1;
-if($found == 0) {
- PRINT "Graph interval $interval is not valid <br />\n";
- exit();
-}
-
-$graphs['4h']['seconds'] = 14400;
-$graphs['4h']['average'] = 60;
-$graphs['4h']['scale'] = "MINUTE:5:MINUTE:10:MINUTE:30:0:%H%:%M";
-$graphs['16h']['seconds'] = 57600;
-$graphs['16h']['average'] = 60;
-$graphs['16h']['scale'] = "MINUTE:30:HOUR:1:HOUR:1:0:%H";
-$graphs['48h']['seconds'] = 172800;
-$graphs['48h']['average'] = 300;
-$graphs['48h']['scale'] = "HOUR:1:HOUR:6:HOUR:2:0:%H";
-$graphs['32d']['seconds'] = 2764800;
-$graphs['32d']['average'] = 3600;
-$graphs['32d']['scale'] = "DAY:1:WEEK:1:WEEK:1:0:Week %W";
-$graphs['6m']['seconds'] = 16070400;
-$graphs['6m']['average'] = 43200;
-$graphs['6m']['scale'] = "WEEK:1:MONTH:1:MONTH:1:0:%b";
-$graphs['1y']['seconds'] = 31622400;
-$graphs['1y']['average'] = 43200;
-$graphs['1y']['scale'] = "MONTH:1:MONTH:3:MONTH:1:0:%b";
-$graphs['4y']['seconds'] = 126489600;
-$graphs['4y']['average'] = 86400;
-$graphs['4y']['scale'] = "MONTH:1:YEAR:1:MONTH:3:0:%b";
-
-/* generate the graphs when we request the page. */
-$seconds = $graphs[$interval]['seconds'];
-$average = $graphs[$interval]['average'];
-$scale = $graphs[$interval]['scale'];
$rrddbpath = "/var/db/rrd/";
$rrdtmppath = "/tmp/";
@@ -110,8 +142,8 @@ $rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
$uptime = "/usr/bin/uptime";
$sed = "/usr/bin/sed";
-$havg = humantime($average);
-$hperiod = humantime($seconds);
+$havg = timeDiff($average, $defOptions);
+$hperiod = timeDiff($seconds, $defOptions);
$data = true;
/* XXX: (billm) do we have an exec() type function that does this type of thing? */
@@ -186,28 +218,60 @@ default:
break;
}
-function humantime($timestamp){
- $difference = $timestamp;
- $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
- $lengths = array("60","60","24","7","4.35","12","10");
- for($j = 0; $difference >= $lengths[$j]; $j++) {
- $difference /= $lengths[$j];
- $difference = round($difference);
- }
- if($difference != 1) {
- $periods[$j].= "s";
- }
- $text = "$difference $periods[$j]";
- return $text;
+function timeDiff($time, $opt = array()) {
+ // The default values
+ $defOptions = array(
+ 'to' => 0,
+ 'parts' => 1,
+ 'precision' => 'second',
+ 'distance' => TRUE,
+ 'separator' => ', '
+ );
+ $opt = array_merge($defOptions, $opt);
+ // Default to current time if no to point is given
+ (!$opt['to']) && ($opt['to'] = time());
+ // Init an empty string
+ $str = '';
+ // To or From computation
+ $diff = ($opt['to'] > $time) ? $opt['to'] - $time : $time - $opt['to'];
+ // An array of label => periods of seconds;
+ $periods = array(
+ 'decade' => 315569260,
+ 'year' => 31539600,
+ 'month' => 2629744,
+ 'week' => 604800,
+ 'day' => 86400,
+ 'hour' => 3600,
+ 'minute' => 60,
+ 'second' => 1
+ );
+ // 31539600, 31556926, 31622400
+ // Round to precision
+ if ($opt['precision'] != 'second')
+ $diff = round(($diff / $periods[$opt['precision']])) * $periods[$opt['precision']];
+ // Report the value is 'less than 1 ' precision period away
+ (0 == $diff) && ($str = 'less than 1 ' . $opt['precision']);
+ // Loop over each period
+ foreach ($periods as $label => $value) {
+ // Stitch together the time difference string
+ (($x = round($diff / $value)) && $opt['parts']--) && $str .= ($str ? $opt['separator'] : '') . ($x .' '. $label. ($x > 1 ? 's' : ''));
+ // Stop processing if no more parts are going to be reported.
+ if ($opt['parts'] == 0 || $label == $opt['precision']) break;
+ // Get ready for the next pass
+ $diff -= $x * $value;
+ }
+ $opt['distance'] && $str .= ($str && $opt['to'] >= $time) ? ' ago' : ' away';
+ return $str;
}
+
if((strstr($curdatabase, "-traffic.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
/* define graphcmd for traffic stats */
- $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png ";
- $graphcmd .= "--start -$seconds -e -$average --vertical-label \"bits/sec\" ";
+ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
+ $graphcmd .= "--start $start --end $end --vertical-label \"bits/sec\" ";
$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
$graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" ";
- $graphcmd .= "--height 200 --width 620 -x \"{$scale}\" ";
+ $graphcmd .= "--height 200 --width 620 ";
$graphcmd .= "DEF:$curif-in_bytes_pass=$rrddbpath$curdatabase:inpass:AVERAGE ";
$graphcmd .= "DEF:$curif-out_bytes_pass=$rrddbpath$curdatabase:outpass:AVERAGE ";
$graphcmd .= "DEF:$curif-in_bytes_block=$rrddbpath$curdatabase:inblock:AVERAGE ";
@@ -279,12 +343,12 @@ if((strstr($curdatabase, "-traffic.rrd")) && (file_exists("$rrddbpath$curdatabas
elseif(strstr($curdatabase, "-throughput.rrd")) {
/* define graphcmd for throughput stats */
/* this gathers all interface statistics, the database does not actually exist */
- $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png ";
- $graphcmd .= "--start -$seconds -e -$average ";
+ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
+ $graphcmd .= "--start $start --end $end ";
$graphcmd .= "--vertical-label \"bits/sec\" ";
$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
$graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" ";
- $graphcmd .= "--height 200 --width 620 -x \"{$scale}\" ";
+ $graphcmd .= "--height 200 --width 620 ";
$iflist = get_configured_interface_list();
$g = 0;
@@ -406,12 +470,12 @@ elseif(strstr($curdatabase, "-throughput.rrd")) {
}
elseif((strstr($curdatabase, "-packets.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
/* define graphcmd for packets stats */
- $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png ";
- $graphcmd .= "--start -$seconds -e -$average ";
+ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
+ $graphcmd .= "--start $start --end $end ";
$graphcmd .= "--vertical-label \"packets/sec\" ";
$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
$graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" ";
- $graphcmd .= "--height 200 --width 620 -x \"$scale\" ";
+ $graphcmd .= "--height 200 --width 620 ";
$graphcmd .= "DEF:\"$curif-in_pps_pass=$rrddbpath$curdatabase:inpass:AVERAGE\" ";
$graphcmd .= "DEF:\"$curif-out_pps_pass=$rrddbpath$curdatabase:outpass:AVERAGE\" ";
$graphcmd .= "DEF:\"$curif-in_pps_block=$rrddbpath$curdatabase:inblock:AVERAGE\" ";
@@ -475,12 +539,12 @@ elseif((strstr($curdatabase, "-packets.rrd")) && (file_exists("$rrddbpath$curdat
}
elseif((strstr($curdatabase, "-wireless.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
/* define graphcmd for packets stats */
- $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png ";
- $graphcmd .= "--start -$seconds -e -$average ";
+ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
+ $graphcmd .= "--start $start --end $end ";
$graphcmd .= "--vertical-label \"snr/channel/rate\" ";
$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
$graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" ";
- $graphcmd .= "--height 200 --width 620 -x \"$scale\" ";
+ $graphcmd .= "--height 200 --width 620 ";
$graphcmd .= "DEF:\"$curif-snr=$rrddbpath$curdatabase:snr:AVERAGE\" ";
$graphcmd .= "DEF:\"$curif-rate=$rrddbpath$curdatabase:rate:AVERAGE\" ";
$graphcmd .= "DEF:\"$curif-channel=$rrddbpath$curdatabase:channel:AVERAGE\" ";
@@ -508,12 +572,12 @@ elseif((strstr($curdatabase, "-wireless.rrd")) && (file_exists("$rrddbpath$curda
}
elseif((strstr($curdatabase, "-states.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
/* define graphcmd for states stats */
- $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png ";
+ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
$graphcmd .= "--start -$seconds -e -$average ";
$graphcmd .= "--vertical-label \"states, ip\" ";
$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
$graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" ";
- $graphcmd .= "--height 200 --width 620 -x \"$scale\" ";
+ $graphcmd .= "--height 200 --width 620 ";
$graphcmd .= "DEF:\"$curif-pfrate=$rrddbpath$curdatabase:pfrate:AVERAGE\" ";
$graphcmd .= "DEF:\"$curif-pfstates=$rrddbpath$curdatabase:pfstates:AVERAGE\" ";
$graphcmd .= "DEF:\"$curif-pfnat=$rrddbpath$curdatabase:pfnat:AVERAGE\" ";
@@ -562,12 +626,12 @@ elseif((strstr($curdatabase, "-states.rrd")) && (file_exists("$rrddbpath$curdata
}
elseif((strstr($curdatabase, "-processor.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
/* define graphcmd for processor stats */
- $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png ";
- $graphcmd .= "--start -$seconds -e -$average ";
+ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
+ $graphcmd .= "--start $start --end $end ";
$graphcmd .= "--vertical-label \"utilization, number\" ";
$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
$graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" ";
- $graphcmd .= "--height 200 --width 620 -x \"$scale\" ";
+ $graphcmd .= "--height 200 --width 620 ";
$graphcmd .= "DEF:\"user=$rrddbpath$curdatabase:user:AVERAGE\" ";
$graphcmd .= "DEF:\"nice=$rrddbpath$curdatabase:nice:AVERAGE\" ";
$graphcmd .= "DEF:\"system=$rrddbpath$curdatabase:system:AVERAGE\" ";
@@ -614,12 +678,12 @@ elseif((strstr($curdatabase, "-processor.rrd")) && (file_exists("$rrddbpath$curd
}
elseif((strstr($curdatabase, "-memory.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
/* define graphcmd for memory usage stats */
- $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png ";
- $graphcmd .= "--start -$seconds -e -$average ";
+ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
+ $graphcmd .= "--start $start --end $end ";
$graphcmd .= "--vertical-label \"utilization, percent\" ";
$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
$graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" ";
- $graphcmd .= "--height 200 --width 620 -x \"$scale\" ";
+ $graphcmd .= "--height 200 --width 620 ";
$graphcmd .= "DEF:\"active=$rrddbpath$curdatabase:active:AVERAGE\" ";
$graphcmd .= "DEF:\"inactive=$rrddbpath$curdatabase:inactive:AVERAGE\" ";
$graphcmd .= "DEF:\"free=$rrddbpath$curdatabase:free:AVERAGE\" ";
@@ -666,12 +730,12 @@ elseif((strstr($curdatabase, "-memory.rrd")) && (file_exists("$rrddbpath$curdata
}
elseif((strstr($curdatabase, "-queues.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
/* define graphcmd for queue stats */
- $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png ";
- $graphcmd .= "--start -$seconds -e -$average ";
+ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
+ $graphcmd .= "--start $start --end $end ";
$graphcmd .= "--vertical-label \"bits/sec\" ";
$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
$graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" ";
- $graphcmd .= "--height 200 --width 620 -x \"$scale\" ";
+ $graphcmd .= "--height 200 --width 620 ";
if ($altq) {
$a_queues =& $altq->get_queue_list();
$t = 0;
@@ -695,12 +759,12 @@ elseif((strstr($curdatabase, "-queues.rrd")) && (file_exists("$rrddbpath$curdata
}
elseif((strstr($curdatabase, "-queuedrops.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
/* define graphcmd for queuedrop stats */
- $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png ";
- $graphcmd .= "--start -$seconds -e -$average ";
+ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
+ $graphcmd .= "--start $start --end $end ";
$graphcmd .= "--vertical-label \"drops / sec\" ";
$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
$graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" ";
- $graphcmd .= "--height 200 --width 620 -x \"$scale\" ";
+ $graphcmd .= "--height 200 --width 620 ";
if ($altq) {
$a_queues =& $altq->get_queue_list();
$t = 0;
@@ -725,13 +789,13 @@ elseif((strstr($curdatabase, "-queuedrops.rrd")) && (file_exists("$rrddbpath$cur
}
elseif((strstr($curdatabase, "-quality.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
/* make a link quality graphcmd, we only have WAN for now, others too follow */
- $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png \\
- --start -$seconds -e -$average \\
+ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png \\
+ --start $start --end $end \\
--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" \\
--color SHADEA#eeeeee --color SHADEB#eeeeee \\
--vertical-label \"ms / %\" \\
--height 200 --width 620 \\
- -x \"$scale\" --lower-limit 0 \\
+ --lower-limit 0 \\
DEF:delayraw=$rrddbpath$curdatabase:delay:AVERAGE \\
DEF:loss=$rrddbpath$curdatabase:loss:AVERAGE \\
\"CDEF:delay=delayraw,1000,*\" \\
@@ -761,13 +825,13 @@ elseif((strstr($curdatabase, "-quality.rrd")) && (file_exists("$rrddbpath$curdat
}
elseif((strstr($curdatabase, "spamd.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
/* graph a spamd statistics graph */
- $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png ";
- $graphcmd .= "--start -$seconds -e -$average ";
+ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
+ $graphcmd .= "--start $start --end $end ";
$graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" ";
$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
$graphcmd .= "--vertical-label=\"Conn / Time, sec.\" ";
$graphcmd .= "--height 200 --width 620 --no-gridfit ";
- $graphcmd .= "-x \"$scale\" --lower-limit 0 ";
+ $graphcmd .= "--lower-limit 0 ";
$graphcmd .= "DEF:\"consmin=$rrddbpath$curdatabase:conn:MIN\" ";
$graphcmd .= "DEF:\"consavg=$rrddbpath$curdatabase:conn:AVERAGE\" ";
$graphcmd .= "DEF:\"consmax=$rrddbpath$curdatabase:conn:MAX\" ";
@@ -799,12 +863,12 @@ elseif((strstr($curdatabase, "spamd.rrd")) && (file_exists("$rrddbpath$curdataba
$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t`date +\"%b %d %H\:%M\:%S %Y\"`\" ";
}
elseif((strstr($curdatabase, "-cellular.rrd")) && (file_exists("$rrddbpath$curdatabase"))) {
- $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$interval.png ";
- $graphcmd .= "--start -$seconds -e -$average ";
+ $graphcmd = "$rrdtool graph $rrdtmppath$curdatabase-$curgraph.png ";
+ $graphcmd .= "--start $start --end $end ";
$graphcmd .= "--vertical-label \"signal\" ";
$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
$graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" ";
- $graphcmd .= "--height 200 --width 620 -x \"$scale\" ";
+ $graphcmd .= "--height 200 --width 620 ";
$graphcmd .= "DEF:\"$curif-signal1=$rrddbpath$curdatabase:signal1:AVERAGE\" ";
$graphcmd .= "DEF:\"$curif-signal2=$rrddbpath$curdatabase:signal2:AVERAGE\" ";
$graphcmd .= "LINE2:\"$curif-signal1#{$colorwireless[0]}:$curif-signal1\" ";
@@ -829,8 +893,8 @@ else {
}
/* check modification time to see if we need to generate image */
-if (file_exists("$rrdtmppath$curdatabase-$interval.png")) {
- if((time() - filemtime("$rrdtmppath$curdatabase-$interval.png")) >= 55 ) {
+if (file_exists("$rrdtmppath$curdatabase-$curgraph.png")) {
+ if((time() - filemtime("$rrdtmppath$curdatabase-$curgraph.png")) >= 5 ) {
if($data)
exec("$graphcmd 2>&1", $graphcmdoutput, $graphcmdreturn);
$graphcmdoutput = implode(" ", $graphcmdoutput) . $graphcmd;
@@ -869,7 +933,7 @@ if(($graphcmdreturn <> 0) || (! $data)) {
$file= "/usr/local/www/themes/{$g['theme']}/images/misc/rrd_error.png";
readfile($file);
} else {
- $file = "$rrdtmppath$curdatabase-$interval.png";
+ $file = "$rrdtmppath$curdatabase-$curgraph.png";
if(file_exists("$file")) {
header("Content-type: image/png");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
diff --git a/usr/local/www/vpn_pptp.php b/usr/local/www/vpn_pptp.php
index 1c88670..9a7b108 100755
--- a/usr/local/www/vpn_pptp.php
+++ b/usr/local/www/vpn_pptp.php
@@ -328,8 +328,9 @@ function enable_change(enable_over) {
<td width="78%" class="vtable">
<select id="n_pptp_units" name="n_pptp_units">
<?php
- for($x=0; $x<255; $x++) {
- if($x == $pconfig['n_pptp_units'])
+ $toselect = ($pconfig['n_pptp_units'] > 0) ? $pconfig['n_pptp_units'] : 16;
+ for($x=1; $x<255; $x++) {
+ if($x == $toselect)
$SELECTED = " SELECTED";
else
$SELECTED = "";
OpenPOWER on IntegriCloud