summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorSeth Mos <seth.mos@xs4all.nl>2008-06-21 15:04:03 +0000
committerSeth Mos <seth.mos@xs4all.nl>2008-06-21 15:04:03 +0000
commit047fa1d050550b926126faf7654ee0542dc20c2e (patch)
treed13503bf66e86fc08615384f1e5aca007381233e /etc
parent7d4515cab0fe3731dbf2333ddb9a483fc0cb2c22 (diff)
downloadpfsense-047fa1d050550b926126faf7654ee0542dc20c2e.zip
pfsense-047fa1d050550b926126faf7654ee0542dc20c2e.tar.gz
Fix quality graphs databases, add function to lookup gateway monitor IP by gateway name
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/pfsense-utils.inc43
1 files changed, 26 insertions, 17 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 3ec1bf1..c47e147 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -3167,20 +3167,10 @@ function enable_rrd_graphing() {
} else {
$rrdupdatesh .= "`$netstat -nbf link -I {$realif} | $awk '{getline 2;print \$5 \":\" \$8}'`\n";
}
- /* FIXME: needs to use the monitor setting from the gateways array now */
- /* if an alternative gateway is defined, use it */
- if ($config['interfaces'][$ifname]['use_rrd_gateway'] <> "") {
- $gatewayip = get_interface_gateway($ifname);
- $monitorip = $config['interfaces'][$ifname]['use_rrd_gateway'];
- mwexec("/sbin/route add -host {$monitorip} {$gatewayip} 1> /dev/null 2>&1");
- } else {
- $monitorip = get_interface_gateway($ifname);
- }
- $numpings = 5;
- $btick = '`';
- if($monitorip <> "") {
- /* QUALITY, create link quality database */
+ /* QUALITY, create link quality database */
+ /* if the interface has a gateway defined, use it */
+ if(interface_has_gateway($ifname)) {
if (!file_exists("$rrddbpath$ifname$quality")) {
/* create rrd file if it does not exist */
log_error("Create RRD database $rrddbpath$ifname$quality");
@@ -3203,16 +3193,18 @@ function enable_rrd_graphing() {
if($g['booting']) {
exec("$rrdtool update $rrddbpath$ifname$quality N:U:U");
}
-
+
+ $numpings = 5;
+ $monitorip = lookup_gateway_monitor_ip_by_name($config['interfaces'][$ifname]['gateway']);
/* the ping test function. We call this on the last line */
$rrdupdatesh .= "get_quality_stats_{$ifname} () {\n";
$rrdupdatesh .= " packetloss_{$ifname}=100\n";
$rrdupdatesh .= " roundtrip_{$ifname}=0\n";
$rrdupdatesh .= " local out_{$ifname}\n";
- $rrdupdatesh .= " out_{$ifname}=$btick ping -c $numpings -q $monitorip $btick\n";
+ $rrdupdatesh .= " out_{$ifname}=\`ping -c $numpings -q $monitorip\`\n";
$rrdupdatesh .= " if [ $? -eq 0 ]; then\n";
- $rrdupdatesh .= " packetloss_{$ifname}=$btick echo \$out_{$ifname} | cut -f18 -d' ' | cut -c -1 $btick\n";
- $rrdupdatesh .= " roundtrip_{$ifname}=$btick echo \$out_{$ifname} | cut -f24 -d' ' | cut -f2 -d'/' $btick\n";
+ $rrdupdatesh .= " packetloss_{$ifname}=\`echo \$out_{$ifname} | cut -f18 -d' ' | cut -c -1\`\n";
+ $rrdupdatesh .= " roundtrip_{$ifname}=\`echo \$out_{$ifname} | cut -f24 -d' ' | cut -f2 -d'/'\`\n";
$rrdupdatesh .= " fi\n";
$rrdupdatesh .= " $rrdtool update $rrddbpath$ifname$quality N:\$packetloss_{$ifname}:\$roundtrip_{$ifname}\n";
$rrdupdatesh .= "}\n\n";
@@ -3996,6 +3988,23 @@ function lookup_gateway_ip_by_name($name) {
}
}
+function lookup_gateway_monitor_ip_by_name($name) {
+ global $config;
+ if(is_array($config['gateways'])) {
+ foreach($config['gateways']['gateway_item'] as $gateway) {
+ if($gateway['name'] == "$name") {
+ $monitorip = $gateway['monitor'];
+ if($monitorip == "")
+ $monitorip = $gateway['gateway'];
+
+ return($monitorip);
+ }
+ }
+ } else {
+ return(false);
+ }
+}
+
function lookup_gateway_interface_by_name($name) {
global $config;
if(is_array($config['gateways'])) {
OpenPOWER on IntegriCloud