腳本1:測試
用於測試重啓後識別hostapd兩個進程,若是當前正常識別到兩個進程,則重啓設備,重複進行識別進程,知道進程識別有誤以後,會退出,往text.txt內寫入識別異常的時間spa
#!/bin/sh sleep 30 count=`ps | grep hostapd | grep -v grep | wc -l` #echo "sssss $count" if [ $count -eq 2 ];then echo "Now rebooting .................." reboot # echo "$date The wlan abnormal!!" > /text.txt fi echo "$date The wlan abnormal!!" > /text.txt
腳本2:rest
記錄一開始reload的時間,撥號成功後記錄時間從新reloadcode
判斷撥號成功的方法:獲取當前的ip地址的第一個數字,若是和1相等,則當前撥號成功orm
#!/bin/sh dial_time="" up_time="" function cellular_dial() { echo -e "enable\ncon t\ncellular reload" | vtysh sleep 10 } function wait_cellular_up() { dial_time=`cat /proc/uptime | awk '{print $1}' | cut -d '.' -f1` dial_date=`date` while [ 1 ] do test=`ifconfig cellular0 | grep Bcast | sed 's/^.*addr://g' | sed 's/Bcast.*$//g' | sed 's/\./ /g' | awk '{print $1}'` a=1 cellip=${test:0:1} if [ "$cellip" = "$a" ]; then break fi sleep 1 done up_time=`cat /proc/uptime | awk '{print $1}' | cut -d '.' -f1` up_date=`date` echo "$dial_date $up_date" } function print_up_duration() { duration_time=`expr $up_time - $dial_time` echo "cellular reload duration: $duration_time" } while : do cellular_dial wait_cellular_up print_up_duration done
腳本3:blog
用於在vtysh底下對當前的進程開關,若是有進程在,則關閉當前進程重啓hostapd進程後查看dmesg中是否有異常打印,有異常打印則跳出循環進程
將進程名做爲傳遞過來的一個參數來使用ip
運行的時候要在腳本後面帶上一個參數 爲./wlan.sh wlan0路由
#!/bin/sh rebootcount=1 echo $1 while [ 1 ] do wlancount=`ps | grep hostapd | grep -v grep | wc -l` if [ $wlancount -eq 1 ];then echo -e "en\ncon t\ninterface $1\nshutdown\nend\nwrite" | vtysh #echo -e "en\ncon t\ninterface p2p0\nshutdown\nend\nwrite" | vtysh echo "---------run restarthostapd count: $rebootcount" let rebootcount=rebootcount+1 echo -e "en\ncon t\ninterface $1\nno shutdown\nend\nwrite" | vtysh #echo -e "en\ncon t\ninterface p2p0\nno shutdown\nend\nwrite" | vtysh fi echo "=====start sleep====" sleep 40 echo "=====stop sleep====" flag_err=`dmesg | grep "hif_sdio_check_fw_reg: fw indication is 0x0." | wc -l` flag=`dmesg | grep "dump_backtrace" | wc -l` echo "===enter===:$flag" if [ $flag_err -gt 0 ] || [ $flag -gt 0 ];then echo ".....wifi error!!!!!!!!!!!!!!" break; fi done
腳本4:qt
找到某個進程而後殺掉當前進程,查看守護進程將其啓動後的 dmesg信息 是否會有報錯信息(kill -9 是發送一個強制殺掉進程的信號 )
#!/bin/sh rebootcount=1 while [ 1 ] do # wlanid=`ps | grep hostapd | grep -v grep | awk '{print $1}'` wlanid=`ps | grep "hostapd.conf.wlan0" | grep -v grep | awk '{print $1}'` p2p0id=`ps | grep "hostapd.conf.p2p0" | grep -v grep | awk '{print $1}'` wlancount=`ps | grep hostapd | grep -v grep | wc -l` if [ $wlancount -eq 2 ];then echo "--WlanPID--" echo $wlanid $p2p0id echo "--wlanCount--" echo $wlancount kill -9 $wlanid kill -9 $p2p0id rm /var/run/hostapd.p2p0 rm /var/run/hostapd.wlan0 echo "---------run reboot count: $rebootcount" let rebootcount=rebootcount+1 fi echo "=====start sleep====" sleep 50 echo "=====stop sleep====" flag_err=`dmesg | grep "hif_sdio_check_fw_reg: fw indication is 0x0." | wc -l` flag_err1=`dmesg | grep "dump_backtrace" | wc -l` if [ $flag_err -gt 0 || flag_err1 -gt 0 ];then echo ".....wifi error!!!!!!!!!!!!!!" break; fi done
查詢路由器當前蜂窩模塊溫度和CPU 溫度
#!/bin/sh while [ 1 ] do cat /sys/devices/virtual/thermal/thermal_zone0/temp vtysh -c enable -c "con t" -c "cellular send at "at+qtemp"" sleep 10 done
上面一個是查詢當前的CPU溫度 下面是查詢移遠的蜂窩模塊溫度
若是是查詢泰利特模塊溫度 則後面改爲 cellular send at "AT#TEMPMON=1"