watchdog

最後更新: 2016-02-04

目錄

 

 


Kernel softdog

 

(V. 15.05)

Package:

kmod-softdog - 3.10.49-1 - Software watchdog driver

Install

opkg install kmod-softdog

安裝後會有 /etc/modules.d/50-softdog

Checking

ls -l /dev/watchdog

0 crw-r--r--    1 root     root       10, 130 Jan  1  1970 /dev/watchdog
0 crw-r--r--    1 root     root      254,   1 Feb  5 00:58 /dev/watchdog1          # <-- 真正的 dog

Usage

insmod /lib/modules/3.18.20/softdog.ko

watchdog -t 10 /dev/misc/watchdog

Checking

ps

xxx root 276 S watchdog -t 10 /dev/misc/watchdog

dmesg

Software Watchdog Timer: 0.05, timer margin: 60 sec

Auto start

watchdog starten per /etc/init.d/watchdog start, dauerhaft per watchdog enable

 


Atheros AR9330 HW watchdog

 

ls -l /dev/watchdog

     0 crw-r--r--    1 root     root       10, 130 Jan  1  1970 /dev/watchdog

 

# status

ubus call system watchdog

{
        "status": "running",
        "timeout": 21,
        "frequency": 5
}

# to stop watchdog:

ubus call system watchdog '{ "stop": true }'

# to start watchdog:

ubus call system watchdog '{ "stop": false }'

magicclose

In 2013 OpenWrt developers removed watchdog daemon and implemented watchdog feature into procd.

The biggest issue was that there was no mechanism to take control back from procd so that you can manually tickle or not tickle hardware watchdog.

ps | grep procd

    1 root      1388 S    /sbin/procd

If you just stop procd from tickling the hardware watchdog you still can't manually tickle watchdog

ubus call system watchdog '{"stop": true}'  

echo 1 > /dev/watchdog 

-ash: can't create /dev/watchdog: Device or resource busy

magicclose made procd release file lock of /dev/watchdog if watchdog feature in procd was stopped.

ubus call system watchdog '{"magicclose": true}'

 


Wireless watchdog

freifunk-watchdog - 8 - A watchdog daemon that monitors wireless interfaces to ensure the correct bssid and channel. The process will initiate a wireless restart as soon as it detects a bssid or channel mismatch.

 

 


Network watchdog script

 

mkdir /root/scripts/

vi  /root/scripts/wan-watchdog.sh

#!/bin/sh
# It is using busybox shell
# file: /root/scripts/wan-watchdog.sh
# cron jobs: */5 * * * * /root/scripts/wan-watchdog.sh

# script wait network interface up after reboot
sleep 120

# try 5, if 1 has response = success
tries=0
while [[ $tries -lt 5 ]]
do
    if /bin/ping -c 1 8.8.8.8 > /dev/null
    then
        touch /tmp/last_ping_success
        exit 0
    fi
    tries=$((tries+1))
done

# 2 選 1
/sbin/reboot
#/etc/init.d/network restart

chmod +x /root/scripts/wan-watchdog.sh

crontab -e

*/5 * * * * /root/scripts/wan-watchdog.sh

 

 

Creative Commons license icon Creative Commons license icon