#!/bin/sh # List and log transmission errors # 01-10-04 Changed date format and line format # 01-11-04 Changed log format # 01-12-04 Changed file to .csv format # 01-18-04 Changed date format statsfile=/proc/net/hostap/wlan0/stats logfile=/usr/local/bin/errors.csv timestamp=$(date --iso-8601=minutes | cut -b 9-16) # YYYY-MM-DDThh:mm-0800 timestamp=$(echo $timestamp | sed s/"T"/" "/) # DD hh:mm echo let txoctets=$(grep "TxUnicastOctets" $statsfile \ | tr --delete "TxUnicastOctets=") let txerrors=$(grep "TxRetryLimitExceeded" $statsfile \ | tr --delete "TxRetryLimitExceeded=") let txratio=$txoctets/$txerrors let txratiodiv=$txratio/20 echo $timestamp "TX Octets:" $txoctets "TX errors:" $txerrors \ "TX error ratio:" $txratio let rxoctets=$(grep "RxUnicastOctets" $statsfile \ | tr --delete "RxUnicastOctets=") let rxerrors=$(grep "RxFCSErrors" $statsfile \ | tr --delete "RxFCSErrors=") let rxratio=$rxoctets/$rxerrors echo $timestamp "RX Octets:" $rxoctets "RX errors:" $rxerrors \ "RX error ratio:" $rxratio echo timestamp=$(echo $timestamp | sed s/" "/""/ | sed s/":"/""/) # DDhhmm if [ -e $logfile ] # If log file exists then echo $timestamp","$rxratio","$txratiodiv","$txratio","$rxerrors","\ $txerrors","$rxoctets","$txoctets >> $logfile else # New file - write spreadsheet header echo "DDhhmm,RX,TXD,TX,RXERR,TXERR,RXOCT,TXOCT" > $logfile echo $timestamp","$rxratio","$txratiodiv","$txratio","$rxerrors","\ $txerrors","$rxoctets","$txoctets >> $logfile fi