Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 May 2005 01:11:01 -0700
From:      John-Mark Gurney <gurney_j@resnet.uoregon.edu>
To:        freebsd-scsi@FreeBSD.org
Subject:   daily scsi defect status...
Message-ID:  <20050518081101.GB6063@funkthat.com>

next in thread | raw e-mail | index | archive | help

--IJpNTDwzlM2Ie8A6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

I thought someone a while back had added scsi defect monitoring to our
periodic config, but upon upgrading one of my boxes, I found out that
no one had...

I no longer have any scsi disks, but could someone try out the attached
daily script?  Of course, you'll want to add the following lines to your
/etc/periodic.conf:
daily_status_scsi_disks_enable="YES"

In the normal case, you should just see:
SCSI Disk defect status:
da0:
da1:

and the files for these defects are in /var/backups if you want to
see the exact defects on your disks...

If the code works fine, I'll cordinate with the correct people to
commit it.

Thanks for testting it out.

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."

--IJpNTDwzlM2Ie8A6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="401.status-scsi-disks"

#!/bin/sh
#
# $FreeBSD: src/etc/periodic/daily/400.status-disks,v 1.6 2002/02/13 19:10:07 brian Exp $
#

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi

disk_unit_list() {
	camcontrol devlist | awk '
/da/ {
	if (match($0, "(da|sd)[[:digit:]]+") != 0) {
		diskname =  substr($0, RSTART, RLENGTH)
		match(diskname, "[[:digit:]]+")
		print substr(diskname, RSTART, RLENGTH)
	 }
}' | sort -u
}

case "$daily_status_scsi_disks_enable" in
    [Yy][Ee][Ss])
	echo ""
	echo "SCSI Disk defect status:"

	bak=/var/backups
	rc=0
	for i in `disk_unit_list()`; do
		old=${bak}/da${i}.glist.bak
		cur=${bak}/da${i}.glist
		if [ -f "$cur" ]; then
			mv "$cur" "$old"
		fi
		echo -n "da${i}: "
		camcontrol defects da$i -f phys -G 2>&1 > "$cur" || rc=1
		if [ -f "$old" ]; then
			if ! cmp -s "$cur" "$old"; then
				diff "$old" "$cur" || rc=2
			fi
		fi
	done

    *)  rc=0;;
esac

exit $rc

--IJpNTDwzlM2Ie8A6--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050518081101.GB6063>