1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
status_rrd_graph.php
|
5
|
Part of pfSense
|
6
|
Copyright (C) 2007 Seth Mos <seth.mos@dds.nl>
|
7
|
All rights reserved.
|
8
|
|
9
|
Redistribution and use in source and binary forms, with or without
|
10
|
modification, are permitted provided that the following conditions are met:
|
11
|
|
12
|
1. Redistributions of source code must retain the above copyright notice,
|
13
|
this list of conditions and the following disclaimer.
|
14
|
|
15
|
2. Redistributions in binary form must reproduce the above copyright
|
16
|
notice, this list of conditions and the following disclaimer in the
|
17
|
documentation and/or other materials provided with the distribution.
|
18
|
|
19
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
POSSIBILITY OF SUCH DAMAGE.
|
29
|
*/
|
30
|
/*
|
31
|
pfSense_MODULE: system
|
32
|
*/
|
33
|
|
34
|
##|+PRIV
|
35
|
##|*IDENT=page-status-rrdgraphs
|
36
|
##|*NAME=Status: RRD Graphs page
|
37
|
##|*DESCR=Allow access to the 'Status: RRD Graphs' page.
|
38
|
##|*MATCH=status_rrd_graph.php*
|
39
|
##|-PRIV
|
40
|
|
41
|
require("guiconfig.inc");
|
42
|
require_once("filter.inc");
|
43
|
require("shaper.inc");
|
44
|
require_once("rrd.inc");
|
45
|
|
46
|
/* if the rrd graphs are not enabled redirect to settings page */
|
47
|
if(! isset($config['rrd']['enable'])) {
|
48
|
header("Location: status_rrd_graph_settings.php");
|
49
|
}
|
50
|
|
51
|
$rrddbpath = "/var/db/rrd/";
|
52
|
chdir($rrddbpath);
|
53
|
$databases = glob("*.rrd");
|
54
|
|
55
|
|
56
|
if ($_GET['cat']) {
|
57
|
$curcat = htmlspecialchars($_GET['cat']);
|
58
|
} else {
|
59
|
if(! empty($config['rrd']['category'])) {
|
60
|
$curcat = $config['rrd']['category'];
|
61
|
} else {
|
62
|
$curcat = "system";
|
63
|
}
|
64
|
}
|
65
|
|
66
|
if ($_GET['period']) {
|
67
|
$curperiod = $_GET['period'];
|
68
|
} else {
|
69
|
if(! empty($config['rrd']['period'])) {
|
70
|
$curperiod = $config['rrd']['period'];
|
71
|
} else {
|
72
|
$curperiod = "absolute";
|
73
|
}
|
74
|
}
|
75
|
|
76
|
if ($_GET['option']) {
|
77
|
$curoption = $_GET['option'];
|
78
|
} else {
|
79
|
switch($curcat) {
|
80
|
case "system":
|
81
|
$curoption = "processor";
|
82
|
break;
|
83
|
case "queues":
|
84
|
$curoption = "queues";
|
85
|
break;
|
86
|
case "queuedrops":
|
87
|
$curoption = "queuedrops";
|
88
|
break;
|
89
|
case "quality":
|
90
|
foreach($databases as $database) {
|
91
|
if(preg_match("/[-]quality\.rrd/i", $database)) {
|
92
|
/* pick off the 1st database we find that matches the quality graph */
|
93
|
$name = explode("-", $database);
|
94
|
$curoption = "$name[0]";
|
95
|
continue 2;
|
96
|
}
|
97
|
}
|
98
|
case "wireless":
|
99
|
foreach($databases as $database) {
|
100
|
if(preg_match("/[-]wireless\.rrd/i", $database)) {
|
101
|
/* pick off the 1st database we find that matches the wireless graph */
|
102
|
$name = explode("-", $database);
|
103
|
$curoption = "$name[0]";
|
104
|
continue 2;
|
105
|
}
|
106
|
}
|
107
|
case "cellular":
|
108
|
foreach($databases as $database) {
|
109
|
if(preg_match("/[-]cellular\.rrd/i", $database)) {
|
110
|
/* pick off the 1st database we find that matches the celullar graph */
|
111
|
$name = explode("-", $database);
|
112
|
$curoption = "$name[0]";
|
113
|
continue 2;
|
114
|
}
|
115
|
}
|
116
|
case "vpnusers":
|
117
|
foreach($databases as $database) {
|
118
|
if(preg_match("/[-]vpnusers\.rrd/i", $database)) {
|
119
|
/* pick off the 1st database we find that matches the VPN graphs */
|
120
|
$name = explode("-", $database);
|
121
|
$curoption = "$name[0]";
|
122
|
continue 2;
|
123
|
}
|
124
|
}
|
125
|
case "captiveportal":
|
126
|
$curoption = "allgraphs";
|
127
|
break;
|
128
|
default:
|
129
|
$curoption = "wan";
|
130
|
break;
|
131
|
}
|
132
|
}
|
133
|
|
134
|
$now = time();
|
135
|
if($curcat == "custom") {
|
136
|
if (is_numeric($_GET['start'])) {
|
137
|
if($start < ($now - (3600 * 24 * 365 * 5))) {
|
138
|
$start = $now - (8 * 3600);
|
139
|
}
|
140
|
$start = $_GET['start'];
|
141
|
} else {
|
142
|
$start = $now - (8 * 3600);
|
143
|
}
|
144
|
}
|
145
|
|
146
|
if (is_numeric($_GET['end'])) {
|
147
|
$end = $_GET['end'];
|
148
|
} else {
|
149
|
$end = $now;
|
150
|
}
|
151
|
|
152
|
/* this should never happen */
|
153
|
if($end < $start) {
|
154
|
log_error("start $start is smaller than end $end");
|
155
|
$end = $now;
|
156
|
}
|
157
|
|
158
|
$seconds = $end - $start;
|
159
|
|
160
|
if ($_GET['style']) {
|
161
|
$curstyle = $_GET['style'];
|
162
|
} else {
|
163
|
if(! empty($config['rrd']['style'])) {
|
164
|
$curstyle = $config['rrd']['style'];
|
165
|
} else {
|
166
|
$curstyle = "inverse";
|
167
|
}
|
168
|
}
|
169
|
|
170
|
/* sort names reverse so WAN comes first */
|
171
|
rsort($databases);
|
172
|
|
173
|
/* these boilerplate databases are required for the other menu choices */
|
174
|
$dbheader = array("allgraphs-traffic.rrd",
|
175
|
"allgraphs-quality.rrd",
|
176
|
"allgraphs-wireless.rrd",
|
177
|
"allgraphs-cellular.rrd",
|
178
|
"allgraphs-vpnusers.rrd",
|
179
|
"captiveportal-allgraphs.rrd",
|
180
|
"allgraphs-packets.rrd",
|
181
|
"system-allgraphs.rrd",
|
182
|
"system-throughput.rrd",
|
183
|
"outbound-quality.rrd",
|
184
|
"outbound-packets.rrd",
|
185
|
"outbound-traffic.rrd");
|
186
|
|
187
|
/* additional menu choices for the custom tab */
|
188
|
$dbheader_custom = array("system-throughput.rrd");
|
189
|
|
190
|
foreach($databases as $database) {
|
191
|
if(stristr($database, "-wireless")) {
|
192
|
$wireless = true;
|
193
|
}
|
194
|
if(stristr($database, "-queues")) {
|
195
|
$queues = true;
|
196
|
}
|
197
|
if(stristr($database, "-cellular") && !empty($config['ppps'])) {
|
198
|
$cellular = true;
|
199
|
}
|
200
|
if(stristr($database, "-vpnusers")) {
|
201
|
$vpnusers = true;
|
202
|
}
|
203
|
if(stristr($database, "captiveportal-") && isset($config['captiveportal']['enable'])) {
|
204
|
$captiveportal = true;
|
205
|
}
|
206
|
}
|
207
|
/* append the existing array to the header */
|
208
|
$ui_databases = array_merge($dbheader, $databases);
|
209
|
$custom_databases = array_merge($dbheader_custom, $databases);
|
210
|
|
211
|
$styles = array('inverse' => gettext('Inverse'),
|
212
|
'absolute' => gettext('Absolute'));
|
213
|
$graphs = array("8hour", "day", "week", "month", "quarter", "year", "4year");
|
214
|
$periods = array("absolute" => gettext("Absolute Timespans"), "current" => gettext("Current Period"), "previous" => gettext("Previous Period"));
|
215
|
$graph_length = array(
|
216
|
"8hour" => 28800,
|
217
|
"day" => 86400,
|
218
|
"week" => 604800,
|
219
|
"month" => 2764800,
|
220
|
"quarter" => 8035200,
|
221
|
"year" => 31622400,
|
222
|
"4year" => 126489600);
|
223
|
|
224
|
$pgtitle = array(gettext("Status"),gettext("RRD Graphs"));
|
225
|
include("head.inc");
|
226
|
|
227
|
function get_dates($curperiod, $graph) {
|
228
|
global $graph_length;
|
229
|
$now = time();
|
230
|
$end = $now;
|
231
|
|
232
|
if($curperiod == "absolute") {
|
233
|
$start = $end - $graph_length[$graph];
|
234
|
} else {
|
235
|
$curyear = date('Y', $now);
|
236
|
$curmonth = date('m', $now);
|
237
|
$curweek = date('W', $now);
|
238
|
$curweekday = date('N', $now) - 1; // We want to start on monday
|
239
|
$curday = date('d', $now);
|
240
|
$curhour = date('G', $now);
|
241
|
|
242
|
switch($curperiod) {
|
243
|
case "previous":
|
244
|
$offset = -1;
|
245
|
break;
|
246
|
default:
|
247
|
$offset = 0;
|
248
|
}
|
249
|
switch($graph) {
|
250
|
case "8hour":
|
251
|
if($curhour < 24)
|
252
|
$starthour = 16;
|
253
|
if($curhour < 16)
|
254
|
$starthour = 8;
|
255
|
if($curhour < 8)
|
256
|
$starthour = 0;
|
257
|
|
258
|
switch($offset) {
|
259
|
case 0:
|
260
|
$houroffset = $starthour;
|
261
|
break;
|
262
|
default:
|
263
|
$houroffset = $starthour + ($offset * 8);
|
264
|
break;
|
265
|
}
|
266
|
$start = mktime($houroffset, 0, 0, $curmonth, $curday, $curyear);
|
267
|
if($offset != 0) {
|
268
|
$end = mktime(($houroffset + 8), 0, 0, $curmonth, $curday, $curyear);
|
269
|
}
|
270
|
break;
|
271
|
case "day":
|
272
|
$start = mktime(0, 0, 0, $curmonth, ($curday + $offset), $curyear);
|
273
|
if($offset != 0)
|
274
|
$end = mktime(0, 0, 0, $curmonth, (($curday + $offset) + 1), $curyear);
|
275
|
break;
|
276
|
case "week":
|
277
|
switch($offset) {
|
278
|
case 0:
|
279
|
$weekoffset = 0;
|
280
|
break;
|
281
|
default:
|
282
|
$weekoffset = ($offset * 7) - 7;
|
283
|
break;
|
284
|
}
|
285
|
$start = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset), $curyear);
|
286
|
if($offset != 0)
|
287
|
$end = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset + 7), $curyear);
|
288
|
break;
|
289
|
case "month":
|
290
|
$start = mktime(0, 0, 0, ($curmonth + $offset), 0, $curyear);
|
291
|
if($offset != 0)
|
292
|
$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
|
293
|
break;
|
294
|
case "quarter":
|
295
|
$start = mktime(0, 0, 0, (($curmonth - 2) + $offset), 0, $curyear);
|
296
|
if($offset != 0)
|
297
|
$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
|
298
|
break;
|
299
|
case "year":
|
300
|
$start = mktime(0, 0, 0, 1, 0, ($curyear + $offset));
|
301
|
if($offset != 0)
|
302
|
$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
|
303
|
break;
|
304
|
case "4year":
|
305
|
$start = mktime(0, 0, 0, 1, 0, (($curyear - 3) + $offset));
|
306
|
if($offset != 0)
|
307
|
$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
|
308
|
break;
|
309
|
}
|
310
|
}
|
311
|
// 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>";
|
312
|
$dates = array();
|
313
|
$dates['start'] = $start;
|
314
|
$dates['end'] = $end;
|
315
|
return $dates;
|
316
|
}
|
317
|
|
318
|
?>
|
319
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
320
|
<?php include("fbegin.inc"); ?>
|
321
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
322
|
<tr>
|
323
|
<td>
|
324
|
<form name="form1" action="status_rrd_graph.php" method="get">
|
325
|
<input type="hidden" name="cat" value="<?php echo "$curcat"; ?>">
|
326
|
<?php
|
327
|
$tab_array = array();
|
328
|
if($curcat == "system") { $tabactive = True; } else { $tabactive = False; }
|
329
|
$tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system");
|
330
|
if($curcat == "traffic") { $tabactive = True; } else { $tabactive = False; }
|
331
|
$tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic");
|
332
|
if($curcat == "packets") { $tabactive = True; } else { $tabactive = False; }
|
333
|
$tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets");
|
334
|
if($curcat == "quality") { $tabactive = True; } else { $tabactive = False; }
|
335
|
$tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality");
|
336
|
if($queues) {
|
337
|
if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; }
|
338
|
$tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues");
|
339
|
if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; }
|
340
|
$tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops");
|
341
|
}
|
342
|
if($wireless) {
|
343
|
if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; }
|
344
|
$tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless");
|
345
|
}
|
346
|
if($cellular) {
|
347
|
if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; }
|
348
|
$tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular");
|
349
|
}
|
350
|
if($vpnusers) {
|
351
|
if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; }
|
352
|
$tab_array[] = array("VPN", $tabactive, "status_rrd_graph.php?cat=vpnusers");
|
353
|
}
|
354
|
if($captiveportal) {
|
355
|
if($curcat == "captiveportal") { $tabactive = True; } else { $tabactive = False; }
|
356
|
$tab_array[] = array("Captive Portal", $tabactive, "status_rrd_graph.php?cat=captiveportal");
|
357
|
}
|
358
|
if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; }
|
359
|
$tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom");
|
360
|
if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; }
|
361
|
$tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php");
|
362
|
display_top_tabs($tab_array);
|
363
|
?>
|
364
|
</td>
|
365
|
</tr>
|
366
|
<tr>
|
367
|
<td>
|
368
|
<div id="mainarea">
|
369
|
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
|
370
|
<tr>
|
371
|
<td colspan="2" class="list"><p><b><?=gettext("Note: Change of color and/or style may not take effect until the next refresh");?></b></p></td>
|
372
|
</tr>
|
373
|
<tr>
|
374
|
<td colspan="2" class="list">
|
375
|
<?=gettext("Graphs:");?>
|
376
|
<select name="option" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
|
377
|
<?php
|
378
|
|
379
|
if($curcat == "custom") {
|
380
|
foreach ($custom_databases as $db => $database) {
|
381
|
$optionc = split("-", $database);
|
382
|
$search = array("-", ".rrd", $optionc);
|
383
|
$replace = array(" :: ", "", $friendly);
|
384
|
echo "<option value=\"{$database}\"";
|
385
|
$prettyprint = ucwords(str_replace($search, $replace, $database));
|
386
|
if($curoption == $database) {
|
387
|
echo " selected";
|
388
|
}
|
389
|
echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
|
390
|
}
|
391
|
}
|
392
|
foreach ($ui_databases as $db => $database) {
|
393
|
if(! preg_match("/($curcat)/i", $database)) {
|
394
|
continue;
|
395
|
}
|
396
|
$optionc = split("-", $database);
|
397
|
$search = array("-", ".rrd", $optionc);
|
398
|
$replace = array(" :: ", "", $friendly);
|
399
|
|
400
|
switch($curcat) {
|
401
|
case "captiveportal":
|
402
|
$optionc = str_replace($search, $replace, $optionc[1]);
|
403
|
echo "<option value=\"$optionc\"";
|
404
|
$prettyprint = ucwords(str_replace($search, $replace, $optionc));
|
405
|
break;
|
406
|
case "system":
|
407
|
$optionc = str_replace($search, $replace, $optionc[1]);
|
408
|
echo "<option value=\"$optionc\"";
|
409
|
$prettyprint = ucwords(str_replace($search, $replace, $optionc));
|
410
|
break;
|
411
|
default:
|
412
|
/* Deduce a interface if possible and use the description */
|
413
|
$optionc = "$optionc[0]";
|
414
|
$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc));
|
415
|
if(empty($friendly)) {
|
416
|
$friendly = $optionc;
|
417
|
}
|
418
|
$search = array("-", ".rrd", $optionc);
|
419
|
$replace = array(" :: ", "", $friendly);
|
420
|
echo "<option value=\"$optionc\"";
|
421
|
$prettyprint = ucwords(str_replace($search, $replace, $friendly));
|
422
|
}
|
423
|
if($curoption == $optionc) {
|
424
|
echo " selected";
|
425
|
}
|
426
|
echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
|
427
|
}
|
428
|
|
429
|
?>
|
430
|
</select>
|
431
|
|
432
|
<?=gettext("Style:");?>
|
433
|
<select name="style" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
|
434
|
<?php
|
435
|
foreach ($styles as $style => $styled) {
|
436
|
echo "<option value=\"$style\"";
|
437
|
if ($style == $curstyle) echo " selected";
|
438
|
echo ">" . htmlspecialchars($styled) . "</option>\n";
|
439
|
}
|
440
|
?>
|
441
|
</select>
|
442
|
|
443
|
<?php
|
444
|
if($curcat <> "custom") {
|
445
|
?>
|
446
|
<?=gettext("Period:");?>
|
447
|
<select name="period" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
|
448
|
<?php
|
449
|
foreach ($periods as $period => $value) {
|
450
|
echo "<option value=\"$period\"";
|
451
|
if ($period == $curperiod) echo " selected";
|
452
|
echo ">" . htmlspecialchars($value) . "</option>\n";
|
453
|
}
|
454
|
}
|
455
|
?>
|
456
|
</select>
|
457
|
<?php
|
458
|
|
459
|
if($curcat == "custom") {
|
460
|
?>
|
461
|
<?=gettext("Start:");?>
|
462
|
<input type="text" name="start" class="formfldunknown" length="32" value="<?php echo $start;?>">
|
463
|
<?=gettext("End:");?>
|
464
|
<input type="text" name="end" class="formfldunknown" length="32" value="<?php echo $now;?>">
|
465
|
<input type="submit" name="Submit" value="<?=gettext("Go"); ?>">
|
466
|
<?php
|
467
|
$curdatabase = $curoption;
|
468
|
$graph = "custom-$curdatabase";
|
469
|
if(in_array($curdatabase, $custom_databases)) {
|
470
|
echo "<tr><td colspan=2 class=\"list\">\n";
|
471
|
echo "<IMG BORDER='0' name='{$graph}-{$curoption}-{$curdatabase}' ";
|
472
|
echo "id='{$graph}-{$curoption}-{$curdatabase}' ALT=\"$prettydb Graph\" ";
|
473
|
echo "SRC=\"status_rrd_graph_img.php?start={$start}&end={$end}&database={$curdatabase}&style={$curstyle}&graph={$graph}\" />\n";
|
474
|
echo "<br /><hr><br />\n";
|
475
|
echo "</td></tr>\n";
|
476
|
}
|
477
|
} else {
|
478
|
foreach($graphs as $graph) {
|
479
|
/* check which databases are valid for our category */
|
480
|
foreach($ui_databases as $curdatabase) {
|
481
|
if(! preg_match("/($curcat)/i", $curdatabase)) {
|
482
|
continue;
|
483
|
}
|
484
|
$optionc = split("-", $curdatabase);
|
485
|
$search = array("-", ".rrd", $optionc);
|
486
|
$replace = array(" :: ", "", $friendly);
|
487
|
switch($curoption) {
|
488
|
case "outbound":
|
489
|
/* make sure we do not show the placeholder databases in the outbound view */
|
490
|
if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
|
491
|
continue 2;
|
492
|
}
|
493
|
/* only show interfaces with a gateway */
|
494
|
$optionc = "$optionc[0]";
|
495
|
if(!interface_has_gateway($optionc)) {
|
496
|
if(!isset($gateways_arr)) {
|
497
|
if(preg_match("/quality/i", $curdatabase))
|
498
|
$gateways_arr = return_gateways_array();
|
499
|
else
|
500
|
$gateways_arr = array();
|
501
|
}
|
502
|
$found_gateway = false;
|
503
|
foreach ($gateways_arr as $gw) {
|
504
|
if ($gw['name'] == $optionc) {
|
505
|
$found_gateway = true;
|
506
|
break;
|
507
|
}
|
508
|
}
|
509
|
if(!$found_gateway) {
|
510
|
continue 2;
|
511
|
}
|
512
|
}
|
513
|
if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
|
514
|
continue 2;
|
515
|
}
|
516
|
break;
|
517
|
case "allgraphs":
|
518
|
/* make sure we do not show the placeholder databases in the all view */
|
519
|
if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
|
520
|
continue 2;
|
521
|
}
|
522
|
break;
|
523
|
default:
|
524
|
/* just use the name here */
|
525
|
if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
|
526
|
continue 2;
|
527
|
}
|
528
|
}
|
529
|
if(in_array($curdatabase, $ui_databases)) {
|
530
|
$dates = get_dates($curperiod, $graph);
|
531
|
$start = $dates['start'];
|
532
|
$end = $dates['end'];
|
533
|
echo "<tr><td colspan=2 class=\"list\">\n";
|
534
|
echo "<IMG BORDER='0' name='{$graph}-{$curoption}-{$curdatabase}' ";
|
535
|
echo "id='{$graph}-{$curoption}-{$curdatabase}' ALT=\"$prettydb Graph\" ";
|
536
|
echo "SRC=\"status_rrd_graph_img.php?start={$start}&end={$end}&database={$curdatabase}&style={$curstyle}&graph={$graph}\" />\n";
|
537
|
echo "<br /><hr><br />\n";
|
538
|
echo "</td></tr>\n";
|
539
|
}
|
540
|
}
|
541
|
}
|
542
|
}
|
543
|
?>
|
544
|
</td>
|
545
|
</tr>
|
546
|
<tr>
|
547
|
<td colspan=2 class="list">
|
548
|
<script language="javascript">
|
549
|
function update_graph_images() {
|
550
|
//alert('updating');
|
551
|
var randomid = Math.floor(Math.random()*11);
|
552
|
<?php
|
553
|
foreach($graphs as $graph) {
|
554
|
/* check which databases are valid for our category */
|
555
|
foreach($ui_databases as $curdatabase) {
|
556
|
if(! stristr($curdatabase, $curcat)) {
|
557
|
continue;
|
558
|
}
|
559
|
$optionc = split("-", $curdatabase);
|
560
|
$search = array("-", ".rrd", $optionc);
|
561
|
$replace = array(" :: ", "", $friendly);
|
562
|
switch($curoption) {
|
563
|
case "outbound":
|
564
|
/* make sure we do not show the placeholder databases in the outbound view */
|
565
|
if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
|
566
|
continue 2;
|
567
|
}
|
568
|
/* only show interfaces with a gateway */
|
569
|
$optionc = "$optionc[0]";
|
570
|
if(!interface_has_gateway($optionc)) {
|
571
|
if(!isset($gateways_arr))
|
572
|
if(preg_match("/quality/i", $curdatabase))
|
573
|
$gateways_arr = return_gateways_array();
|
574
|
else
|
575
|
$gateways_arr = array();
|
576
|
$found_gateway = false;
|
577
|
foreach ($gateways_arr as $gw) {
|
578
|
if ($gw['name'] == $optionc) {
|
579
|
$found_gateway = true;
|
580
|
break;
|
581
|
}
|
582
|
}
|
583
|
if(!$found_gateway) {
|
584
|
continue 2;
|
585
|
}
|
586
|
}
|
587
|
if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
|
588
|
continue 2;
|
589
|
}
|
590
|
break;
|
591
|
case "allgraphs":
|
592
|
/* make sure we do not show the placeholder databases in the all view */
|
593
|
if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
|
594
|
continue 2;
|
595
|
}
|
596
|
break;
|
597
|
default:
|
598
|
/* just use the name here */
|
599
|
if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
|
600
|
continue 2;
|
601
|
}
|
602
|
}
|
603
|
$dates = get_dates($curperiod, $graph);
|
604
|
$start = $dates['start'];
|
605
|
if($curperiod == "current") {
|
606
|
$end = $dates['end'];
|
607
|
}
|
608
|
/* generate update events utilizing prototype $('') feature */
|
609
|
echo "\n";
|
610
|
echo "\t\t\$('{$graph}-{$curoption}-{$curdatabase}').src='status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid;\n";
|
611
|
}
|
612
|
}
|
613
|
?>
|
614
|
window.setTimeout('update_graph_images()', 355000);
|
615
|
}
|
616
|
window.setTimeout('update_graph_images()', 355000);
|
617
|
</script>
|
618
|
</form>
|
619
|
</td>
|
620
|
</tr>
|
621
|
</table>
|
622
|
</div>
|
623
|
</td>
|
624
|
</tr>
|
625
|
</table>
|
626
|
|
627
|
<?php include("fend.inc"); ?>
|
628
|
</body>
|
629
|
</html>
|