Last active
September 12, 2023 06:10
-
-
Save matsubo/2182530 to your computer and use it in GitHub Desktop.
Restart NEC router when NAT buffer pool is overflow.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Reboot NEC router if NAT errors are saved in router status page. | |
# - Checks VoIP status. | |
# - Run as daemon. | |
# - Encoding have to be Shift-JIS. | |
# | |
# @copytright Yuki Matsukura | |
# @contact https://matsu.teraren.com/blog/ | |
# | |
USER="admin" | |
PASSWORD="admin" | |
HOST="http://192.168.0.1" | |
echo "Starting." | |
while : | |
do | |
ERRORCOUNT=`wget -q -O - --user=$USER --password=$PASSWORD $HOST/log_main.html|grep ERROR | wc -l` | |
if [ $ERRORCOUNT -lt 10 ] | |
then | |
# echo `date` "Error not found" | |
sleep 5 | |
continue | |
fi | |
# check current tel connection | |
# 2:unused 0:in use | |
CONNECTION=`wget -q -O - --user=$USER --password=$PASSWORD $HOST/info_tel.html | grep '未通話' | wc -l` | |
if [ $CONNECTION -eq 0 ] | |
then | |
echo "Waiting for disconnecting the tel line." | |
sleep 1 | |
continue | |
fi | |
# Reset log to avoid double count | |
echo "Reset log" | |
wget -q -O - --user=$USER --password=$PASSWORD --post-data 'No00208010=&No004c0000=&No00F6D011&No00420000=%93o%98%5E' $HOST/log_main.html > /dev/null | |
# Reset the router | |
echo "Reboot" | |
wget -q -O - --user=$USER --password=$PASSWORD --post-data 'No00420011=reboot&No00420000=%93o%98%5E' $HOST/index_menu.html > /dev/null | |
# wait for the router is coming up | |
sleep 30 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
exec 2>&1 | |
exec sh -c 'exec envuidgid daemon softlimit -o10 ./router_restart.sh' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment