source: src/router/others/wl_snmpd_ath.sh @ 18331

Last change on this file since 18331 was 18331, checked in by BrainSlayer, 16 months ago

export interface name to snmp list

  • Property svn:executable set to *
File size: 3.3 KB
Line 
1#!/bin/sh
2
3place=".1.3.6.1.4.1.2021.255"
4
5refresh() {
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      getnext_13614120212553541332128="$place.3.54.1.3.32.1.28.1"
21    else
22      eval getnext_1361412021255354133211${lastid}="$place.3.54.1.3.32.1.1.$id"
23      eval getnext_1361412021255354133214${lastid}="$place.3.54.1.3.32.1.4.$id"
24      eval getnext_13614120212553541332113${lastid}="$place.3.54.1.3.32.1.13.$id"
25      eval getnext_13614120212553541332126${lastid}="$place.3.54.1.3.32.1.26.$id"
26      eval getnext_13614120212553541332127${lastid}="$place.3.54.1.3.32.1.27.$id"
27      eval getnext_13614120212553541332128${lastid}="$place.3.54.1.3.32.1.28.$id"
28    fi
29 
30    rssi=$(wl_atheros rssi $mac | cut -d" " -f3)
31    noise_reference=$(wl_atheros noise $mac | cut -d" " -f3)
32    uptime=$(wl_atheros uptime $mac | cut -d" " -f3)
33    ifname=$(wl_atheros ifname $mac | cut -d" " -f3)
34    if test $rssi -eq 0
35    then
36      snr=0
37    else
38      let snr=-1*$noise_reference+$rssi
39    fi
40    mac=$(echo $mac | tr : ' ')
41 
42    eval value_1361412021255354133211${id}=$id;
43    eval type_1361412021255354133211${id}='integer';
44    eval value_1361412021255354133214${id}='$mac';
45    eval type_1361412021255354133214${id}='octet';
46    eval value_13614120212553541332113${id}=$noise_reference;
47    eval type_13614120212553541332113${id}='integer';
48    eval value_13614120212553541332126${id}=$snr;
49    eval type_13614120212553541332126${id}='integer';
50    eval value_13614120212553541332127${id}=$uptime;
51    eval type_13614120212553541332127${id}='integer';
52    eval value_13614120212553541332128${id}=$ifname;
53    eval type_13614120212553541332128${id}='octet';
54
55    lastid=$id
56    let id=$id+1
57 
58  done
59
60  if test $lastid -ne 0
61  then
62    eval getnext_1361412021255354133211${lastid}="$place.3.54.1.3.32.1.4.1"
63    eval getnext_1361412021255354133214${lastid}="$place.3.54.1.3.32.1.13.1"
64    eval getnext_13614120212553541332113${lastid}="$place.3.54.1.3.32.1.26.1"
65    eval getnext_13614120212553541332126${lastid}="$place.3.54.1.3.32.1.27.1"
66    eval getnext_13614120212553541332127${lastid}="NONE"
67    eval getnext_13614120212553541332128${lastid}="NONE"
68  fi
69}
70
71LASTREFRESH=0
72
73while read CMD
74do
75  case "$CMD" in
76    PING)
77      echo PONG
78      continue
79      ;;
80    getnext)
81      read REQ
82      let REFRESH=$(date +%s)-$LASTREFRESH
83      if test $REFRESH -gt 30
84      then
85        LASTREFRESH=$(date +%s)
86        refresh
87      fi
88     
89      oid=$(echo $REQ | tr -d .)
90      eval ret=\$getnext_${oid}
91      if test "x$ret" = "xNONE"
92      then
93        echo NONE
94        continue
95      fi
96      ;;
97    *)
98      read REQ
99      if test "x$REQ" = "x$place"
100      then
101        echo NONE
102        continue
103      else
104        ret=$REQ
105      fi
106      ;;
107  esac
108
109  oid=$(echo $ret | tr -d .)
110  if eval test "x\$type_${oid}" != "x"
111  then
112    echo $ret
113    eval echo "\$type_${oid}"
114    eval echo "\$value_${oid}"
115  else
116    echo NONE
117  fi
118
119done
Note: See TracBrowser for help on using the repository browser.