blob: 33a895e324162f7440c6cb2a849f3e7ec4a1b619 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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"
|