| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | place=".1.3.6.1.4.1.2021.255" |
|---|
| 4 | |
|---|
| 5 | refresh() { |
|---|
| 6 | |
|---|
| 7 | id=1 |
|---|
| 8 | lastid=0 |
|---|
| 9 | |
|---|
| 10 | for mac in $(wl_atheros assoclist | cut -d" " -f2) |
|---|
| 11 | do |
|---|
| 12 | if test $lastid -eq 0 |
|---|
| 13 | then |
|---|
| 14 | getnext_1361412021255="$place.3.54.1.3.32.1.1.1" |
|---|
| 15 | getnext_1361412021255354133211="$place.3.54.1.3.32.1.1.1" |
|---|
| 16 | getnext_1361412021255354133214="$place.3.54.1.3.32.1.4.1" |
|---|
| 17 | getnext_13614120212553541332113="$place.3.54.1.3.32.1.13.1" |
|---|
| 18 | getnext_13614120212553541332126="$place.3.54.1.3.32.1.26.1" |
|---|
| 19 | getnext_13614120212553541332127="$place.3.54.1.3.32.1.27.1" |
|---|
| 20 | else |
|---|
| 21 | eval getnext_1361412021255354133211${lastid}="$place.3.54.1.3.32.1.1.$id" |
|---|
| 22 | eval getnext_1361412021255354133214${lastid}="$place.3.54.1.3.32.1.4.$id" |
|---|
| 23 | eval getnext_13614120212553541332113${lastid}="$place.3.54.1.3.32.1.13.$id" |
|---|
| 24 | eval getnext_13614120212553541332126${lastid}="$place.3.54.1.3.32.1.26.$id" |
|---|
| 25 | eval getnext_13614120212553541332127${lastid}="$place.3.54.1.3.32.1.27.$id" |
|---|
| 26 | fi |
|---|
| 27 | |
|---|
| 28 | rssi=$(wl_atheros rssi $mac | cut -d" " -f3) |
|---|
| 29 | noise_reference=$(wl_atheros noise $mac | cut -d" " -f3) |
|---|
| 30 | uptime=$(wl_atheros uptime $mac | cut -d" " -f3) |
|---|
| 31 | if test $rssi -eq 0 |
|---|
| 32 | then |
|---|
| 33 | snr=0 |
|---|
| 34 | else |
|---|
| 35 | let snr=-1*$noise_reference+$rssi |
|---|
| 36 | fi |
|---|
| 37 | mac=$(echo $mac | tr : ' ') |
|---|
| 38 | |
|---|
| 39 | eval value_1361412021255354133211${id}=$id; |
|---|
| 40 | eval type_1361412021255354133211${id}='integer'; |
|---|
| 41 | eval value_1361412021255354133214${id}='$mac'; |
|---|
| 42 | eval type_1361412021255354133214${id}='octet'; |
|---|
| 43 | eval value_13614120212553541332113${id}=$noise_reference; |
|---|
| 44 | eval type_13614120212553541332113${id}='integer'; |
|---|
| 45 | eval value_13614120212553541332126${id}=$snr; |
|---|
| 46 | eval type_13614120212553541332126${id}='integer'; |
|---|
| 47 | eval value_13614120212553541332127${id}=$uptime; |
|---|
| 48 | eval type_13614120212553541332127${id}='integer'; |
|---|
| 49 | |
|---|
| 50 | lastid=$id |
|---|
| 51 | let id=$id+1 |
|---|
| 52 | |
|---|
| 53 | done |
|---|
| 54 | |
|---|
| 55 | if test $lastid -ne 0 |
|---|
| 56 | then |
|---|
| 57 | eval getnext_1361412021255354133211${lastid}="$place.3.54.1.3.32.1.4.1" |
|---|
| 58 | eval getnext_1361412021255354133214${lastid}="$place.3.54.1.3.32.1.13.1" |
|---|
| 59 | eval getnext_13614120212553541332113${lastid}="$place.3.54.1.3.32.1.26.1" |
|---|
| 60 | eval getnext_13614120212553541332126${lastid}="$place.3.54.1.3.32.1.27.1" |
|---|
| 61 | eval getnext_13614120212553541332127${lastid}="NONE" |
|---|
| 62 | fi |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | LASTREFRESH=0 |
|---|
| 66 | |
|---|
| 67 | while read CMD |
|---|
| 68 | do |
|---|
| 69 | case "$CMD" in |
|---|
| 70 | PING) |
|---|
| 71 | echo PONG |
|---|
| 72 | continue |
|---|
| 73 | ;; |
|---|
| 74 | getnext) |
|---|
| 75 | read REQ |
|---|
| 76 | let REFRESH=$(date +%s)-$LASTREFRESH |
|---|
| 77 | if test $REFRESH -gt 30 |
|---|
| 78 | then |
|---|
| 79 | LASTREFRESH=$(date +%s) |
|---|
| 80 | refresh |
|---|
| 81 | fi |
|---|
| 82 | |
|---|
| 83 | oid=$(echo $REQ | tr -d .) |
|---|
| 84 | eval ret=\$getnext_${oid} |
|---|
| 85 | if test "x$ret" = "xNONE" |
|---|
| 86 | then |
|---|
| 87 | echo NONE |
|---|
| 88 | continue |
|---|
| 89 | fi |
|---|
| 90 | ;; |
|---|
| 91 | *) |
|---|
| 92 | read REQ |
|---|
| 93 | if test "x$REQ" = "x$place" |
|---|
| 94 | then |
|---|
| 95 | echo NONE |
|---|
| 96 | continue |
|---|
| 97 | else |
|---|
| 98 | ret=$REQ |
|---|
| 99 | fi |
|---|
| 100 | ;; |
|---|
| 101 | esac |
|---|
| 102 | |
|---|
| 103 | oid=$(echo $ret | tr -d .) |
|---|
| 104 | if eval test "x\$type_${oid}" != "x" |
|---|
| 105 | then |
|---|
| 106 | echo $ret |
|---|
| 107 | eval echo "\$type_${oid}" |
|---|
| 108 | eval echo "\$value_${oid}" |
|---|
| 109 | else |
|---|
| 110 | echo NONE |
|---|
| 111 | fi |
|---|
| 112 | |
|---|
| 113 | done |
|---|