1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Script for graphing signal strength between AP and client

Discussion in 'HyperWRT Firmware' started by kubark42, Oct 11, 2004.

  1. kubark42

    kubark42 Network Guru Member

    You must first install rrdtool and update the /var/www/cgi/cpuinfo.cgi script inside the batbox tarball. Replace

    Code:
    wl assoclist  | cut -d' ' -f 2
    with

    Code:
    for MAC in `wl assoclist | cut -d ' ' -f 2` ; do echo -n $MAC ; echo -n '  ' ; wl rssi $MAC ; done
    After that, just save the following script into a directory somewhere. For example, I made /var/lib/rrd/rrd.d/ for all my rrd scripts. Don't forget to make it executable! (chmod 744)

    Code:
    #!/bin/bash
    # Script to extract MAC and rssi values from a Linkysys WRT54G 
    # that is running batbox.
    # This script requires rrdtool as a dependency.
    
    # List of WRT54Gs that you want to query
    WRT="10.0.0.1
    10.0.0.2
    10.0.0.4
    10.0.0.5
    10.0.0.6
    10.0.0.7"
    
    ############################
    # Default settings. Change these if you like.
    ############################
    DIR="/var/lib/rrd/linksys"
    STEP=60	#The amount of time in seconds between data points
    HEARTBEAT=90 #the time before a value is considered unknown
    echo "$HEARTBEAT"
    MIN=10	#The minimum anticipated value.  
    MAX=100 #The maximum anticipated value.
    ENTRY=1051200	#The number of entries the database can contain
    ###########################
    
    for AP in $WRT 
    do
    	if [[ ! -d $DIR/$AP ]] ; then
    		mkdir $DIR/$AP
    	fi
    	cd $DIR/$AP
    
    # Download the web page
    	wget -t 5 -nH --cut-dirs=1 -r $AP:8000/cgi-bin/cpuinfo.cgi
    
    # Parse the web page and create any new RRDs
    	for MAC in `grep rssi $DIR/$AP/cpuinfo.cgi |cut -d ' ' -f1`
    		do 
    		RSSI=`grep "$MAC" $DIR/$AP/cpuinfo.cgi|cut -d '-' -f2`
    		echo "**************** $MAC $RSSI"
    		if [[ ! -f $DIR/$AP/"$MAC".rrd ]] ; then
    			rrdtool create $DIR/$AP/"$MAC".rrd \
    					--start N --step $STEP \
    					DS:rssi:GAUGE:$HEARTBEAT:$MIN:$MAX \
    					RRA:LAST:0.5:1:$ENTRY
    
    # Pause for one second in order to avoid an 
    # input error related to newly formed RRDs.
    			sleep 1
    		fi
    # Update the RRD
    		rrdtool update $DIR/$AP/"$MAC".rrd N:$RSSI
    	done
    done
    
    
    After that, just throw it into crontab. Run it every minute.

    I use drraw to view my results. It's easy and intuitive. Just remember to graph the values as negative so that you see the true rssi.

    Feel free to update/critique. I have no idea how to make scripts efficiently, so I'm all ears. Kudos to Avenger for making all this possible.

    Kenn
     

Share This Page