summaryrefslogtreecommitdiffstats
path: root/usr/local
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 /usr/local
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 'usr/local')
-rwxr-xr-xusr/local/bin/3gstats.php54
-rwxr-xr-xusr/local/www/status_interfaces.php21
-rw-r--r--usr/local/www/status_rrd_graph_img.php19
3 files changed, 81 insertions, 13 deletions
diff --git a/usr/local/bin/3gstats.php b/usr/local/bin/3gstats.php
new file mode 100755
index 0000000..fe7be46
--- /dev/null
+++ b/usr/local/bin/3gstats.php
@@ -0,0 +1,54 @@
+#!/usr/local/bin/php -f
+<?php
+
+if(empty($argv[1])) {
+ echo "No modem device given \n";
+ exit(0);
+}
+
+/* Huawei example */
+$device = "/dev/{$argv[1]}";
+$statfile = "/tmp/3gstats.{$argv[2]}";
+$header = "#seconds,rssi,mode,upstream,downstream,sentbytes,receivedbyts,bwupstream,bwdownstream\n";
+
+$i = 0;
+
+$record = array();
+$handle = fopen($device, "r");
+while(true) {
+ $string = "";
+ $string = fgets($handle, 256);
+
+ $elements = array();
+ $elements = split(":", $string);
+ $elements[0] = trim($elements[0]);
+ $elements[1] = trim($elements[1]);
+
+ switch($elements[0]) {
+ case "^RSSI":
+ $record['rssi'] = $elements[1];
+ break;
+ case "^DSFLOWRPT":
+ $items = array();
+ $items = split(",", $elements[1]);
+ $record['bwdownstream'] = 0;
+ $record['bwdownstream'] = 0;
+ $record['time'] = hexdec($items[0]);
+ $record['upstream'] = hexdec($items[1]);
+ $record['downstream'] = hexdec($items[2]);
+ $record['sent'] = hexdec($items[3]);
+ $record['received'] = hexdec($items[4]);
+ $record['bwupstream'] = hexdec($items[5]);
+ $record['bwdownstream'] = hexdec($items[6]);
+ break;
+ }
+
+ if($i > 10) {
+ $csv = $header . "{$record['time']},{$record['rssi']},{$record['mode']},{$record['upstream']},{$record['downstream']},{$record['sent']},{$record['received']},{$record['bwupstream']},{$record['bwdownstream']}\n";
+ file_put_contents($statfile, $csv);
+ $i = 0;
+ }
+ $i++;
+}
+fclose($handle);
+?>
diff --git a/usr/local/www/status_interfaces.php b/usr/local/www/status_interfaces.php
index 56c4b57..dec67bb 100755
--- a/usr/local/www/status_interfaces.php
+++ b/usr/local/www/status_interfaces.php
@@ -191,6 +191,27 @@ include("head.inc");
<?=htmlspecialchars($ifinfo['ppp_uptime']);?> <?=htmlspecialchars($ifinfo['ppp_uptime_accumulated']);?>
</td>
</tr>
+ <?php endif; if ($ifinfo['cell_rssi']): ?>
+ <tr>
+ <td width="22%" class="vncellt"><?=gettext("Cell Signal (RSSI)");?></td>
+ <td width="78%" class="listr">
+ <?=htmlspecialchars($ifinfo['cell_rssi']);?> (0-31)
+ </td>
+ </tr>
+ <?php endif; if ($ifinfo['cell_upstream']): ?>
+ <tr>
+ <td width="22%" class="vncellt"><?=gettext("Cell Upstream");?></td>
+ <td width="78%" class="listr">
+ <?=htmlspecialchars($ifinfo['cell_upstream']);?> kbit/s
+ </td>
+ </tr>
+ <?php endif; if ($ifinfo['cell_downstream']): ?>
+ <tr>
+ <td width="22%" class="vncellt"><?=gettext("Cell Downstream");?></td>
+ <td width="78%" class="listr">
+ <?=htmlspecialchars($ifinfo['cell_downstream']);?> kbit/s
+ </td>
+ </tr>
<?php endif; if ($ifinfo['macaddr']): ?>
<tr>
<td width="22%" class="vncellt"><?=gettext("MAC address");?></td>
diff --git a/usr/local/www/status_rrd_graph_img.php b/usr/local/www/status_rrd_graph_img.php
index 3756f65..fea016b 100644
--- a/usr/local/www/status_rrd_graph_img.php
+++ b/usr/local/www/status_rrd_graph_img.php
@@ -1031,21 +1031,14 @@ elseif((strstr($curdatabase, "-cellular.rrd")) && (file_exists("$rrddbpath$curda
$graphcmd .= "--color SHADEA#eeeeee --color SHADEB#eeeeee ";
$graphcmd .= "--title \"`hostname` - {$prettydb} - {$hperiod} - {$havg} average\" ";
$graphcmd .= "--height 200 --width 620 ";
- $graphcmd .= "DEF:\"$curif-signal1=$rrddbpath$curdatabase:signal1:AVERAGE\" ";
- $graphcmd .= "DEF:\"$curif-signal2=$rrddbpath$curdatabase:signal2:AVERAGE\" ";
- $graphcmd .= "LINE2:\"$curif-signal1#{$colorwireless[0]}:$curif-signal1\" ";
- $graphcmd .= "LINE2:\"$curif-signal2#{$colorwireless[1]}:$curif-signal2\" ";
+ $graphcmd .= "DEF:\"$curif-rssi=$rrddbpath$curdatabase:rssi:AVERAGE\" ";
+ $graphcmd .= "LINE2:\"$curif-rssi#{$colorwireless[0]}:$curif-rssi\" ";
$graphcmd .= "COMMENT:\"\\n\" ";
$graphcmd .= "COMMENT:\"\t\t maximum\t\t average\t current\\n\" ";
- $graphcmd .= "COMMENT:\"Signal1\t\t\" ";
- $graphcmd .= "GPRINT:\"$curif-signal1:MAX:%7.2lf dBm \" ";
- $graphcmd .= "GPRINT:\"$curif-signal1:AVERAGE:%7.2lf dBm \" ";
- $graphcmd .= "GPRINT:\"$curif-signal1:LAST:%7.2lf dBm\" ";
- $graphcmd .= "COMMENT:\"\\n\" ";
- $graphcmd .= "COMMENT:\"Signal2\t\t\" ";
- $graphcmd .= "GPRINT:\"$curif-signal2:MAX:%7.2lf dBm \" ";
- $graphcmd .= "GPRINT:\"$curif-signal2:AVERAGE:%7.2lf dBm \" ";
- $graphcmd .= "GPRINT:\"$curif-signal2:LAST:%7.2lf dBm\" ";
+ $graphcmd .= "COMMENT:\"RSSI\t\t\" ";
+ $graphcmd .= "GPRINT:\"$curif-rssi:MAX:%7.2lf \" ";
+ $graphcmd .= "GPRINT:\"$curif-rssi:AVERAGE:%7.2lf \" ";
+ $graphcmd .= "GPRINT:\"$curif-rssi:LAST:%7.2lf \" ";
$graphcmd .= "COMMENT:\"\\n\" ";
$graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t`date +\"%b %d %H\:%M\:%S %Y\"`\" ";
}
OpenPOWER on IntegriCloud