Skip to content
Snippets Groups Projects
Commit fa6d0337 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

Watchdog for unbound

With extra check to see if it actually resolves.
parent d712a07d
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
#!/bin/busybox ash
# Copyright (c) 2013-2014, CZ.NIC, z.s.p.o. (http://www.nic.cz/)
# All rights reserved.
......@@ -28,7 +28,7 @@
set -ex
# Configuration
SERVICES="ucollect"
SERVICES="ucollect unbound"
if [ -e '/etc/init.d/nethist' ] ; then
SERVICES="$SERVICES nethist"
fi
......@@ -45,8 +45,14 @@ for SERVICE in $SERVICES ; do
# Get the claimed PID of the service
PID=`cat /var/run/"$SERVICE".pid || echo 'No such PID available'`
FILE=/tmp/watchdog-"$SERVICE"-missing
EXTRA=true # In case unbound is running but not working, try to reset it
if [ "$SERVICE" = "unbound" ] ; then
if ! ping -c 2 turris.cz ; then
EXTRA=false
fi
fi
# Look if there's a process with such name and PID in as reliable way as shell allows
if grep "^$PID " "$TEMPFILE" | sed -e 's/^[^ ]*//' | grep "$SERVICE">/dev/null ; then
if grep "^$PID " "$TEMPFILE" | sed -e 's/^[^ ]*//' | grep "$SERVICE">/dev/null && $EXTRA ; then
# It runs. Remove any possible missing note from previous run.
rm -f "$FILE"
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment