Date: Mon, 27 Oct 2014 15:17:28 +0100 From: Olivier Sauzet <olivier.sauzet@univ-lr.fr> To: freebsd-questions@freebsd.org Subject: Nagios Check freebsd-update Message-ID: <544E53F8.6030805@univ-lr.fr>
next in thread | raw e-mail | index | archive | help
Hi, I started wroting a short checkfor "freebsd-update install" and if its necessary to reboot ... But whith p11 in freebsd10 my check are broken... Coul you tell me if its the right way for test if a rebbot is necessary... Thanks... #!/bin/sh # # Check if update are installed after a : freebsd-update fetch # and test if reboot is needed # KERN_VERS : kernel currently running # FILESYSTEM_VERS : print the version (and patch) of the new kernel # UPDATE_VERS : currently update version STATE_OK=0 STATE_WARNING=1 STATE_CRITICAL=2 KERN_VERS="$(uname -r | cut -d 'p' -f2 )" FILESYSTEM_VERS="$(freebsd-version -k |cut -d 'p' -f2)" UPDATE_VERS="$(cut -d '|' -f4 /var/db/freebsd-update/tag)" BASEDIR="/" BASE="/var/db/freebsd-update" cd $BASE # Construct a unique name from ${BASEDIR} BDHASH=`echo $BASEDIR | sha256 -q` if [ "$KERN_VERS" -ne "$UPDATE_VERS" ] || [ "$FILESYSTEM_VERS" -ne "$UPDATE_VERS" ] ;then if [ -f "$BASE/$BDHASH-install/INDEX-NEW" ];then kern_patch=$(grep -c 'kernel' $BASE/$BDHASH-install/INDEX-NEW) elif [ -f "$BASE/$BDHASH-rollback/INDEX-NEW" ];then kern_patch=$(grep -c 'kernel' $BASE/$BDHASH-rollback/INDEX-NEW) fi # Check that we have updates ready to install if [ -L ${BDHASH}-install ] && [ $kern_patch -ne 0 ]; then echo "Updates (p$UPDATE_VERS) are available to install, AND reboot are needed : Kern Pach = $kern_patch " && exit $STATE_WARNING elif [ -L ${BDHASH}-install ];then echo "Install update (p$UPDATE_VERS) by : freebsd-update install" && exit $STATE_WARNING elif [ -L ${BDHASH}-rollback ] && [ $kern_patch -ne 0 ];then echo "Reboot for apply Kern Patch: ($kern_patch patch), that install completely update (p$UPDATE_VERS) " && exit $STATE_WARNING fi else echo "OK - Systeme UpToDate" && exit $STATE_OK fi -- -------------------------------------------------------------------- Olivier S --------------------------------------------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?544E53F8.6030805>