8 of 8
deleted 4 characters in body
Dagelf
  • 635
  • 5
  • 16

CentOS

yum install watchdog

On Ubuntu

apt-get install watchdog
#optional
#apt-get install das-watchdog

Then...

sudo vi /etc/watchdog.conf

Of course you should know that in VIM the colon (:) button opens the menu (or rather, command line) and w tells it to write your changes, or w! forces it to, and q quits. (Also that you can use the old ZX Spectrum cursor keys - hjkl to move around, the letter d to delete and i to insert, escape to stop inserting.)

Uncomment:

 watchdog-device = /dev/watchdog

See

 man watchdog.conf

For more... when you're done...

service watchdog restart

Yes, those processes are related to the watchdog, but unless they're configured properly, they're just sitting there doing nothing.

This should help you cope with unreliable power supplies turning random lock-ups into random reboots.

You can test it with

echo *todo* placeholder while I test how to test it, in case I reboot...

If it still doesn't work, you might have to sweat a little more and find out what driver your platform supports.

Personally, would try loading and testing each watchdog timer module individually, with something like this, run as root in the shell:

echo "Testing default... " | tee -a /var/log/watchdog-test.log; sync
service watchdog stop
echo Didn't work, we're still here... | tee -a /var/log/watchdog-test.log; sync
# If the default watchdog does work, I bet stopping the service disabled the default watchdog then... *todo* test and update this
echo Modules still loaded...
DOGS=`lsmod|grep -e wdt -e dog|cut -d\  -f1`
echo $DOGS
for dog in $DOGS; do
  echo Unloading $dog
  rmmod $dog || { echo "Oops.. didn't work, $dog won't unload"; sleep 70; };
done;
echo Did they all unload...? If not, I think the rest of this is a waste of time... reboot and skip that one next time
sleep 63
DOGS=`find /lib/modules|grep watchdog|awk -F'\watchdog/' '{print $2}'|sed [email protected]@@g|sort|uniq`
for dog in $DOGS; do 
   echo "Testing $dog... " | tee -a /var/log/watchdog-test.log; sync
   modprobe -v $dog && if [ -e /dev/watchdog ]; then
      dmesg|tail -5
      echo $dog Loaded. Ready for a reboot? | tee -a /var/log/watchdog-test.log; sync
      echo *todo* force a quicker timeout? *todo* read kernel source
      cat /dev/watchdog & test=$!
      sleep 0.5
      [ -e /proc/$test ] && { sleep 63; kill $test; };
  fi
  rmmod $dog
  echo $dog Didn't work, we're still here... | tee -a /var/log/watchdog-test.log; sync
done

If it just runs through, no delays... then none of the modules seemed to work. If your PC reboots, when it boots up:

tail -1 /var/log/watchdog-test.log

Will show a likely candidate... Now make sure your server loads it...

Ubuntu seems to use the module you note here:

sudo vi /etc/default/watchdog

I haven't tested this. If you do, come and update this answer. todo Here's a hint for SuSe: https://www.suse.com/support/kb/doc?id=7016880 and for Ubuntu: https://github.com/miniwark/miniwark-howtos/wiki/Hardware-Watchdog-Timer-setup-on-Ubuntu-12.04 http://odroid.com/dokuwiki/doku.php?id=en:odroid_linux_watchdog

Dagelf
  • 635
  • 5
  • 16