Date: Sun, 23 Jan 2011 18:35:13 +0100 From: Jilles Tjoelker <jilles@stack.nl> To: Josh Paetzel <jpaetzel@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r217755 - head/etc/periodic/daily Message-ID: <20110123173513.GB9898@stack.nl> In-Reply-To: <201101231713.p0NHDTvg062076@svn.freebsd.org> References: <201101231713.p0NHDTvg062076@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jan 23, 2011 at 05:13:29PM +0000, Josh Paetzel wrote: > Author: jpaetzel > Date: Sun Jan 23 17:13:29 2011 > New Revision: 217755 > URL: http://svn.freebsd.org/changeset/base/217755 > > Log: > This script parses output of userland tools. In the case of a faulted > zpool the output causes the script to bail out with syntax errors. > Since a scrub of a faulted zpool is pointless, just skip over any pools > marked as such. > > PR: conf/150228 > Submitted by: jpaetzel > Approved by: kib (mentor) > MFC after: 3 days > MFC note: only for RELENG_8 > > Modified: > head/etc/periodic/daily/800.scrub-zfs > > Modified: head/etc/periodic/daily/800.scrub-zfs > ============================================================================== > --- head/etc/periodic/daily/800.scrub-zfs Sun Jan 23 16:28:44 2011 (r217754) > +++ head/etc/periodic/daily/800.scrub-zfs Sun Jan 23 17:13:29 2011 (r217755) > @@ -24,13 +24,17 @@ case "$daily_scrub_zfs_enable" in > > for pool in ${daily_scrub_zfs_pools}; do > # sanity check > - zpool list ${pool} >/dev/null 2>&1 > + _status=$(zpool list ${pool} | sed -n -e '$p') > if [ $? -ne 0 ]; then > echo " WARNING: pool '${pool}' specified in" > echo " '/etc/periodic.conf:daily_scrub_zfs_pools'" > echo " does not exist" > continue > fi The above 'if' block never executes anymore now, since $? is sed's exit status which is always 0. Consider _status=$(zpool list "${pool}") if [ $? -ne 0 ]; then ... fi _status=${_status##*$newline} With somewhere at the top of the script newline=' ' # one newline and no other whitespace Note that this changed code will give the last non-empty line, while your sed code gives the last line even if it is empty. I think it does not make a difference. > + if echo ${_status} | grep -q FAULTED; then > + echo "Skipping faulted pool: ${pool}" > + continue > + fi Faster and more resilient to special characters: case ${_status} in *FAULTED*) echo "Skipping faulted pool: ${pool}" continue ;; esac > # successful only if there is at least one pool to scrub > rc=0 -- Jilles Tjoelker
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110123173513.GB9898>