Advertisement
Guest User

Untitled

a guest
May 25th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.41 KB | None | 0 0
  1. #!/bin/ash
  2.  
  3. # hostname
  4. # should return ?host=hostname
  5.  
  6. UCISYSNAME=`uci show system.@system[0].hostname | sed -e 's/.*=//'`
  7. echo -n "?host=$UCISYSNAME"
  8.  
  9. # ping stats
  10. # should ping a host and return fping results with spaces replaced with _
  11. # should return &ping=
  12.  
  13. PINGSTATS=`fping -C 5 -q cobianet.com 2>&1 | sed 's/ /_/g'`
  14. echo -n "&ping=$PINGSTATS"
  15.  
  16. # wifi stations rssi
  17. # should return all associated stations for any athX interfaces, with MAC and DBM
  18. # example: &athif[ath0][00:15:6d:da:ee:11][DBM]=-82&athif[ath0][00:14:a4:61:74:21][DBM]=-90&athif[ath2][01:34:a4:15:6e:12][DBM]=-50
  19.  
  20. ATHINTERFACES=`cat /proc/net/wireless | grep ath | cut -d: -f1`
  21. ATHCOUNT=`echo $ATHINTERFACES | awk -F' ' '{ print NF }'`
  22.  
  23. c=1
  24.  
  25. while [ $c -le $ATHCOUNT ]
  26. do
  27.         CURRENTATHIF=`echo $ATHINTERFACES | awk '{ print $"'"$c"'"}'`
  28.  
  29.         CAISTA="`wlanconfig $CURRENTATHIF list sta | sed '1d' | sed ':a;N;$!ba;s/\n/;/g'`"
  30.         CAISTACOUNT=`wlanconfig $CURRENTATHIF list sta | sed '1d' | wc -l`
  31.         d=1
  32.  
  33.         while [ $d -le $CAISTACOUNT ]
  34.         do
  35.                 # get mac
  36.                 CURRENTMAC=`echo $CAISTA | cut -d';' -f"$d" | cut -d' ' -f1`
  37.  
  38.                 # print dbm
  39.                 echo -n "&athif[$CURRENTATHIF][$CURRENTMAC][DBM]="
  40.                 echo -n `echo $CAISTA | cut -d';' -f"$d" | cut -d' ' -f6`
  41.  
  42.                 d=$(( $d + 1 ))
  43.         done
  44.  
  45.  
  46.         c=$(( $c + 1 ))
  47. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement