123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #!/bin/bash
- source /etc/profile
- # 网络摄像头自检
- ip="$rtspip"
- date="`date '+%Y-%m-%d %H:%M:%S'`"
- lost_rate=`ping -c 8 -w 8 $ip | grep 'packet loss' \
- | awk -F'packet loss' '{ print $1 }' \
- | awk '{ print $NF }' | sed 's/%//g'`
- if [ ! -d "/opt/datas/log/network" ]; then
- mkdir -p /opt/datas/log/network
- fi
- if [ $lost_rate -eq 0 ]
- then
- echo "rtsp ok"
- ps -ef | grep "birdy" | grep -v "grep"
- if [ $? -eq 1 ]
- then
- echo "Rtsp服务恢复,重启服务! $date" >> /opt/datas/log/network/check_rtsp.log
- cd /opt/GSD/
- docker-compose up -d
- else
- echo "服务正常 $date" >> /opt/datas/log/network/check_rtsp.log
- fi
- elif [ $lost_rate -le 100 ]
- then
- echo "rtsp error"
- ps -ef | grep "birdy" | grep -v "grep"
- if [ $? -eq 1 ]
- then
- echo "rtsp服务异常,等待服务恢复 $date" >> /opt/datas/log/network/check_rtsp.log
- else
- cd /opt/GSD/
- docker-compose stop
- echo "rtsp摄像头异常,等待摄像头服务正常后重启服务! $date" >> /opt/datas/log/network/check_rtsp.log
- fi
- fi
|