summaryrefslogtreecommitdiffstats
path: root/etc/inc
diff options
context:
space:
mode:
authorsmos <seth.mos@dds.nl>2012-05-21 15:29:57 +0200
committersmos <seth.mos@dds.nl>2012-05-21 15:31:02 +0200
commit5e5896856a2a7e464225db18b68600b48e41033e (patch)
tree74ef226fb0d02a0851663d999674c0bf7e0ba4d7 /etc/inc
parentc0ae3bfb747553ba8ebcf63be3d0d10427f84f5a (diff)
downloadpfsense-5e5896856a2a7e464225db18b68600b48e41033e.zip
pfsense-5e5896856a2a7e464225db18b68600b48e41033e.tar.gz
Add 3G statistics for Huawei modems, split the Cellular stats out to per interface instead of global.
Diffstat (limited to 'etc/inc')
-rw-r--r--etc/inc/interfaces.inc6
-rw-r--r--etc/inc/pfsense-utils.inc11
-rw-r--r--etc/inc/rrd.inc54
3 files changed, 43 insertions, 28 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index eaf6a8f..6405063 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -1722,6 +1722,12 @@ EOD;
$i++;
}
+ foreach($ports as $port) {
+ $mondev = substr(basename($port), 0, -1). "3";
+ log_error("/usr/local/bin/3gstats.php $mondev $interface");
+ mwexec_bg("/usr/local/bin/3gstats.php $mondev {$interface}");
+ }
+
return 1;
}
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 146b81e..113e477 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -1259,6 +1259,17 @@ function get_interface_info($ifdescr) {
$ifinfo['nodevice'] = 1;
$ifinfo['pppinfo'] = $dev . " " . gettext("device not present! Is the modem attached to the system?");
}
+
+ $mondev = $dev;
+ /* FIXME: needs a gui part really, some devices only have port 2. */
+ $mondev = "{$g['tmp_path']}/3gstats.". substr(basename($mondev), 0, -1) ."3";
+ if(file_exists($mondev)) {
+ $cellstats = file($mondev);
+ $a_cellstats = explode(",", $cellstats[1]);
+ $ifinfo['cell_rssi'] = $a_cellstats[1];
+ $ifinfo['cell_upstream'] = $a_cellstats[7];
+ $ifinfo['cell_downstream'] = trim($a_cellstats[8]);
+ }
// Calculate cumulative uptime for PPP link. Useful for connections that have per minute/hour contracts so you don't go over!
if (isset($ppp['uptime']))
$ifinfo['ppp_uptime_accumulated'] = "(".get_ppp_uptime($ifinfo['if']).")";
diff --git a/etc/inc/rrd.inc b/etc/inc/rrd.inc
index 4c218a7..a6b4dc0 100644
--- a/etc/inc/rrd.inc
+++ b/etc/inc/rrd.inc
@@ -539,6 +539,32 @@ function enable_rrd_graphing() {
$rrdupdatesh .= " printf \"-t \" dsname \" N:\" dsdata }' ";
$rrdupdatesh .= " dsname=\"\" dsdata=\"\"`\n\n";
}
+
+ /* 3G interfaces */
+ 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 ";
+ $rrdcreate .= "DS:upstream:GAUGE:$cellularvalid:0:100000000 ";
+ $rrdcreate .= "DS:downstream:GAUGE:$cellularvalid:0:100000000 ";
+ $rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
+ $rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
+ $rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
+ $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
+ create_new_rrd($rrdcreate);
+ }
+
+ /* enter UNKNOWN values in the RRD so it knows we rebooted. */
+ if($g['booting']) {
+ mwexec("$rrdtool update $rrddbpath$ifname$cellular N:U:U:U");
+ }
+
+ $rrdupdatesh .= "\n";
+ $rrdupdatesh .= "# polling 3G\n";
+ $rrdupdatesh .= "3GSTATS=`awk -F, 'getline 2 {print \$2 \":\" \$8 \":\" \$9}' < /tmp/3gstats.$ifname\`\n";
+ $rrdupdatesh .= "$rrdtool update N:\"\$3GSTATS\"";
+ }
+
}
$i++;
@@ -677,34 +703,6 @@ function enable_rrd_graphing() {
}
/* End System statistics */
- /* 3G WIRELESS, set up the rrd file */
- /* XXX: Are multiple 3G interfaces not possible? smos@ */
- if(isset($config['ppps']['ppp'])) {
- $ifname = "ppp";
- if (!file_exists("$rrddbpath$ifname$cellular")) {
- $rrdcreate = "$rrdtool create $rrddbpath$ifname$cellular --step $rrdcellularinterval ";
- $rrdcreate .= "DS:signal1:GAUGE:$cellularvalid:-200:200 ";
- $rrdcreate .= "DS:signal2:GAUGE:$cellularvalid:-200:200 ";
- $rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
- $rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
- $rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
- $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
-
- create_new_rrd($rrdcreate);
- }
-
- /* enter UNKNOWN values in the RRD so it knows we rebooted. */
- if($g['booting']) {
- mwexec("$rrdtool update $rrddbpath$ifname$cellular N:U:U");
- }
-
- $rrdupdatesh .= "\n";
- $rrdupdatesh .= "# polling 3G\n";
- $rrdupdatesh .= "dev=`usbconfig show_ifdrv | awk -F. '/ u3g|umodem/ {print \"/dev/\" $1 \".\" $2}'`\n";
- $rrdupdatesh .= "if [ -n \"\$dev\" ]; then $rrdtool update $rrddbpath$ifname$cellular N:`3gstat -s -d \$dev`\n";
- $rrdupdatesh .= "else $rrdtool update $rrddbpath$ifname$cellular N:U:U; fi\n";
- }
-
/* Captive Portal statistics, set up the rrd file */
if(isset($config['captiveportal']['enable'])) {
$ifname= "captiveportal";
OpenPOWER on IntegriCloud