Commit 8e823ef0 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) spaces and curly braces in rrd.inc

parent ababecf8
......@@ -41,7 +41,7 @@ function restore_rrd()
}
$_gb = exec('cd /;LANG=C /usr/bin/tar -xzf /conf/rrd.tgz 2>&1', $rrdrestore, $rrdreturn);
$rrdrestore = implode(" ", $rrdrestore);
if($rrdreturn != 0) {
if ($rrdreturn != 0) {
log_error("RRD restore failed exited with $rrdreturn, the error is: $rrdrestore\n");
}
unset($rrdrestore);
......@@ -82,8 +82,9 @@ function enable_rrd_graphing()
{
global $config;
if(file_exists("/var/run/booting"))
if (file_exists("/var/run/booting")) {
echo gettext("Generating RRD graphs...");
}
$rrddbpath = "/var/db/rrd/";
$rrdgraphpath = "/usr/local/www/rrd";
......@@ -139,7 +140,6 @@ function enable_rrd_graphing()
$upstream = 2500000000;
if (isset ($config['rrd']['enable'])) {
/* create directory if needed */
if (!is_dir($rrddbpath)) {
mkdir($rrddbpath, 0775);
......@@ -167,7 +167,7 @@ function enable_rrd_graphing()
/* IPsec counters */
$ifdescrs['ipsec'] = "IPsec";
/* OpenVPN server counters */
if(isset($config['openvpn']['openvpn-server'])) {
if (isset($config['openvpn']['openvpn-server'])) {
foreach($config['openvpn']['openvpn-server'] as $server) {
$serverid = "ovpns" . $server['vpnid'];
$ifdescrs[$serverid] = "{$server['description']}";
......@@ -177,7 +177,7 @@ function enable_rrd_graphing()
/* process all real and pseudo interfaces */
foreach ($ifdescrs as $ifname => $ifdescr) {
$temp = get_real_interface($ifname);
if($temp <> "") {
if ($temp <> "") {
$realif = $temp;
}
......@@ -202,7 +202,7 @@ function enable_rrd_graphing()
}
/* enter UNKNOWN values in the RRD so it knows we rebooted. */
if(file_exists("/var/run/booting")) {
if (file_exists("/var/run/booting")) {
mwexec("$rrdtool update $rrddbpath$ifname$traffic N:U:U:U:U:U:U:U:U");
}
......@@ -235,7 +235,7 @@ function enable_rrd_graphing()
}
/* enter UNKNOWN values in the RRD so it knows we rebooted. */
if(file_exists("/var/run/booting")) {
if (file_exists("/var/run/booting")) {
mwexec("$rrdtool update $rrddbpath$ifname$packets N:U:U:U:U:U:U:U:U");
}
......@@ -248,7 +248,7 @@ function enable_rrd_graphing()
$rrdupdatesh .= "END {print b4pi \":\" b4po \":\" b4bi \":\" b4bo \":\" b6pi \":\" b6po \":\" b6bi \":\" b6bo};'`\n";
/* WIRELESS, set up the rrd file */
if(isset($config['interfaces'][$ifname]['wireless']['mode']) && $config['interfaces'][$ifname]['wireless']['mode'] == "bss") {
if (isset($config['interfaces'][$ifname]['wireless']['mode']) && $config['interfaces'][$ifname]['wireless']['mode'] == "bss") {
if (!file_exists("$rrddbpath$ifname$wireless")) {
$rrdcreate = "$rrdtool create $rrddbpath$ifname$wireless --step $rrdwirelessinterval ";
$rrdcreate .= "DS:snr:GAUGE:$wirelessvalid:0:1000 ";
......@@ -264,7 +264,7 @@ function enable_rrd_graphing()
}
/* enter UNKNOWN values in the RRD so it knows we rebooted. */
if(file_exists("/var/run/booting")) {
if (file_exists("/var/run/booting")) {
mwexec("$rrdtool update $rrddbpath$ifname$wireless N:U:U:U");
}
......@@ -275,7 +275,7 @@ function enable_rrd_graphing()
}
/* OpenVPN, set up the rrd file */
if(stristr($ifname, "ovpns")) {
if (stristr($ifname, "ovpns")) {
if (!file_exists("$rrddbpath$ifname$vpnusers")) {
$rrdcreate = "$rrdtool create $rrddbpath$ifname$vpnusers --step $rrdvpninterval ";
$rrdcreate .= "DS:users:GAUGE:$vpnvalid:0:10000 ";
......@@ -289,13 +289,13 @@ function enable_rrd_graphing()
}
/* enter UNKNOWN values in the RRD so it knows we rebooted. */
if(file_exists("/var/run/booting")) {
if (file_exists("/var/run/booting")) {
mwexec("$rrdtool update $rrddbpath$ifname$vpnusers N:U");
}
if(is_array($config['openvpn']['openvpn-server'])) {
if (is_array($config['openvpn']['openvpn-server'])) {
foreach($config['openvpn']['openvpn-server'] as $server) {
if("ovpns{$server['vpnid']}" == $ifname) {
if ("ovpns{$server['vpnid']}" == $ifname) {
$port = $server['local_port'];
$vpnid = $server['vpnid'];
}
......@@ -314,7 +314,7 @@ function enable_rrd_graphing()
}
/* 3G interfaces */
if(preg_match("/ppp[0-9]+/i", $realif)) {
if (preg_match("/ppp[0-9]+/i", $realif)) {
if (!file_exists("$rrddbpath$ifname$cellular")) {
$rrdcreate = "$rrdtool create $rrddbpath$ifname$cellular --step $rrdcellularinterval ";
$rrdcreate .= "DS:rssi:GAUGE:$cellularvalid:0:100 ";
......@@ -329,7 +329,7 @@ function enable_rrd_graphing()
}
/* enter UNKNOWN values in the RRD so it knows we rebooted. */
if(file_exists("/var/run/booting")) {
if (file_exists("/var/run/booting")) {
mwexec("$rrdtool update $rrddbpath$ifname$cellular N:U:U:U");
}
......@@ -338,7 +338,6 @@ function enable_rrd_graphing()
$rrdupdatesh .= "GSTATS=`awk -F, 'getline 2 {print \$2 \":\" \$8 \":\" \$9}' < /tmp/3gstats.$ifname`\n";
$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$cellular N:\"\$GSTATS\"";
}
}
$i++;
......@@ -346,7 +345,7 @@ function enable_rrd_graphing()
$ifname = "system";
/* STATES, create pf states database */
if(! file_exists("$rrddbpath$ifname$states")) {
if (! file_exists("$rrddbpath$ifname$states")) {
$rrdcreate = "$rrdtool create $rrddbpath$ifname$states --step $rrdstatesinterval ";
$rrdcreate .= "DS:pfrate:GAUGE:$statesvalid:0:10000000 ";
$rrdcreate .= "DS:pfstates:GAUGE:$statesvalid:0:10000000 ";
......@@ -363,7 +362,7 @@ function enable_rrd_graphing()
}
/* enter UNKNOWN values in the RRD so it knows we rebooted. */
if(file_exists("/var/run/booting")) {
if (file_exists("/var/run/booting")) {
mwexec("$rrdtool update $rrddbpath$ifname$states N:U:U:U:U:U");
}
......@@ -377,11 +376,10 @@ function enable_rrd_graphing()
$rrdupdatesh .= "srcip=\"` cat /tmp/pfctl_ss_out | egrep -v '<\\-.*?<\\-|\\->.*?\\->' | grep '\\->' | awk '{print \$3}' | awk -F: '{print \$1}' | sort -u|wc -l|sed 's/ //g' `\"\n";
$rrdupdatesh .= "dstip=\"` cat /tmp/pfctl_ss_out | egrep -v '<\\-.*?<\\-|\\->.*?\\->' | grep '<\\-' | awk '{print \$3}' | awk -F: '{print \$1}' | sort -u|wc -l|sed 's/ //g' `\"\n";
$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$states N:\$pfrate:\$pfstates:\$pfnat:\$srcip:\$dstip\n\n";
/* End pf states statistics */
/* CPU, create CPU statistics database */
if(! file_exists("$rrddbpath$ifname$proc")) {
if (!file_exists("$rrddbpath$ifname$proc")) {
$rrdcreate = "$rrdtool create $rrddbpath$ifname$proc --step $rrdprocinterval ";
$rrdcreate .= "DS:user:GAUGE:$procvalid:0:10000000 ";
$rrdcreate .= "DS:nice:GAUGE:$procvalid:0:10000000 ";
......@@ -398,7 +396,7 @@ function enable_rrd_graphing()
}
/* enter UNKNOWN values in the RRD so it knows we rebooted. */
if(file_exists("/var/run/booting")) {
if (file_exists("/var/run/booting")) {
mwexec("$rrdtool update $rrddbpath$ifname$proc N:U:U:U:U:U");
}
......@@ -407,11 +405,10 @@ function enable_rrd_graphing()
/* Using ps uxaH will count all processes including system threads. Top was undercounting. */
$rrdupdatesh .= "PROCS=`ps uxaH | wc -l | awk '{print \$1;}'`\n";
$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$proc N:\${CPU}:\${PROCS}\n";
/* End CPU statistics */
/* Memory, create Memory statistics database */
if(! file_exists("$rrddbpath$ifname$mem")) {
if (!file_exists("$rrddbpath$ifname$mem")) {
$rrdcreate = "$rrdtool create $rrddbpath$ifname$mem --step $rrdmeminterval ";
$rrdcreate .= "DS:active:GAUGE:$memvalid:0:10000000 ";
$rrdcreate .= "DS:inactive:GAUGE:$memvalid:0:10000000 ";
......@@ -436,7 +433,7 @@ function enable_rrd_graphing()
}
/* enter UNKNOWN values in the RRD so it knows we rebooted. */
if(file_exists("/var/run/booting")) {
if (file_exists("/var/run/booting")) {
mwexec("$rrdtool update $rrddbpath$ifname$mem N:U:U:U:U:U");
}
......@@ -445,11 +442,10 @@ function enable_rrd_graphing()
$rrdupdatesh .= " $awk '{getline active;getline inactive;getline free;getline cache;getline wire;printf ";
$rrdupdatesh .= "((active/$0) * 100)\":\"((inactive/$0) * 100)\":\"((free/$0) * 100)\":\"((cache/$0) * 100)\":\"(wire/$0 * 100)}'`\n";
$rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$mem N:\${MEM}\n";
/* End Memory statistics */
/* mbuf, create mbuf statistics database */
if(! file_exists("$rrddbpath$ifname$mbuf")) {
if (!file_exists("$rrddbpath$ifname$mbuf")) {
$rrdcreate = "$rrdtool create $rrddbpath$ifname$mbuf --step $rrdmbufinterval ";
$rrdcreate .= "DS:current:GAUGE:$mbufvalid:0:10000000 ";
$rrdcreate .= "DS:cache:GAUGE:$mbufvalid:0:10000000 ";
......@@ -473,7 +469,7 @@ function enable_rrd_graphing()
}
/* enter UNKNOWN values in the RRD so it knows we rebooted. */
if(file_exists("/var/run/booting")) {
if (file_exists("/var/run/booting")) {
mwexec("$rrdtool update $rrddbpath$ifname$mbuf N:U:U:U:U");
}
......@@ -514,10 +510,9 @@ function enable_rrd_graphing()
}
/* enter UNKNOWN values in the RRD so it knows we rebooted. */
if(file_exists("/var/run/booting")) {
if (file_exists("/var/run/booting")) {
mwexec("$rrdtool update $rrddbpath$ntpd N:U:U:U:U:U:U");
}
/* the ntp stats gathering function. */
$rrdupdatesh .= "\n";
$rrdupdatesh .= "$ntpq -c rv | $awk 'BEGIN{ RS=\",\"}{ print }' >> /tmp/ntp-rrdstats.$$\n";
......@@ -530,10 +525,8 @@ function enable_rrd_graphing()
$rrdupdatesh .= "$rrdtool update $rrddbpath$ntpd \N:\${NOFFSET}:\${NSJIT}:\${NCJIT}:\${NWANDER}:\${NFREQ}:\${NDISPER}\n";
$rrdupdatesh .= "rm /tmp/ntp-rrdstats.$$\n";
$rrdupdatesh .= "\n";
}
/* End NTP statistics */
$rrdupdatesh .= "sleep 60\n";
$rrdupdatesh .= "done\n";
log_error(gettext("Creating rrd update script"));
......@@ -550,7 +543,6 @@ function enable_rrd_graphing()
/* start traffic collector */
mwexec_bg("/bin/sh $updaterrdscript");
} else {
/* kill off traffic collectors */
kill_traffic_collector();
......@@ -561,9 +553,9 @@ function enable_rrd_graphing()
chown($database, "nobody");
}
if(file_exists("/var/run/booting"))
if (file_exists("/var/run/booting")) {
echo gettext("done.") . "\n";
}
}
function create_gateway_quality_rrd($rrd_file)
......@@ -587,7 +579,7 @@ function create_gateway_quality_rrd($rrd_file)
}
/* enter UNKNOWN values in the RRD so it knows we rebooted. */
if(file_exists("/var/run/booting")) {
if (file_exists("/var/run/booting")) {
mwexec("$rrdtool update $rrd_file N:U:U");
}
unset($rrdtool, $rrdinterval, $valid, $rrd_file);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment