diff options
author | Chris Buechler <cmb@pfsense.org> | 2015-11-18 18:18:05 -0600 |
---|---|---|
committer | Chris Buechler <cmb@pfsense.org> | 2015-11-18 18:18:40 -0600 |
commit | ec5b9e96fa2c215bdf827de47f5ffdd758bfe2da (patch) | |
tree | 950f2c44afdf3cc2bc131c98b3b164b4cecb9c10 /src/etc | |
parent | 0206483d49ef8139ccbc281fdba5f2f62a0bb925 (diff) | |
download | pfsense-ec5b9e96fa2c215bdf827de47f5ffdd758bfe2da.zip pfsense-ec5b9e96fa2c215bdf827de47f5ffdd758bfe2da.tar.gz |
fix invalid foreach with no DHCP server enabled introduced in Ticket #5387
Diffstat (limited to 'src/etc')
-rw-r--r-- | src/etc/inc/rrd.inc | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/src/etc/inc/rrd.inc b/src/etc/inc/rrd.inc index 5f7ac73..1459c93 100644 --- a/src/etc/inc/rrd.inc +++ b/src/etc/inc/rrd.inc @@ -917,42 +917,43 @@ function enable_rrd_graphing() { /* End NTP statistics */ /* Start dhcpd statistics */ - foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) { - if (isset($config['dhcpd'][$dhcpif]['statsgraph'])) { - if (!file_exists("$rrddbpath$dhcpif$dhcpd")) { - $rrdcreate = "$rrdtool create $rrddbpath$dhcpif$dhcpd --step $rrddhcpdinterval "; - $rrdcreate .= "DS:leases:GAUGE:$dhcpdvalid:0:100000 "; - $rrdcreate .= "DS:staticleases:GAUGE:$dhcpdvalid:0:100000 "; - $rrdcreate .= "DS:dhcprange:GAUGE:$dhcpdvalid:0:100000 "; - $rrdcreate .= "RRA:MIN:0.5:1:1200 "; - $rrdcreate .= "RRA:MIN:0.5:5:720 "; - $rrdcreate .= "RRA:MIN:0.5:60:1860 "; - $rrdcreate .= "RRA:MIN:0.5:1440:2284 "; - $rrdcreate .= "RRA:AVERAGE:0.5:1:1200 "; - $rrdcreate .= "RRA:AVERAGE:0.5:5:720 "; - $rrdcreate .= "RRA:AVERAGE:0.5:60:1860 "; - $rrdcreate .= "RRA:AVERAGE:0.5:1440:2284 "; - $rrdcreate .= "RRA:MAX:0.5:1:1200 "; - $rrdcreate .= "RRA:MAX:0.5:5:720 "; - $rrdcreate .= "RRA:MAX:0.5:60:1860 "; - $rrdcreate .= "RRA:MAX:0.5:1440:2284 "; - create_new_rrd($rrdcreate); - unset($rrdcreate); - } + if (is_array($config['dhcpd'])) { + foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) { + if (isset($config['dhcpd'][$dhcpif]['statsgraph'])) { + if (!file_exists("$rrddbpath$dhcpif$dhcpd")) { + $rrdcreate = "$rrdtool create $rrddbpath$dhcpif$dhcpd --step $rrddhcpdinterval "; + $rrdcreate .= "DS:leases:GAUGE:$dhcpdvalid:0:100000 "; + $rrdcreate .= "DS:staticleases:GAUGE:$dhcpdvalid:0:100000 "; + $rrdcreate .= "DS:dhcprange:GAUGE:$dhcpdvalid:0:100000 "; + $rrdcreate .= "RRA:MIN:0.5:1:1200 "; + $rrdcreate .= "RRA:MIN:0.5:5:720 "; + $rrdcreate .= "RRA:MIN:0.5:60:1860 "; + $rrdcreate .= "RRA:MIN:0.5:1440:2284 "; + $rrdcreate .= "RRA:AVERAGE:0.5:1:1200 "; + $rrdcreate .= "RRA:AVERAGE:0.5:5:720 "; + $rrdcreate .= "RRA:AVERAGE:0.5:60:1860 "; + $rrdcreate .= "RRA:AVERAGE:0.5:1440:2284 "; + $rrdcreate .= "RRA:MAX:0.5:1:1200 "; + $rrdcreate .= "RRA:MAX:0.5:5:720 "; + $rrdcreate .= "RRA:MAX:0.5:60:1860 "; + $rrdcreate .= "RRA:MAX:0.5:1440:2284 "; + create_new_rrd($rrdcreate); + unset($rrdcreate); + } - /* enter UNKNOWN values in the RRD so it knows we rebooted. */ - if (platform_booting()) { - mwexec("$rrdtool update $rrddbpath$dhcpif$dhcpd N:U:U:U:U:U:U:U:U"); - } + /* enter UNKNOWN values in the RRD so it knows we rebooted. */ + if (platform_booting()) { + mwexec("$rrdtool update $rrddbpath$dhcpif$dhcpd N:U:U:U:U:U:U:U:U"); + } - $rrdupdatesh .= "\n"; - $rrdupdatesh .= "# polling leases for dhcp \n"; - $rrdupdatesh .= "DHCP=`${php} -q ${dhcpd_gather} '${dhcpif}'`\n"; - $rrdupdatesh .= "$rrdtool update $rrddbpath$dhcpif$dhcpd \${DHCP}\n"; - + $rrdupdatesh .= "\n"; + $rrdupdatesh .= "# polling leases for dhcp \n"; + $rrdupdatesh .= "DHCP=`${php} -q ${dhcpd_gather} '${dhcpif}'`\n"; + $rrdupdatesh .= "$rrdtool update $rrddbpath$dhcpif$dhcpd \${DHCP}\n"; + + } } } - /* END dhcpd statistics */ $rrdupdatesh .= "sleep 60\n"; |