Skip to content

Instantly share code, notes, and snippets.

@dlangille
Last active August 29, 2015 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlangille/cea9526ef3eb8ee3dfe8 to your computer and use it in GitHub Desktop.
Save dlangille/cea9526ef3eb8ee3dfe8 to your computer and use it in GitHub Desktop.
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