Listing 3: Check disk script used by census
#!/bin/sh
#
# Copyright 1994, Lehman Brothers Inc.
#
# disk check used by census script
#
# Lehman Fixed Income Research naming conventions for Sybase partition search:
# There is a start script ~sybase/install/RUN_<Servername> for each
# dataserver on the host.
#
# There is a device list ${DbaHome}/files/<Servername>.device_list for
# each dataserver on the host.
#
# You will need to modify the script if your conventions differ.
#
SybHome=/usr/local/sybase
DbaHome=/export/home/dba
#
# Get file system and swap partitions
#
fsPart=`grep -v "^#" /etc/fstab | awk `$3=="4.2" {print $1}' `
swPart=`grep -v "^#" /etc/fstab | awk `$2=="swap" {print $1}' `
#
# Find sybase servers and associated partitions
#
if [ -d ${SybHome}/install ]; then
sybServers=`cd ${SybHome}/install; ls RUN_* 2>/dev/null|fgrep -v .star-
tup|sed -e "s/RUN_//"`
for serv in ${sybServers} ; do
if [ -f ${DbaHome}/files/${serv}.device_list ]; then
if [ -n "$sybPart" ]; then
sybPart="$sybPart `cat ${DbaHome}/files/${serv}.device_list`"
else
sybPart="`cat ${DbaHome}/files/${serv}.device_list`"
fi
fi
done
else
sybPart=""
fi
errorSeen=""
#
# Check file system partitions
#
for devPart in ${fsPart}; do
/bin/dd if=${devPart} of=/dev/null count=1 2> /dev/null
if [ $? -ne 0 ] ; then
errorSeen="${errorSeen}${devPart} "
fi
done
#
# Check swap partitions
#
if [ -n "$swPart" ]; then
for devPart in ${swPart}; do
/bin/dd if=${devPart} of=/dev/null count=1 2> /dev/null
if [ $? -ne 0 ] ; then
errorSeen="${errorSeen}${devPart} "
fi
done
fi
#
# Check Sybase partitions
#
if [ -n "$sybPart" ]; then
for devPart in ${sybPart}; do
/bin/dd if=${devPart} of=/dev/null count=1 2> /dev/null
if [ $? -ne 0 ] ; then
errorSeen="${errorSeen}${devPart} "
fi
done
fi
#
# Report results on stdout
#
if [ -n "$errorSeen" ]; then
echo "Disk errors: ${errorSeen}"
else
echo "All disks OK."
fi
|