Revision 3c44b044
Added by sbeaver over 10 years ago
usr/local/www/status_rrd_graph.php | ||
---|---|---|
18 | 18 |
documentation and/or other materials provided with the distribution. |
19 | 19 |
|
20 | 20 |
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
21 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
|
21 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHƒANTABILITY
|
|
22 | 22 |
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
23 | 23 |
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, |
24 | 24 |
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
... | ... | |
28 | 28 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | 29 |
POSSIBILITY OF SUCH DAMAGE. |
30 | 30 |
*/ |
31 |
/* |
|
32 |
pfSense_MODULE: system
|
|
31 |
/* c
|
|
32 |
pfSense_MODULE: system
|
|
33 | 33 |
*/ |
34 | 34 |
|
35 | 35 |
##|+PRIV |
... | ... | |
51 | 51 |
header("Location: status_rrd_graph_settings.php"); |
52 | 52 |
} |
53 | 53 |
|
54 |
$home = getcwd(); |
|
54 | 55 |
$rrddbpath = "/var/db/rrd/"; |
55 | 56 |
chdir($rrddbpath); |
56 | 57 |
$databases = glob("*.rrd"); |
57 |
|
|
58 |
chdir($home); |
|
58 | 59 |
|
59 | 60 |
if ($_GET['cat']) { |
60 | 61 |
$curcat = htmlspecialchars($_GET['cat']); |
... | ... | |
71 | 72 |
else |
72 | 73 |
$curzone = ''; |
73 | 74 |
|
74 |
if ($_GET['period']) {
|
|
75 |
$curperiod = $_GET['period'];
|
|
75 |
if ($_POST['period']) {
|
|
76 |
$curperiod = $_POST['period'];
|
|
76 | 77 |
} else { |
77 | 78 |
if(! empty($config['rrd']['period'])) { |
78 | 79 |
$curperiod = $config['rrd']['period']; |
... | ... | |
81 | 82 |
} |
82 | 83 |
} |
83 | 84 |
|
84 |
if ($_GET['option']) { |
|
85 |
$curoption = $_GET['option']; |
|
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']; |
|
86 | 98 |
} else { |
87 | 99 |
switch($curcat) { |
88 | 100 |
case "system": |
... | ... | |
166 | 178 |
} |
167 | 179 |
|
168 | 180 |
if (is_numeric($_GET['end'])) { |
169 |
$end = $_GET['end'];
|
|
181 |
$end = $_GET['end'];
|
|
170 | 182 |
} else if ($_GET['end']) { |
171 | 183 |
$end = strtotime($_GET['end']); |
172 | 184 |
if ($end === FALSE || $end === -1) { |
... | ... | |
174 | 186 |
$end = $now; |
175 | 187 |
} |
176 | 188 |
} else { |
177 |
$end = $now;
|
|
189 |
$end = $now;
|
|
178 | 190 |
} |
179 | 191 |
|
180 | 192 |
/* this should never happen */ |
181 | 193 |
if($end < $start) { |
182 | 194 |
log_error("start $start is smaller than end $end"); |
183 |
$end = $now;
|
|
195 |
$end = $now;
|
|
184 | 196 |
} |
185 | 197 |
|
186 | 198 |
$seconds = $end - $start; |
... | ... | |
188 | 200 |
$styles = array('inverse' => gettext('Inverse'), |
189 | 201 |
'absolute' => gettext('Absolute')); |
190 | 202 |
|
191 |
// Set default and override later |
|
192 |
$curstyle = "inverse"; |
|
193 |
|
|
194 |
if ($_GET['style']) { |
|
195 |
foreach($styles as $style) |
|
196 |
if(strtoupper($style) == strtoupper($_GET['style'])) |
|
197 |
$curstyle = $_GET['style']; |
|
198 |
} else { |
|
199 |
if(! empty($config['rrd']['style'])) { |
|
200 |
$curstyle = $config['rrd']['style']; |
|
201 |
} else { |
|
202 |
$curstyle = "inverse"; |
|
203 |
} |
|
204 |
} |
|
205 |
|
|
206 | 203 |
/* sort names reverse so WAN comes first */ |
207 | 204 |
rsort($databases); |
208 | 205 |
|
... | ... | |
282 | 279 |
} |
283 | 280 |
|
284 | 281 |
include("head.inc"); |
285 |
?> |
|
286 | 282 |
|
287 |
<?php if ($curcat === "custom") { ?>
|
|
283 |
if ($curcat === "custom") { ?>
|
|
288 | 284 |
<link rel="stylesheet" type="text/css" href="/javascript/jquery-ui-timepicker-addon/css/jquery-ui-timepicker-addon.css" /> |
289 | 285 |
<?php if (file_exists("{$g['www_path']}/themes/{$g['theme']}/jquery-ui-1.11.1.css")) { ?> |
290 | 286 |
<link rel="stylesheet" type="text/css" href="/themes/<?= $g['theme'] ?>/jquery-ui-1.11.1.css" /> |
... | ... | |
400 | 396 |
return $dates; |
401 | 397 |
} |
402 | 398 |
|
403 |
?> |
|
404 |
</head> |
|
405 |
<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> |
|
406 |
<?php include("fbegin.inc"); ?> |
|
407 |
<?php if ($input_errors && count($input_errors)) { print_input_errors($input_errors); } ?> |
|
408 |
<form name="form1" action="status_rrd_graph.php" method="get"> |
|
409 |
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="rrd graphs"> |
|
410 |
<tr> |
|
411 |
<td> |
|
412 |
<input type="hidden" name="cat" value="<?php echo "$curcat"; ?>" /> |
|
413 |
<?php |
|
414 |
$tab_array = array(); |
|
415 |
if($curcat == "system") { $tabactive = True; } else { $tabactive = False; } |
|
416 |
$tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system"); |
|
417 |
if($curcat == "traffic") { $tabactive = True; } else { $tabactive = False; } |
|
418 |
$tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic"); |
|
419 |
if($curcat == "packets") { $tabactive = True; } else { $tabactive = False; } |
|
420 |
$tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets"); |
|
421 |
if($curcat == "quality") { $tabactive = True; } else { $tabactive = False; } |
|
422 |
$tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality"); |
|
423 |
if($queues) { |
|
424 |
if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; } |
|
425 |
$tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues"); |
|
426 |
if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; } |
|
427 |
$tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops"); |
|
428 |
} |
|
429 |
if($wireless) { |
|
430 |
if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; } |
|
431 |
$tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless"); |
|
432 |
} |
|
433 |
if($cellular) { |
|
434 |
if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; } |
|
435 |
$tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular"); |
|
436 |
} |
|
437 |
if($vpnusers) { |
|
438 |
if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; } |
|
439 |
$tab_array[] = array("VPN", $tabactive, "status_rrd_graph.php?cat=vpnusers"); |
|
440 |
} |
|
441 |
if($captiveportal) { |
|
442 |
if($curcat == "captiveportal") { $tabactive = True; } else { $tabactive = False; } |
|
443 |
$tab_array[] = array("Captive Portal", $tabactive, "status_rrd_graph.php?cat=captiveportal"); |
|
444 |
} |
|
445 |
if($ntpd) { |
|
446 |
if($curcat == "ntpd") { $tabactive = True; } else { $tabactive = False; } |
|
447 |
$tab_array[] = array("NTP", $tabactive, "status_rrd_graph.php?cat=ntpd"); |
|
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; |
|
448 | 501 |
} |
449 |
if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; } |
|
450 |
$tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom"); |
|
451 |
if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; } |
|
452 |
$tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php"); |
|
453 |
display_top_tabs($tab_array); |
|
454 |
?> |
|
455 |
</td> |
|
456 |
</tr> |
|
457 |
<?php if ($curcat == "captiveportal") : ?> |
|
458 |
<tr> |
|
459 |
<td class="tabnavtbl"> |
|
460 |
<?php display_top_tabs($cp_zones_tab_array); ?> |
|
461 |
</td> |
|
462 |
</tr> |
|
463 |
<?php endif; ?> |
|
464 |
<tr> |
|
465 |
<td> |
|
466 |
<div id="mainarea"> |
|
467 |
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0" summary="main area"> |
|
468 |
<tr> |
|
469 |
<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> |
|
470 |
</tr> |
|
471 |
<tr> |
|
472 |
<td colspan="2" class="list"> |
|
473 |
<?=gettext("Graphs:");?> |
|
474 |
<?php if (!empty($curzone)): ?> |
|
475 |
<input type="hidden" name="zone" value="<?= htmlspecialchars($curzone) ?>" /> |
|
476 |
<?php endif; ?> |
|
477 |
<select name="option" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> |
|
478 |
<?php |
|
479 |
|
|
480 |
if($curcat == "custom") { |
|
481 |
foreach ($custom_databases as $db => $database) { |
|
482 |
$optionc = explode("-", $database); |
|
483 |
$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc[0])); |
|
484 |
if (empty($friendly)) { |
|
485 |
$friendly = $optionc[0]; |
|
486 |
} |
|
487 |
$search = array("-", ".rrd", $optionc[0]); |
|
488 |
$replace = array(" :: ", "", $friendly); |
|
489 |
echo "<option value=\"{$database}\""; |
|
490 |
$prettyprint = ucwords(str_replace($search, $replace, $database)); |
|
491 |
if($curoption == $database) { |
|
492 |
echo " selected=\"selected\""; |
|
493 |
} |
|
494 |
echo ">" . htmlspecialchars($prettyprint) . "</option>\n"; |
|
495 |
} |
|
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; |
|
496 | 628 |
} |
497 |
foreach ($ui_databases as $db => $database) { |
|
498 |
if(! preg_match("/($curcat)/i", $database)) |
|
499 |
continue; |
|
500 |
|
|
501 |
if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $database)) |
|
502 |
continue; |
|
503 |
|
|
504 |
$optionc = explode("-", $database); |
|
505 |
$search = array("-", ".rrd", $optionc); |
|
506 |
$replace = array(" :: ", "", $friendly); |
|
507 |
|
|
508 |
switch($curcat) { |
|
509 |
case "captiveportal": |
|
510 |
$optionc = str_replace($search, $replace, $optionc[2]); |
|
511 |
echo "<option value=\"$optionc\""; |
|
512 |
$prettyprint = ucwords(str_replace($search, $replace, $optionc)); |
|
513 |
break; |
|
514 |
case "system": |
|
515 |
$optionc = str_replace($search, $replace, $optionc[1]); |
|
516 |
echo "<option value=\"$optionc\""; |
|
517 |
$prettyprint = ucwords(str_replace($search, $replace, $optionc)); |
|
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; |
|
518 | 642 |
break; |
519 |
default: |
|
520 |
/* Deduce a interface if possible and use the description */ |
|
521 |
$optionc = "$optionc[0]"; |
|
522 |
$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc)); |
|
523 |
if(empty($friendly)) { |
|
524 |
$friendly = $optionc; |
|
525 |
} |
|
526 |
$search = array("-", ".rrd", $optionc); |
|
527 |
$replace = array(" :: ", "", $friendly); |
|
528 |
echo "<option value=\"$optionc\""; |
|
529 |
$prettyprint = ucwords(str_replace($search, $replace, $friendly)); |
|
643 |
} |
|
530 | 644 |
} |
531 |
if($curoption == $optionc) {
|
|
532 |
echo " selected=\"selected\"";
|
|
645 |
if(!$found_gateway) {
|
|
646 |
continue 2;
|
|
533 | 647 |
} |
534 |
echo ">" . htmlspecialchars($prettyprint) . "</option>\n"; |
|
535 | 648 |
} |
536 |
|
|
537 |
?> |
|
538 |
</select> |
|
539 |
|
|
540 |
<?=gettext("Style:");?> |
|
541 |
<select name="style" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> |
|
542 |
<?php |
|
543 |
foreach ($styles as $style => $styled) { |
|
544 |
echo "<option value=\"$style\""; |
|
545 |
if ($style == $curstyle) echo " selected=\"selected\""; |
|
546 |
echo ">" . htmlspecialchars($styled) . "</option>\n"; |
|
649 |
if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) { |
|
650 |
continue 2; |
|
547 | 651 |
} |
548 |
?> |
|
549 |
</select> |
|
550 |
|
|
551 |
<?php |
|
552 |
if($curcat <> "custom") { |
|
553 |
?> |
|
554 |
<?=gettext("Period:");?> |
|
555 |
<select name="period" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> |
|
556 |
<?php |
|
557 |
foreach ($periods as $period => $value) { |
|
558 |
echo "<option value=\"$period\""; |
|
559 |
if ($period == $curperiod) echo " selected=\"selected\""; |
|
560 |
echo ">" . htmlspecialchars($value) . "</option>\n"; |
|
561 |
} |
|
562 |
echo "</select>\n"; |
|
563 |
echo "</td></tr>\n"; |
|
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; |
|
564 | 657 |
} |
565 |
?> |
|
566 |
<?php |
|
567 |
|
|
568 |
if($curcat == "custom") { |
|
569 |
$tz = date_default_timezone_get(); |
|
570 |
$tz_msg = gettext("Enter date and/or time. Current timezone:") . " $tz"; |
|
571 |
$start_fmt = strftime("%m/%d/%Y %H:%M:%S", $start); |
|
572 |
$end_fmt = strftime("%m/%d/%Y %H:%M:%S", $end); |
|
573 |
?> |
|
574 |
<?=gettext("Start:");?> |
|
575 |
<input id="startDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="start" class="formfld unknown" size="24" value="<?= htmlentities($start_fmt); ?>" /> |
|
576 |
<?=gettext("End:");?> |
|
577 |
<input id="endDateTime" title="<?= htmlentities($tz_msg); ?>." type="text" name="end" class="formfld unknown" size="24" value="<?= htmlentities($end_fmt); ?>" /> |
|
578 |
<input type="submit" name="Submit" value="<?=gettext("Go"); ?>" /> |
|
579 |
</td></tr> |
|
580 |
<?php |
|
581 |
$curdatabase = $curoption; |
|
582 |
$graph = "custom-$curdatabase"; |
|
583 |
if(in_array($curdatabase, $custom_databases)) { |
|
584 |
$id = "{$graph}-{$curoption}-{$curdatabase}"; |
|
585 |
$id = preg_replace('/\./', '_', $id); |
|
586 |
|
|
587 |
echo "<tr><td colspan=\"2\" class=\"list\">\n"; |
|
588 |
echo "<img border=\"0\" name=\"{$id}\" "; |
|
589 |
echo "id=\"{$id}\" alt=\"$prettydb Graph\" "; |
|
590 |
echo "src=\"status_rrd_graph_img.php?start={$start}&end={$end}&database={$curdatabase}&style={$curstyle}&graph={$graph}\" />\n"; |
|
591 |
echo "<br /><hr /><br />\n"; |
|
592 |
echo "</td></tr>\n"; |
|
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; |
|
593 | 702 |
} |
594 |
} else { |
|
595 |
foreach($graphs as $graph) { |
|
596 |
/* check which databases are valid for our category */ |
|
597 |
foreach($ui_databases as $curdatabase) { |
|
598 |
if(! preg_match("/($curcat)/i", $curdatabase)) |
|
599 |
continue; |
|
600 |
|
|
601 |
if (($curcat == "captiveportal") && !empty($curzone) && !preg_match("/captiveportal-{$curzone}/i", $curdatabase)) |
|
602 |
continue; |
|
603 |
|
|
604 |
$optionc = explode("-", $curdatabase); |
|
605 |
$search = array("-", ".rrd", $optionc); |
|
606 |
$replace = array(" :: ", "", $friendly); |
|
607 |
switch($curoption) { |
|
608 |
case "outbound": |
|
609 |
/* make sure we do not show the placeholder databases in the outbound view */ |
|
610 |
if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) { |
|
611 |
continue 2; |
|
612 |
} |
|
613 |
/* only show interfaces with a gateway */ |
|
614 |
$optionc = "$optionc[0]"; |
|
615 |
if(!interface_has_gateway($optionc)) { |
|
616 |
if(!isset($gateways_arr)) { |
|
617 |
if(preg_match("/quality/i", $curdatabase)) |
|
618 |
$gateways_arr = return_gateways_array(); |
|
619 |
else |
|
620 |
$gateways_arr = array(); |
|
621 |
} |
|
622 |
$found_gateway = false; |
|
623 |
foreach ($gateways_arr as $gw) { |
|
624 |
if ($gw['name'] == $optionc) { |
|
625 |
$found_gateway = true; |
|
626 |
break; |
|
627 |
} |
|
628 |
} |
|
629 |
if(!$found_gateway) { |
|
630 |
continue 2; |
|
631 |
} |
|
632 |
} |
|
633 |
if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) { |
|
634 |
continue 2; |
|
635 |
} |
|
636 |
break; |
|
637 |
case "allgraphs": |
|
638 |
/* make sure we do not show the placeholder databases in the all view */ |
|
639 |
if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) { |
|
640 |
continue 2; |
|
641 |
} |
|
642 |
break; |
|
643 |
default: |
|
644 |
/* just use the name here */ |
|
645 |
if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) { |
|
646 |
continue 2; |
|
647 |
} |
|
648 |
} |
|
649 |
if(in_array($curdatabase, $ui_databases)) { |
|
650 |
$id = "{$graph}-{$curoption}-{$curdatabase}"; |
|
651 |
$id = preg_replace('/\./', '_', $id); |
|
652 |
|
|
653 |
$dates = get_dates($curperiod, $graph); |
|
654 |
$start = $dates['start']; |
|
655 |
$end = $dates['end']; |
|
656 |
echo "<tr><td colspan=\"2\" class=\"list\">\n"; |
|
657 |
echo "<img border=\"0\" name=\"{$id}\" "; |
|
658 |
echo "id=\"{$id}\" alt=\"$prettydb Graph\" "; |
|
659 |
echo "src=\"status_rrd_graph_img.php?start={$start}&end={$end}&database={$curdatabase}&style={$curstyle}&graph={$graph}\" />\n"; |
|
660 |
echo "<br /><hr /><br />\n"; |
|
661 |
echo "</td></tr>\n"; |
|
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; |
|
662 | 716 |
} |
663 | 717 |
} |
718 |
if(!$found_gateway) { |
|
719 |
continue 2; |
|
720 |
} |
|
664 | 721 |
} |
665 |
} |
|
666 |
?> |
|
667 |
<tr> |
|
668 |
<td colspan="2" class="list"> |
|
669 |
<script type="text/javascript"> |
|
670 |
//<![CDATA[ |
|
671 |
function update_graph_images() { |
|
672 |
//alert('updating'); |
|
673 |
var randomid = Math.floor(Math.random()*11); |
|
674 |
<?php |
|
675 |
foreach($graphs as $graph) { |
|
676 |
/* check which databases are valid for our category */ |
|
677 |
foreach($ui_databases as $curdatabase) { |
|
678 |
if(! stristr($curdatabase, $curcat)) { |
|
679 |
continue; |
|
680 |
} |
|
681 |
$optionc = explode("-", $curdatabase); |
|
682 |
$search = array("-", ".rrd", $optionc); |
|
683 |
$replace = array(" :: ", "", $friendly); |
|
684 |
switch($curoption) { |
|
685 |
case "outbound": |
|
686 |
/* make sure we do not show the placeholder databases in the outbound view */ |
|
687 |
if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) { |
|
688 |
continue 2; |
|
689 |
} |
|
690 |
/* only show interfaces with a gateway */ |
|
691 |
$optionc = "$optionc[0]"; |
|
692 |
if(!interface_has_gateway($optionc)) { |
|
693 |
if(!isset($gateways_arr)) |
|
694 |
if(preg_match("/quality/i", $curdatabase)) |
|
695 |
$gateways_arr = return_gateways_array(); |
|
696 |
else |
|
697 |
$gateways_arr = array(); |
|
698 |
$found_gateway = false; |
|
699 |
foreach ($gateways_arr as $gw) { |
|
700 |
if ($gw['name'] == $optionc) { |
|
701 |
$found_gateway = true; |
|
702 |
break; |
|
703 |
} |
|
704 |
} |
|
705 |
if(!$found_gateway) { |
|
706 |
continue 2; |
|
707 |
} |
|
708 |
} |
|
709 |
if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) { |
|
710 |
continue 2; |
|
711 |
} |
|
712 |
break; |
|
713 |
case "allgraphs": |
|
714 |
/* make sure we do not show the placeholder databases in the all view */ |
|
715 |
if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) { |
|
716 |
continue 2; |
|
717 |
} |
|
718 |
break; |
|
719 |
default: |
|
720 |
/* just use the name here */ |
|
721 |
if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) { |
|
722 |
continue 2; |
|
723 |
} |
|
724 |
} |
|
725 |
$dates = get_dates($curperiod, $graph); |
|
726 |
$start = $dates['start']; |
|
727 |
if($curperiod == "current") { |
|
728 |
$end = $dates['end']; |
|
729 |
} |
|
730 |
/* generate update events utilizing jQuery('') feature */ |
|
731 |
$id = "{$graph}-{$curoption}-{$curdatabase}"; |
|
732 |
$id = preg_replace('/\./', '_', $id); |
|
733 |
|
|
734 |
echo "\n"; |
|
735 |
echo "\t\tjQuery('#{$id}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n"; |
|
736 |
} |
|
737 |
} |
|
738 |
?> |
|
739 |
window.setTimeout('update_graph_images()', 355000); |
|
722 |
if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) { |
|
723 |
continue 2; |
|
740 | 724 |
} |
741 |
window.setTimeout('update_graph_images()', 355000); |
|
742 |
//]]> |
|
743 |
</script> |
|
744 |
</td> |
|
745 |
</tr> |
|
746 |
</table> |
|
747 |
</div> |
|
748 |
</td> |
|
749 |
</tr> |
|
750 |
</table> |
|
751 |
</form> |
|
752 |
<?php include("fend.inc"); ?> |
|
753 |
</body> |
|
754 |
</html> |
|
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"); ?> |
Also available in: Unified diff
status_rd_graph.php updated
This page has been extensively updated, but it could do with bing
revised further at some time in the future.
For now it works slightly better than the original, looks reasonable
and has been updated to the project display system.
I’d like to merge it now, with the option to revisit it later.