From owner-freebsd-questions@FreeBSD.ORG Mon Oct 27 14:27:15 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DB90A654 for ; Mon, 27 Oct 2014 14:27:15 +0000 (UTC) Received: from mailint.univ-lr.fr (mailint.univ-lr.fr [193.49.30.36]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7CEDDDD4 for ; Mon, 27 Oct 2014 14:27:15 +0000 (UTC) Received: from [10.1.11.23] (soleil.univ-lr.fr [10.1.11.23]) (authenticated bits=0) by mailint.univ-lr.fr (8.14.4/8.14.4) with ESMTP id s9REMWbs021715 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Mon, 27 Oct 2014 15:22:32 +0100 Message-ID: <544E53F8.6030805@univ-lr.fr> Date: Mon, 27 Oct 2014 15:17:28 +0100 From: Olivier Sauzet User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: freebsd-questions@freebsd.org Subject: Nagios Check freebsd-update Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.97.6 at mail X-Virus-Status: Clean X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Oct 2014 14:27:15 -0000 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 --------------------------------------------------------------------