+nagios-plugins-local (0.27) unstable; urgency=medium
+
+ * Add check_newaliases
+
+ -- Michael Howe <michael@michaelhowe.org> Sat, 23 Dec 2023 14:02:10 +0000
+
nagios-plugins-local (0.26) unstable; urgency=medium
* Remove check_running_kernel and associated overrides as the upstream
/usr/lib/nagios/plugins/check_configtool
/usr/lib/nagios/plugins/check_md_raid
/usr/lib/nagios/plugins/check_monit
+/usr/lib/nagios/plugins/check_newaliases
/usr/lib/nagios/plugins/check_iostat
/usr/lib/nagios/plugins/check_systemd
--- /dev/null
+#!/bin/bash
+#
+# Simple script to check that /etc/aliases.db is newer than /etc/aliases for
+# systems that require the db file to exist.
+#
+# Possibly a slight race condition if you deploy /etc/aliases and run
+# newaliases within the same second, but this is highly unlikely.
+
+set -e
+set -u
+
+NEWALIASES=/usr/bin/newaliases
+REQUIRED_TARGET=/usr/sbin/sendmail
+
+ALIAS_FILE=/etc/aliases
+ALIASDB_FILE=${ALIAS_FILE}.db
+
+TARGET=$(readlink -f $NEWALIASES)
+
+if [ "$TARGET" != "$REQUIRED_TARGET" ]; then
+ echo "ALIASES OK - Looks like we're not running postfix (newaliases points to ${TARGET})"
+ exit
+fi
+
+ALIAS_TS=$(stat --format %Y $ALIAS_FILE)
+ALIASDB_TS=$(stat --format %Y $ALIASDB_FILE)
+
+sec=$((ALIASDB_TS - ALIAS_TS))
+
+if [ $sec > 0 ]; then
+ echo "ALIASES OK - aliases.db is ${sec}s newer than aliases"
+else
+ echo "ALIASES CRITICAL - aliases.db is ${sec}s older than aliases"
+ exit 2
+fi