OpenWrt Forum Archive

Topic: How to find the number of Wifi Client through SNMP ??!!

The content of this topic has been archived on 2 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi

Is there a way that I can configure net-snmp to give me the number of WiFi clients connected to the router (WRT54GL)?
Something like a script that can do "wl assoclist" or similar and give me the number through SNMP, or defining a OID that can do the same?

Any ideas or some one that needed the same thing?

I dunno how efficient this script is but I use this.

#!/bin/sh
wl assoclist | wc -l | sed 's/ //g'

Thank you for the reply, but the biggest problem is how to get this info with snmp?

snmpd.conf,

com2sec  ro  default    public
com2sec  rw  localhost  private

group  public   v1   ro
group  public   v2c  ro
group  public   usm  ro
group  private  v1   rw
group  private  v2c  rw
group  private  usm  rw

view  all  included  .1

access  public   ""  any  noauth  exact  all  none  none
access  private  ""  any  noauth  exact  all  all   all
exec wlrssi /etc/snmp/wlrssi
exec wlnoise /etc/snmp/wlnoise
exec wlrate /etc/snmp/wlrate
exec wlclients /etc/snmp/wlclients

wlrssi

#!/bin/sh
echo `wl rssi` | awk '{{ print $3 }}'

wlnoise

#!/bin/sh
echo `wl noise` | awk '{{ print $3 }}'

wlrate

#!/bin/sh
echo `wl rate` | awk '{{ print $3 }}'

wlclients

#!/bin/sh
wl assoclist | wc -l | sed 's/ //g'

scanscript

#!/usr/bin/awk -f
#
# REFERENTIAL CREDITS:
# A large portion of this code is identical to, or derived from
# Justin Jones's WRT scanner and this project would not have been
# possible without his public contribution.
# His code has been optimized [modified] extensively by FragtioN of
# www.jawug.za.net, specifically for the wireless comunity therein.
#
# TODO:
# - Once(if) signal for a node can no longer be obtined, that node will
#   be omitted from the list in the next display update to enable a more
#   'live' list which, in turn, will save some space in the display window,
#   as well as help avoid confusion... [suggested by: Setsquare]
#
# CHANGES:
# 19/01/2006
# - Credits 'optimizations'... [inspired by: Setsquare]
# 07/01/2006
# - Optimized the UI (everything nicely lined up now (I hope)).
# - Added SNR display; please report any bugs you may encounter with this addition.
# - General code optimizations and fixes to some bugs in Justin's code, namely:
#   - Fixed a problem that would cause Ad-Hoc networks to be displayed incorrectly.
#

BEGIN {
IGNORECASE = 1;
command = "wl scan 2> /dev/null ; wl scanresults 2> /dev/null";
red = "\x1b[31m";              green = "\x1b[32m";
greenback="\x1b[42m";          yellow = "\x1b[33m";
cyan = "\x1b[36m";             blue = "\x1b[34m";
blueback = "\x1b[44m";         white = "\x1b[37m";
whiteback = "\x1b[47m";        reset = "\x1b[0m";
underscore = "\x1b[4m";        clear = "\x1b[2J";
home = "\x1b[0;0H";            erase2end = "\x1b[K";
cName = white;                 cSignal = green;
cNoise = red;                  cCaps = green;
cRssi = green;
cSnr = yellow;
cChannel = white;
cType = white;
cStrengthLow = blue blueback;
cStrengthMed = white whiteback;
cStrengthHi = green greenback;
cStrengthAged = red;

print clear;
for( ;; )
{
  while (command|getline)
  {
  if(/^SSID/) { cn = $2 ; name[cn] = cn;  rssi[cn] = $6 ; noise[cn] = $9 }
  if(/^Mode/) {
    if(/Ad Hoc/) {
      rssi[cn] = $5 ; noise[cn] = $8 ; channel[cn] = $11
    }
    else {
      rssi[cn] = $4 ; noise[cn] = $7 ; channel[cn] = $10
    }
  }
  if(/^BSSID/) { caps[cn] = $4" "$5" "$6" "$7" "$8" "$9" "$10 }
  }
  close(command)
  printf home;
  ln = 0;
  print white "WRT awk wl Live Scanner v1.0b by FragtioN -- http://www.jawug.za.net/WRTScanScriptn";
  print white "SSID       RSSI  NOISE SNR   CHANNEL  TYPE";
  for (x in name)
  {
        {
        snr = (-1*(noise[x] - rssi[x]));
        sigstrength = ((rssi[x] - noise[x])*1.5) + ((rssi[x] +90)*1.5);
        if (sigstrength 4) cStrength = cStrengthMed;
        if(sigstrength>7) cStrength = cStrengthHi;
        if(age[x]=0) cStrength = cStrengthAged;

        fmt = "%s%-15s %s%0"sigstrength"d "reset erase2end "\n           %s%-4d  %s%-4d  %s%-4d  %s%2s       %s%10s "  reset erase2end "\n" erase2end "\n";
        printf fmt,cName,name[x],cStrength,0,cRssi,rssi[x],cNoise,noise[x],cSnr,snr,cChannel,channel[x],cType,caps[x];

        ln++;
        }
  }
  print erase2end;
}
}

Make your own templates for cacti, soz I cant find mine atm.

(Last edited by Setsquare on 20 May 2006, 16:24)

Excellent, Setsquare!!!
I have tried this exec wlclients /etc/snmp/wlclients in the snmpd.conf, but now the problem I have encounter is that I don't know what is the OID ? How to set the SNMP  agent to read this information?? sad

use snmpwalk in linux or use getif in windows

Yeap it is working smile

For future reference the OID to get this value from this script is 1.3.6.1.4.1.2021.8.1.101.1

Setsquare, I have looked at the scancript at your site, and it is very good and usefull. How can I find the opposite of that,  a wireless client table <MAC-Address Signal Noise  SNR Signal Quality> , that this is solved in the new DD-WRT SP1 firmware. So there must be a way in OpenWrt.

gile

Sorry cant help out there, I got the script from another site.

The discussion might have continued from here.