Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Compare iocage jail version against the host - nagios check
#!/bin/sh
HOSTVERSION=`/usr/bin/file /bin/sh`
JAILS=`/usr/local/sbin/iocage list | /usr/bin/egrep -v '^JID' | /usr/bin/cut -f 2 -w`
ERRORS=''
for jail in ${JAILS}
do
JAILVERSION=`/usr/local/sbin/iocage chroot ${jail} 'file /bin/sh'`
if [ "${JAILVERSION}" != "${HOSTVERSION}" ]
then
ERRORS="jail '${jail}' is ${JAILVERSION} ${ERRORS}"
fi
done
if [ "${ERRORS}" == "" ]
then
echo 'All jails match the host'
exit 0
else
echo "WARNING: HOST and jails are NOT in sync: host = ${HOSTVERSION} but ${ERRORS}"
exit 2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.