zeldor.biz

Linux, programming and more

Copyright © 2025
Log in

Watchdog for ARM systems

April 26, 2020 by Igor Drobot Leave a Comment

Watchdog is responsible for monitoring tiny systems like raspberry PI, BeagleBone or any other system.
The main functionality of the watchdog is to check, if the system is still responding, lets say, to keep-alive messages.
Let’s assume, the system is stuck in a kernel panic, this will be automatically restarted by watchdog after reaching a grace time period. So a manual rebooting by unplugging the DC adapter is not required at all.

1. DIY – Do it yourself method

The DIY method don’t require installation of any additional system packages and can be realised in any scripting language.

Proof of concept – initialise the watchdog by running:

echo "." > /dev/watchdog

the system gets automatically restarted in 15 seconds if you don’t feed the watchdog or issue the interrupt statement by sending the V-character:

echo "V" > /dev/watchdog

This tiny script can be started with your system and will be responsible system monitoring

#!/usr/bin/env bash

# Activate watchdog and run periodically a keep-alive
while true; do
    echo "." > /dev/watchdog
    sleep 14
done

Or as a python version:

import time

watchdog = '/dev/watchdog'

while True:
    with open(watchdog, 'w+') as wf: wf.write('.')
    time.sleep(14)

2. Ready to go method

The second method is to install watchdog and configure it.

apt install watchdog

Configuration part is short /etc/watchdog.conf and can be filled out just by copy-paste:

max-load-1 = 24
min-memory = 1
watchdog-device = /dev/watchdog
watchdog-timeout = 15

Finally start and enable the watchdog:

systemctl start watchdog && systemctl enable watchdog

Get ready for any issue

Start a fork bomb to bring your system out of order to verify if your watchdog implementation works as expected :

: (  ){ : | : &  }; : 

Or simulate a kernel panic:

echo c > /proc/sysrq-trigger

Filed Under: Bash, Linux, Monitoring, Programming Tagged With: bash, Linux, Monitoring, Python, watchdog

Categories

Archives

Tags

apache2 Apple arduino ARM Automation backup bash Cisco Cluster Corosync Database Debian Debian squeeze DIY DNS Fedora FTP Fun Icinga Ipv6 KVM Linux LVM MAC OS X Monitoring MySQL Nagios Nginx openSUSE OpenVPN PHP Proxy Python python3 qemu RAID rsync Samba security ssh Ubuntu virtualization Windows Windows 7 Wordpress

Leave a Reply

Your email address will not be published. Required fields are marked *

Yeaaah Cookie! We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok