bundlewrap/bundles/icinga2/files/check_by_sshmon
CroneKorkN 0684323cf3
feat(backup-freshness-check): wake the server and check once a day
The backup server sleeps most of the time, so the check was UNKNOWN.
check_by_sshmon now runs an optional wake command first; the freshness
check uses the wol-sleeper wake command, runs every 24h and retries
after 6h so a failure does not wake the server every 30s. nagios on
the icinga node may run the waker command as wol.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RywMtsL8qXG7GDY3MHq9Uh
2026-10-23 15:18:08 +02:00

42 lines
756 B
Bash

#!/bin/sh
UNKNOWN=3
if [ -z "$SSHMON_COMMAND" ]
then
echo 'check_by_sshmon: Env SSHMON_COMMAND missing' >&2
exit $UNKNOWN
elif [ -z "$SSHMON_HOST" ]
then
echo 'check_by_sshmon: Env SSHMON_HOST missing' >&2
exit $UNKNOWN
fi
if [ -z "$SSHMON_SUDO" ]
then
PREFIX=""
else
PREFIX="sudo "
fi
if [ -n "$SSHMON_WAKE" ] && ! sh -c "$SSHMON_WAKE" > /dev/null 2>&1
then
echo 'check_by_sshmon: Wakeup failed' >&2
exit $UNKNOWN
fi
ssh sshmon@"$SSHMON_HOST" "$PREFIX$SSHMON_COMMAND"
exitcode=$?
if [ "$exitcode" = 124 ]
then
echo 'check_by_sshmon: Timeout while running check remotely' >&2
exit $UNKNOWN
elif [ "$exitcode" = 255 ]
then
echo 'check_by_sshmon: SSH error' >&2
exit $UNKNOWN
else
exit $exitcode
fi