summaryrefslogtreecommitdiff
path: root/datasources/adsl-snmp.sh
diff options
context:
space:
mode:
authorEbus-at-dockstar <ebus@dockstar>2014-09-18 15:48:47 +0200
committerEbus-at-dockstar <ebus@dockstar>2014-09-18 15:48:47 +0200
commitf5fc2f205f22580bfaea3efaa055bcb090500c05 (patch)
tree559a8a54972ec834581f3547cc3bef8af6a742b6 /datasources/adsl-snmp.sh
parent84b33f3efbe4678ddf2acb54aee0aeaaa43240d9 (diff)
downloadebus-alt-f5fc2f205f22580bfaea3efaa055bcb090500c05.tar.gz
ebus-alt-f5fc2f205f22580bfaea3efaa055bcb090500c05.zip
updated datasources
Diffstat (limited to 'datasources/adsl-snmp.sh')
-rwxr-xr-xdatasources/adsl-snmp.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/datasources/adsl-snmp.sh b/datasources/adsl-snmp.sh
new file mode 100755
index 0000000..33a895e
--- /dev/null
+++ b/datasources/adsl-snmp.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+. "`dirname \"$0\"`"/datastore-functions.sh
+
+
+get_value() {
+ snmpget -v 1 -c public $1 $2 |
+ gawk '{ if (/Counter32/) { match($0, "Counter32: (.*)", a); print a[1]; } }'
+}
+
+in1=`get_value 192.168.10.1 IF-MIB::ifInOctets.4`
+out1=`get_value 192.168.10.1 IF-MIB::ifOutOctets.4`
+
+sleep 30
+
+in2=`get_value 192.168.10.1 IF-MIB::ifInOctets.4`
+out2=`get_value 192.168.10.1 IF-MIB::ifOutOctets.4`
+
+
+inps=`expr \( $in2 - $in1 \) / 30`
+outps=`expr \( $out2 - $out1 \) / 30`
+
+in_max=620000
+out_max=150000
+
+in_p=`expr \( $inps \* 100 \) / $in_max`
+out_p=`expr \( $outps \* 100 \) / $out_max`
+
+put_value_sensor_now "adsl.in.percent" "$in_p"
+put_value_sensor_now "adsl.in.persecond" "$inps"
+put_value_sensor_now "adsl.out.percent" "$out_p"
+put_value_sensor_now "adsl.out.persecond" "$outps"
+