summaryrefslogtreecommitdiffstats
path: root/usr/local/bin
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/bin
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/bin')
-rwxr-xr-xusr/local/bin/3gstats.php54
1 files changed, 54 insertions, 0 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);
+?>
OpenPOWER on IntegriCloud