脚本1:
用于测试重启后识别hostapd两个进程,如果当前正常识别到两个进程,则重启设备,重复进行识别进程,知道进程识别有误之后,会退出,往text.txt内写入识别异常的时间
#!/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:
记录一开始reload的时间,拨号成功后记录时间重新reload
判断拨号成功的方法:获取当前的ip地址的第一个数字,如果和1相等,则当前拨号成功
#!/bin/sh dial_time="" up_time="" function cellular_dial() { echo -e "enable con t cellular 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:
用于在vtysh底下对当前的进程开关,如果有进程在,则关闭当前进程重启hostapd进程后查看dmesg中是否有异常打印,有异常打印则跳出循环
将进程名作为传递过来的一个参数来使用
运行的时候要在脚本后面带上一个参数 为./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 con t interface $1 shutdown end write" | vtysh #echo -e "en con t interface p2p0 shutdown end write" | vtysh echo "---------run restarthostapd count: $rebootcount" let rebootcount=rebootcount+1 echo -e "en con t interface $1 no shutdown end write" | vtysh #echo -e "en con t interface p2p0 no shutdown end write" | 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:
找到某个进程然后杀掉当前进程,查看守护进程将其启动后的 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"
当前打印出来的温度 蜂窝模块的温度是在AT指令返回值的最后一个值 才会蜂窝模块的温度
温度到达极限值时 log中会打印出相关的内容 表示当前的温度已经超过一定的值
#177: read -1 bytes, vtysh(): vtysh_client_execute(): (104)Connection reset by peer
#185: vtysh err when write 'enable' to daemon zebra: 104(Connection reset by peer), nbytes -1!
Warning: closing connection to zebra because of an I/O error!