daily scsi defect status...

John-Mark Gurney gurney_j at resnet.uoregon.edu
Wed May 18 01:11:03 PDT 2005


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."
-------------- next part --------------
#!/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


More information about the freebsd-scsi mailing list