A PC watchdog timer is a device that resets the PC if a certain amount of time passes where the watchdog is not regularly kicked (i.e. usually this means the PC has crashed or is somehow locked up).
This is my Arduino PC watchdog project.
An extremely critical part of our home entertainment infrastructure is the mythtv recording server.
Although both linux and mythtv are pretty solid pieces of software, and can run fine unattended for months and months - once in a while some crash will occur and recordings will be missed until the mythtv backend service or the PC is restarted.
To keep track of the mythtv backend service and restart it if would hang, a shell script watchdogs runs as a cron job.
But in the rare event that the recording PC itself would hang (it has been observed once or twice within the past few years to great pain for the users) - I need a hardware watchdog to physically trigger the reset switch on the PC motherboard.
Make a PC watchdog using an Arduino board, and kick the watchdog over the serial connection using a small script on the linux PC.
I have written a small Arduino sketch, a watchdog script and upstart configuration file.
watchdog.pde watchdog sketch to load on the Arduino
watchdog.sh watchdog script to run on the computer
watchdog.conf configure upstart to automatically run the watchdog script when the system starts
Compile the sketch and upload it to the Arduino board. Connect the device to the internal USB connector on the PC motherboard.
PIN12 to the reset pins on the PC motherboard using an optocoupler diode.
On my PC the Arduino is located under
/dev/ttyACM0 - (you may need to edit the watchdog script)
To test the watchdog:
$ ./watchdog status 14/11/2011 15:05:38 Requesting status from watchdog timer device 14/11/2011 15:05:38 Disarmed: timeout in 179003 ms, Triggered reboots: 0, Longest tickle delay: 0 ms, Device boots: 1, Clock: 426742883
Some information is reported in the status output:
To arm the watchdog but without having a timeout result in an actual reset (press ^C to disarm).
The status LED on the Arduino should be on to indicate armed state (slightly dimmed to indicate 'fake' armed state)
$ ./watchdog fakearm 14/11/2011 15:08:54 FakeArming watchdog and emitting heartbeats . 14/11/2011 15:08:55 FakeArmed: timeout in 14796 ms, Triggered reboots: 0, Longest tickle delay: 0 ms, Device boots: 1, Clock: 426939705 .......^C14/11/2011 15:09:02 Disarming watchdog 14/11/2011 15:09:02 Disarmed, Triggered reboots: 0, Longest tickle delay: 1001 ms, Device boots: 1, Clock: 426947150
To arm the watchdog and have a timeout result in an actual reset (press ^C to disarm).
The status LED on the Arduino should be bright ON to indicate armed state
$ ./watchdog arm 14/11/2011 15:11:38 Arming watchdog and emitting heartbeats . 14/11/2011 15:11:39 Armed: timeout in 179796 ms, Triggered reboots: 0, Longest tickle delay: 1001 ms, Device boots: 1, Clock: 427103788 ............^C14/11/2011 15:11:52 Disarming watchdog 14/11/2011 15:11:52 Disarmed, Triggered reboots: 0, Longest tickle delay: 1001 ms, Device boots: 1, Clock: 427116661
To run watchdog script automatically as a service by upstart when the system is booted, copy the
watchdog.conf file to
/etc/init (remember to edit path to where the watchdog script is located).
The watchdog is automatically armed at system startup, and disarmed again when doing a shutdown.