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