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
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
2. Redistributions in binary form must reproduce the above copyright
|
17
|
notice, this list of conditions and the following disclaimer in the
|
18
|
documentation and/or other materials provided with the distribution.
|
19
|
|
20
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
POSSIBILITY OF SUCH DAMAGE.
|
30
|
*/
|
31
|
/*
|
32
|
pfSense_MODULE: system
|
33
|
*/
|
34
|
|
35
|
##|+PRIV
|
36
|
##|*IDENT=page-status-rrdgraphs
|
37
|
##|*NAME=Status: RRD Graphs page
|
38
|
##|*DESCR=Allow access to the 'Status: RRD Graphs' page.
|
39
|
##|*MATCH=status_rrd_graph.php*
|
40
|
##|-PRIV
|
41
|
|
42
|
require("guiconfig.inc");
|
43
|
require_once("filter.inc");
|
44
|
require("shaper.inc");
|
45
|
require_once("rrd.inc");
|
46
|
|
47
|
unset($input_errors);
|
48
|
|
49
|
/* if the rrd graphs are not enabled redirect to settings page */
|
50
|
if(! isset($config['rrd']['enable'])) {
|
51
|
header("Location: status_rrd_graph_settings.php");
|
52
|
}
|
53
|
|
54
|
$home = getcwd();
|
55
|
$rrddbpath = "/var/db/rrd/";
|
56
|
chdir($rrddbpath);
|
57
|
$databases = glob("*.rrd");
|
58
|
chdir($home);
|
59
|
|
60
|
if ($_GET['cat']) {
|
61
|
$curcat = htmlspecialchars($_GET['cat']);
|
62
|
} else {
|
63
|
if(! empty($config['rrd']['category'])) {
|
64
|
$curcat = $config['rrd']['category'];
|
65
|
} else {
|
66
|
$curcat = "system";
|
67
|
}
|
68
|
}
|
69
|
|
70
|
if ($_POST['cat']) {
|
71
|
$curcat = htmlspecialchars($_POST['cat']);
|
72
|
}
|
73
|
|
74
|
if ($_GET['zone'])
|
75
|
$curzone = $_GET['zone'];
|
76
|
else
|
77
|
$curzone = '';
|
78
|
|
79
|
if ($_POST['period']) {
|
80
|
$curperiod = $_POST['period'];
|
81
|
} else {
|
82
|
if(! empty($config['rrd']['period'])) {
|
83
|
$curperiod = $config['rrd']['period'];
|
84
|
} else {
|
85
|
$curperiod = "absolute";
|
86
|
}
|
87
|
}
|
88
|
|
89
|
if ($_POST['style']) {
|
90
|
$curstyle = $_POST['style'];
|
91
|
} else {
|
92
|
if(! empty($config['rrd']['style'])) {
|
93
|
$curstyle = $config['rrd']['style'];
|
94
|
} else {
|
95
|
$curstyle = "absolute";
|
96
|
}
|
97
|
}
|
98
|
|
99
|
if ($_POST['option']) {
|
100
|
$curoption = $_POST['option'];
|
101
|
} else {
|
102
|
switch($curcat) {
|
103
|
case "system":
|
104
|
$curoption = "processor";
|
105
|
break;
|
106
|
case "queues":
|
107
|
$curoption = "queues";
|
108
|
break;
|
109
|
case "queuedrops":
|
110
|
$curoption = "queuedrops";
|
111
|
break;
|
112
|
case "quality":
|
113
|
foreach($databases as $database) {
|
114
|
if(preg_match("/[-]quality\.rrd/i", $database)) {
|
115
|
/* pick off the 1st database we find that matches the quality graph */
|
116
|
$name = explode("-", $database);
|
117
|
$curoption = "$name[0]";
|
118
|
continue 2;
|
119
|
}
|
120
|
}
|
121
|
case "wireless":
|
122
|
foreach($databases as $database) {
|
123
|
if(preg_match("/[-]wireless\.rrd/i", $database)) {
|
124
|
/* pick off the 1st database we find that matches the wireless graph */
|
125
|
$name = explode("-", $database);
|
126
|
$curoption = "$name[0]";
|
127
|
continue 2;
|
128
|
}
|
129
|
}
|
130
|
case "cellular":
|
131
|
foreach($databases as $database) {
|
132
|
if(preg_match("/[-]cellular\.rrd/i", $database)) {
|
133
|
/* pick off the 1st database we find that matches the celullar graph */
|
134
|
$name = explode("-", $database);
|
135
|
$curoption = "$name[0]";
|
136
|
continue 2;
|
137
|
}
|
138
|
}
|
139
|
case "vpnusers":
|
140
|
foreach($databases as $database) {
|
141
|
if(preg_match("/[-]vpnusers\.rrd/i", $database)) {
|
142
|
/* pick off the 1st database we find that matches the VPN graphs */
|
143
|
$name = explode("-", $database);
|
144
|
$curoption = "$name[0]";
|
145
|
continue 2;
|
146
|
}
|
147
|
}
|
148
|
case "captiveportal":
|
149
|
$curoption = "allgraphs";
|
150
|
break;
|
151
|
case "ntpd":
|
152
|
if(isset($config['ntpd']['statsgraph'])) {
|
153
|
$curoption = "allgraphs";
|
154
|
} else {
|
155
|
$curoption = "processor";
|
156
|
$curcat = "system";
|
157
|
}
|
158
|
break;
|
159
|
default:
|
160
|
$curoption = "wan";
|
161
|
break;
|
162
|
}
|
163
|
}
|
164
|
|
165
|
$now = time();
|
166
|
|
167
|
if($curcat == "custom") {
|
168
|
if (is_numeric($_POST['start'])) {
|
169
|
if($start < ($now - (3600 * 24 * 365 * 5))) {
|
170
|
$start = $now - (8 * 3600);
|
171
|
}
|
172
|
|
173
|
$start = $_POST['start'];
|
174
|
} else if ($_POST['start']) {
|
175
|
$start = strtotime($_POST['start']);
|
176
|
|
177
|
if ($start === FALSE || $start === -1) {
|
178
|
$input_errors[] = gettext("Invalid start date/time:") . " '{$_POST['start']}'";
|
179
|
|
180
|
$start = $now - (8 * 3600);
|
181
|
}
|
182
|
} else {
|
183
|
$start = $now - (8 * 3600);
|
184
|
}
|
185
|
}
|
186
|
|
187
|
if (is_numeric($_POST['end'])) {
|
188
|
$end = $_POST['end'];
|
189
|
} else if ($_POST['end']) {
|
190
|
$end = strtotime($_POST['end']);
|
191
|
|
192
|
if ($end === FALSE || $end === -1) {
|
193
|
$input_errors[] = gettext("Invalid end date/time:") . " '{$_POST['end']}'";
|
194
|
|
195
|
$end = $now;
|
196
|
}
|
197
|
} else {
|
198
|
$end = $now;
|
199
|
}
|
200
|
|
201
|
/* this should never happen */
|
202
|
if($end < $start) {
|
203
|
log_error("start $start is smaller than end $end");
|
204
|
$end = $now;
|
205
|
}
|
206
|
|
207
|
$seconds = $end - $start;
|
208
|
|
209
|
$styles = array('inverse' => gettext('Inverse'),
|
210
|
'absolute' => gettext('Absolute'));
|
211
|
|
212
|
/* sort names reverse so WAN comes first */
|
213
|
rsort($databases);
|
214
|
|
215
|
/* these boilerplate databases are required for the other menu choices */
|
216
|
$dbheader = array("allgraphs-traffic.rrd",
|
217
|
"allgraphs-quality.rrd",
|
218
|
"allgraphs-wireless.rrd",
|
219
|
"allgraphs-cellular.rrd",
|
220
|
"allgraphs-vpnusers.rrd",
|
221
|
"allgraphs-packets.rrd",
|
222
|
"system-allgraphs.rrd",
|
223
|
"system-throughput.rrd",
|
224
|
"outbound-quality.rrd",
|
225
|
"outbound-packets.rrd",
|
226
|
"outbound-traffic.rrd");
|
227
|
|
228
|
/* additional menu choices for the custom tab */
|
229
|
$dbheader_custom = array("system-throughput.rrd");
|
230
|
|
231
|
foreach($databases as $database) {
|
232
|
if(stristr($database, "-wireless")) {
|
233
|
$wireless = true;
|
234
|
}
|
235
|
|
236
|
if(stristr($database, "-queues")) {
|
237
|
$queues = true;
|
238
|
}
|
239
|
|
240
|
if(stristr($database, "-cellular") && !empty($config['ppps'])) {
|
241
|
$cellular = true;
|
242
|
}
|
243
|
|
244
|
if(stristr($database, "-vpnusers")) {
|
245
|
$vpnusers = true;
|
246
|
}
|
247
|
|
248
|
if(stristr($database, "captiveportal-") && is_array($config['captiveportal'])) {
|
249
|
$captiveportal = true;
|
250
|
}
|
251
|
|
252
|
if(stristr($database, "ntpd") && isset($config['ntpd']['statsgraph'])) {
|
253
|
$ntpd = true;
|
254
|
}
|
255
|
}
|
256
|
/* append the existing array to the header */
|
257
|
$ui_databases = array_merge($dbheader, $databases);
|
258
|
$custom_databases = array_merge($dbheader_custom, $databases);
|
259
|
|
260
|
$graphs = array("eighthour", "day", "week", "month", "quarter", "year", "fouryear");
|
261
|
$periods = array("absolute" => gettext("Absolute Timespans"), "current" => gettext("Current Period"), "previous" => gettext("Previous Period"));
|
262
|
$graph_length = array(
|
263
|
"eighthour" => 28800,
|
264
|
"day" => 86400,
|
265
|
"week" => 604800,
|
266
|
"month" => 2678400,
|
267
|
"quarter" => 7948800,
|
268
|
"year" => 31622400,
|
269
|
"fouryear" => 126230400);
|
270
|
|
271
|
$pgtitle = array(gettext("Status"),gettext("RRD Graphs"));
|
272
|
|
273
|
$closehead = false;
|
274
|
|
275
|
/* Load all CP zones */
|
276
|
if ($captiveportal && is_array($config['captiveportal'])) {
|
277
|
$cp_zones_tab_array = array();
|
278
|
|
279
|
foreach($config['captiveportal'] as $cpkey => $cp) {
|
280
|
if (!isset($cp['enable']))
|
281
|
continue;
|
282
|
|
283
|
if ($curzone == '') {
|
284
|
$tabactive = true;
|
285
|
$curzone = $cpkey;
|
286
|
} elseif ($curzone == $cpkey) {
|
287
|
$tabactive = true;
|
288
|
} else {
|
289
|
$tabactive = false;
|
290
|
}
|
291
|
|
292
|
$cp_zones_tab_array[] = array($cp['zone'], $tabactive, "status_rrd_graph.php?cat=captiveportal&zone=$cpkey");
|
293
|
}
|
294
|
}
|
295
|
|
296
|
function get_dates($curperiod, $graph) {
|
297
|
global $graph_length;
|
298
|
$now = time();
|
299
|
$end = $now;
|
300
|
|
301
|
if($curperiod == "absolute") {
|
302
|
$start = $end - $graph_length[$graph];
|
303
|
} else {
|
304
|
$curyear = date('Y', $now);
|
305
|
$curmonth = date('m', $now);
|
306
|
$curweek = date('W', $now);
|
307
|
$curweekday = date('N', $now) - 1; // We want to start on monday
|
308
|
$curday = date('d', $now);
|
309
|
$curhour = date('G', $now);
|
310
|
|
311
|
switch($curperiod) {
|
312
|
case "previous":
|
313
|
$offset = -1;
|
314
|
break;
|
315
|
default:
|
316
|
$offset = 0;
|
317
|
}
|
318
|
switch($graph) {
|
319
|
case "eighthour":
|
320
|
if($curhour < 24)
|
321
|
$starthour = 16;
|
322
|
if($curhour < 16)
|
323
|
$starthour = 8;
|
324
|
if($curhour < 8)
|
325
|
$starthour = 0;
|
326
|
|
327
|
switch($offset) {
|
328
|
case 0:
|
329
|
$houroffset = $starthour;
|
330
|
break;
|
331
|
default:
|
332
|
$houroffset = $starthour + ($offset * 8);
|
333
|
break;
|
334
|
}
|
335
|
$start = mktime($houroffset, 0, 0, $curmonth, $curday, $curyear);
|
336
|
if($offset != 0) {
|
337
|
$end = mktime(($houroffset + 8), 0, 0, $curmonth, $curday, $curyear);
|
338
|
}
|
339
|
break;
|
340
|
case "day":
|
341
|
$start = mktime(0, 0, 0, $curmonth, ($curday + $offset), $curyear);
|
342
|
if($offset != 0)
|
343
|
$end = mktime(0, 0, 0, $curmonth, (($curday + $offset) + 1), $curyear);
|
344
|
break;
|
345
|
case "week":
|
346
|
switch($offset) {
|
347
|
case 0:
|
348
|
$weekoffset = 0;
|
349
|
break;
|
350
|
default:
|
351
|
$weekoffset = ($offset * 7) - 7;
|
352
|
break;
|
353
|
}
|
354
|
$start = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset), $curyear);
|
355
|
if($offset != 0)
|
356
|
$end = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset + 7), $curyear);
|
357
|
break;
|
358
|
case "month":
|
359
|
$start = mktime(0, 0, 0, ($curmonth + $offset), 0, $curyear);
|
360
|
if($offset != 0)
|
361
|
$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
|
362
|
break;
|
363
|
case "quarter":
|
364
|
$start = mktime(0, 0, 0, (($curmonth - 2) + $offset), 0, $curyear);
|
365
|
if($offset != 0)
|
366
|
$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
|
367
|
break;
|
368
|
case "year":
|
369
|
$start = mktime(0, 0, 0, 1, 0, ($curyear + $offset));
|
370
|
if($offset != 0)
|
371
|
$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
|
372
|
break;
|
373
|
case "fouryear":
|
374
|
$start = mktime(0, 0, 0, 1, 0, (($curyear - 3) + $offset));
|
375
|
if($offset != 0)
|
376
|
$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
|
377
|
break;
|
378
|
}
|
379
|
}
|
380
|
// 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 />";
|
381
|
$dates = array();
|
382
|
$dates['start'] = $start;
|
383
|
$dates['end'] = $end;
|
384
|
return $dates;
|
385
|
}
|
386
|
|
387
|
function make_tabs() {
|
388
|
global $curcat;
|
389
|
|
390
|
$tab_array = array();
|
391
|
$tab_array[] = array(gettext("System"), ($curcat == "system"), "status_rrd_graph.php?cat=system");
|
392
|
$tab_array[] = array(gettext("Traffic"), ($curcat == "traffic"), "status_rrd_graph.php?cat=traffic");
|
393
|
$tab_array[] = array(gettext("Packets"), ($curcat == "packets"), "status_rrd_graph.php?cat=packets");
|
394
|
$tab_array[] = array(gettext("Quality"), ($curcat == "quality"), "status_rrd_graph.php?cat=quality");
|
395
|
|
396
|
if($queues) {
|
397
|
$tab_array[] = array(gettext("Queues"), ($curcat == "queues"), "status_rrd_graph.php?cat=queues");
|
398
|
$tab_array[] = array(gettext("QueueDrops"), ($curcat == "queuedrops"), "status_rrd_graph.php?cat=queuedrops");
|
399
|
}
|
400
|
|
401
|
if($wireless) {
|
402
|
$tab_array[] = array(gettext("Wireless"), ($curcat == "wireless"), "status_rrd_graph.php?cat=wireless");
|
403
|
}
|
404
|
|
405
|
if($cellular) {
|
406
|
$tab_array[] = array(gettext("Cellular"), ($curcat == "cellular"), "status_rrd_graph.php?cat=cellular");
|
407
|
}
|
408
|
|
409
|
if($vpnusers) {
|
410
|
$tab_array[] = array(gettext("VPN"), ($curcat == "vpnusers"), "status_rrd_graph.php?cat=vpnusers");
|
411
|
}
|
412
|
|
413
|
if($captiveportal) {
|
414
|
$tab_array[] = array(gettext("Captive Portal"), ($curcat == "captiveportal"), "status_rrd_graph.php?cat=captiveportal");
|
415
|
}
|
416
|
|
417
|
if(isset($config['ntpd']['statsgraph'])) {
|
418
|
$tab_array[] = array("NTP", ($curcat == "ntpd"), "status_rrd_graph.php?cat=ntpd");
|
419
|
}
|
420
|
|
421
|
$tab_array[] = array(gettext("Custom"), ($curcat == "custom"), "status_rrd_graph.php?cat=custom");
|
422
|
$tab_array[] = array(gettext("Settings"), ($curcat == "settings"), "status_rrd_graph_settings.php");
|
423
|
|
424
|
return($tab_array);
|
425
|
}
|
426
|
|
427
|
// Create the selectable list of graphs
|
428
|
function build_options() {
|
429
|
global $curcat, $custom_databases, $ui_databases;
|
430
|
|
431
|
$optionslist = array();
|
432
|
|
433
|
if($curcat == "custom") {
|
434
|
foreach ($custom_databases as $db => $database) {
|
435
|
$optionc = explode("-", $database);
|
436
|
$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc[0]));
|
437
|
if (empty($friendly)) {
|
438
|
$friendly = $optionc[0];
|
439
|
}
|
440
|
|
441
|
$search = array("-", ".rrd", $optionc[0]);
|
442
|
$replace = array(" :: ", "", $friendly);
|
443
|
$prettyprint = ucwords(str_replace($search, $replace, $database));
|
444
|
$optionslist[$database] = htmlspecialchars($prettyprint);
|
445
|
}
|
446
|
}
|
447
|
|
448
|
foreach ($ui_databases as $db => $database) {
|
449
|
if(! preg_match("/($curcat)/i", $database))
|
450
|
continue;
|
451
|
|
452
|
if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $database))
|
453
|
continue;
|
454
|
|
455
|
$optionc = explode("-", $database);
|
456
|
$search = array("-", ".rrd", $optionc);
|
457
|
$replace = array(" :: ", "", $friendly);
|
458
|
|
459
|
switch($curcat) {
|
460
|
case "captiveportal":
|
461
|
$optionc = str_replace($search, $replace, $optionc[2]);
|
462
|
$prettyprint = ucwords(str_replace($search, $replace, $optionc));
|
463
|
$optionslist[$optionc] = htmlspecialchars($prettyprint);
|
464
|
break;
|
465
|
case "system":
|
466
|
$optionc = str_replace($search, $replace, $optionc[1]);
|
467
|
$prettyprint = ucwords(str_replace($search, $replace, $optionc));
|
468
|
$optionslist[$optionc] = htmlspecialchars($prettyprint);
|
469
|
break;
|
470
|
default:
|
471
|
/* Deduce an interface if possible and use the description */
|
472
|
$optionc = "$optionc[0]";
|
473
|
$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc));
|
474
|
if(empty($friendly)) {
|
475
|
$friendly = $optionc;
|
476
|
}
|
477
|
$search = array("-", ".rrd", $optionc);
|
478
|
$replace = array(" :: ", "", $friendly);
|
479
|
$prettyprint = ucwords(str_replace($search, $replace, $friendly));
|
480
|
$optionslist[$optionc] = htmlspecialchars($prettyprint);
|
481
|
}
|
482
|
}
|
483
|
|
484
|
return($optionslist);
|
485
|
}
|
486
|
include("head.inc");
|
487
|
|
488
|
display_top_tabs(make_tabs());
|
489
|
|
490
|
if ($input_errors && count($input_errors))
|
491
|
print_input_errors($input_errors);
|
492
|
|
493
|
require('classes/Form.class.php');
|
494
|
|
495
|
$form = new Form(new Form_Button(
|
496
|
'submit',
|
497
|
'Go!'
|
498
|
));
|
499
|
|
500
|
$form->addClass('auto-submit');
|
501
|
|
502
|
$section = new Form_Section('Graph settings');
|
503
|
|
504
|
$group = new Form_Group('Options');
|
505
|
|
506
|
$group->add(new Form_Select(
|
507
|
'option',
|
508
|
'Graphs',
|
509
|
$curoption,
|
510
|
build_options()
|
511
|
))->setHelp('Graph');
|
512
|
|
513
|
$group->add(new Form_Select(
|
514
|
'style',
|
515
|
'Style',
|
516
|
$curstyle,
|
517
|
$styles
|
518
|
))->setHelp('Style');
|
519
|
|
520
|
$group->add(new Form_Select(
|
521
|
'period',
|
522
|
'Period',
|
523
|
$curperiod,
|
524
|
$periods
|
525
|
))->setHelp('Period');
|
526
|
|
527
|
if($curcat == 'custom')
|
528
|
$group->setHelp('Any changes to these option may not take affect until the next auto-refresh.');
|
529
|
|
530
|
$section->add($group);
|
531
|
|
532
|
if($curcat == 'custom') {
|
533
|
|
534
|
$section->addInput(new Form_Input(
|
535
|
'cat',
|
536
|
null,
|
537
|
'hidden',
|
538
|
'custom'
|
539
|
));
|
540
|
|
541
|
$tz = date_default_timezone_get();
|
542
|
$tz_msg = gettext("Enter date and/or time. Current timezone:") . " $tz";
|
543
|
$start_fmt = strftime("%m/%d/%Y %H:%M:%S", $start);
|
544
|
$end_fmt = strftime("%m/%d/%Y %H:%M:%S", $end);
|
545
|
|
546
|
$group = new Form_Group('');
|
547
|
|
548
|
$group->add(new Form_Input(
|
549
|
'start',
|
550
|
'Start',
|
551
|
'datetime',
|
552
|
$start_fmt
|
553
|
))->setHelp('Start');
|
554
|
|
555
|
$group->add(new Form_Input(
|
556
|
'end',
|
557
|
'End',
|
558
|
'datetime',
|
559
|
$end_fmt
|
560
|
))->setHelp('End');
|
561
|
|
562
|
if($curcat != 'custom')
|
563
|
$group->setHelp('Any changes to these option may not take affect until the next auto-refresh');
|
564
|
|
565
|
$section->add($group);
|
566
|
|
567
|
$form->add($section);
|
568
|
print($form);
|
569
|
|
570
|
$curdatabase = $curoption;
|
571
|
$graph = "custom-$curdatabase";
|
572
|
if(in_array($curdatabase, $custom_databases)) {
|
573
|
$id = "{$graph}-{$curoption}-{$curdatabase}";
|
574
|
$id = preg_replace('/\./', '_', $id);
|
575
|
?>
|
576
|
<div class="panel panel-default">
|
577
|
<img align="center" name="<?=$id?>" id="<?=$id?>" alt="<?=$prettydb?> Graph" src="status_rrd_graph_img.php?start=<?=$start?>&end={<?=$end?>&database=<?=$curdatabase?>&style=<?=$curstyle?>&graph=<?=$graph?>" />
|
578
|
</div>
|
579
|
<?php
|
580
|
|
581
|
}
|
582
|
} else {
|
583
|
$form->add($section);
|
584
|
print($form);
|
585
|
|
586
|
foreach($graphs as $graph) {
|
587
|
/* check which databases are valid for our category */
|
588
|
foreach($ui_databases as $curdatabase) {
|
589
|
if(! preg_match("/($curcat)/i", $curdatabase))
|
590
|
continue;
|
591
|
|
592
|
if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $curdatabase))
|
593
|
continue;
|
594
|
|
595
|
$optionc = explode("-", $curdatabase);
|
596
|
$search = array("-", ".rrd", $optionc);
|
597
|
$replace = array(" :: ", "", $friendly);
|
598
|
|
599
|
switch($curoption) {
|
600
|
case "outbound":
|
601
|
/* make sure we do not show the placeholder databases in the outbound view */
|
602
|
if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
|
603
|
continue 2;
|
604
|
}
|
605
|
/* only show interfaces with a gateway */
|
606
|
$optionc = "$optionc[0]";
|
607
|
if(!interface_has_gateway($optionc)) {
|
608
|
if(!isset($gateways_arr)) {
|
609
|
if(preg_match("/quality/i", $curdatabase))
|
610
|
$gateways_arr = return_gateways_array();
|
611
|
else
|
612
|
$gateways_arr = array();
|
613
|
}
|
614
|
$found_gateway = false;
|
615
|
foreach ($gateways_arr as $gw) {
|
616
|
if ($gw['name'] == $optionc) {
|
617
|
$found_gateway = true;
|
618
|
break;
|
619
|
}
|
620
|
}
|
621
|
if(!$found_gateway) {
|
622
|
continue 2;
|
623
|
}
|
624
|
}
|
625
|
|
626
|
if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
|
627
|
continue 2;
|
628
|
}
|
629
|
break;
|
630
|
case "allgraphs":
|
631
|
/* make sure we do not show the placeholder databases in the all view */
|
632
|
if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
|
633
|
continue 2;
|
634
|
}
|
635
|
break;
|
636
|
default:
|
637
|
/* just use the name here */
|
638
|
if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
|
639
|
continue 2;
|
640
|
}
|
641
|
}
|
642
|
|
643
|
if(in_array($curdatabase, $ui_databases)) {
|
644
|
$id = "{$graph}-{$curoption}-{$curdatabase}";
|
645
|
$id = preg_replace('/\./', '_', $id);
|
646
|
|
647
|
$dates = get_dates($curperiod, $graph);
|
648
|
$start = $dates['start'];
|
649
|
$end = $dates['end'];
|
650
|
?>
|
651
|
<div class="panel panel-default" align="center">
|
652
|
<img name="<?=$id?>" id="<?=$id?>" alt="<?=$prettydb?> Graph" src="status_rrd_graph_img.php?start=<?=$start?>&end={<?=$end?>&database=<?=$curdatabase?>&style=<?=$curstyle?>&graph=<?=$graph?>" />
|
653
|
</div>
|
654
|
<?php
|
655
|
}
|
656
|
}
|
657
|
}
|
658
|
}
|
659
|
|
660
|
?>
|
661
|
<script type="text/javascript">
|
662
|
//<![CDATA[
|
663
|
function update_graph_images() {
|
664
|
//alert('updating');
|
665
|
var randomid = Math.floor(Math.random()*11);
|
666
|
<?php
|
667
|
foreach($graphs as $graph) {
|
668
|
/* check which databases are valid for our category */
|
669
|
foreach($ui_databases as $curdatabase) {
|
670
|
if(! stristr($curdatabase, $curcat)) {
|
671
|
continue;
|
672
|
}
|
673
|
$optionc = explode("-", $curdatabase);
|
674
|
$search = array("-", ".rrd", $optionc);
|
675
|
$replace = array(" :: ", "", $friendly);
|
676
|
switch($curoption) {
|
677
|
case "outbound":
|
678
|
/* make sure we do not show the placeholder databases in the outbound view */
|
679
|
if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
|
680
|
continue 2;
|
681
|
}
|
682
|
/* only show interfaces with a gateway */
|
683
|
$optionc = "$optionc[0]";
|
684
|
if(!interface_has_gateway($optionc)) {
|
685
|
if(!isset($gateways_arr))
|
686
|
if(preg_match("/quality/i", $curdatabase))
|
687
|
$gateways_arr = return_gateways_array();
|
688
|
else
|
689
|
$gateways_arr = array();
|
690
|
$found_gateway = false;
|
691
|
foreach ($gateways_arr as $gw) {
|
692
|
if ($gw['name'] == $optionc) {
|
693
|
$found_gateway = true;
|
694
|
break;
|
695
|
}
|
696
|
}
|
697
|
if(!$found_gateway) {
|
698
|
continue 2;
|
699
|
}
|
700
|
}
|
701
|
if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
|
702
|
continue 2;
|
703
|
}
|
704
|
break;
|
705
|
case "allgraphs":
|
706
|
/* make sure we do not show the placeholder databases in the all view */
|
707
|
if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
|
708
|
continue 2;
|
709
|
}
|
710
|
break;
|
711
|
default:
|
712
|
/* just use the name here */
|
713
|
if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
|
714
|
continue 2;
|
715
|
}
|
716
|
}
|
717
|
$dates = get_dates($curperiod, $graph);
|
718
|
$start = $dates['start'];
|
719
|
if($curperiod == "current") {
|
720
|
$end = $dates['end'];
|
721
|
}
|
722
|
/* generate update events utilizing jQuery('') feature */
|
723
|
$id = "{$graph}-{$curoption}-{$curdatabase}";
|
724
|
$id = preg_replace('/\./', '_', $id);
|
725
|
|
726
|
echo "\n";
|
727
|
echo "\t\tjQuery('#{$id}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n";
|
728
|
}
|
729
|
}
|
730
|
?>
|
731
|
window.setTimeout('update_graph_images()', 355000);
|
732
|
}
|
733
|
window.setTimeout('update_graph_images()', 355000);
|
734
|
//]]>
|
735
|
</script>
|
736
|
|
737
|
<script>
|
738
|
events.push(function(){
|
739
|
$('.auto-submit').on('change', function(){
|
740
|
$(this).submit();
|
741
|
});
|
742
|
});
|
743
|
</script>
|
744
|
|
745
|
<?php include("foot.inc");
|