Soalris10 Health Check

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

#!

/bin/sh

outputOK () {
echo $1 "[ OK ]"
}

outputW () {
echo $1 "[ Warning ]"
}

#Check filesystems mounted


# For ZFS, just list mounted filesystems
for fs in `zfs mount | awk '{ print $2 }'`
do
outputOK "Filesystem: $fs mounted"
done

# Show status of all mounts listed in vfstab


for vol in `/usr/xpg4/bin/grep -E 'vxfs|ufs|nfs|cifs' /etc/vfstab | egrep -v '^#' |
awk '{ print $3 }'`
do
if df -k $vol | grep $vol > /dev/null
then
outputOK "Filesystem: $vol mounted"
else outputW "Filesystem: $vol NOT MOUNTED"
fi
done

#Disksuite checks
if [ `metadb 2>&1 | grep 'no existing databases' | wc -l` != 1 ]
then
if [ `metadb 2>&1 | grep -v flags | grep -v a | wc -l` != 0 ]
then
outputW "Disksuite: Inactive metadb(s) found"
else
outputOK "Disksuite: All metadbs are active"
fi
else
outputOK "Disksuite: Not in use"
fi

if [ `metastat 2>&1 | grep 'no existing databases' | wc -l` != 1 ]


then
if [ `metastat 2>&1 | grep State: | egrep -v Okay | wc -l` != 0 ]
then
outputW "Disksuite: Metadevices are showing errors" ;
else
outputOK "Disksuite: All metadevices are in Okay state" ;
fi
fi

# Check multipathing working if SAN attached.


if [ `fcinfo hba-port|wc -l` != 1 ]
then
if [ `fcinfo hba-port|grep online|wc -l` != `fcinfo hba-port|grep State|wc -l` ]
then
outputW "SAN: Offline HBAs detected."
else
outputOK "SAN: All HBAs are online"
fi
else
outputOK "SAN: No HBAs found."
fi

# Need to update to handle .bak .orig, etc...


# Check interfaces are plumbed, up and full duplex.
for iface in `ls /etc/hostname.*|awk '{ FS=".";print $2 }'`
do
if dladm show-dev | grep $iface | grep up | grep full > /dev/null
then
outputOK "Network: $iface is up and full duplex"
else
outputW "Network: `dladm show-dev | grep $iface`"
fi
done

# Check for a default route


if netstat -rn|grep default > /dev/null
then
outputOK "Network: Default route found"
else
outputW "Network: Default route not found"
fi

# All services have started


if [ `svcs -xv|wc -l` != 0 ] ;
then
outputW "Services: There are offline services"
else
outputOK "Services: All services are online"
fi

if [ `inetadm|/usr/xpg4/bin/grep -vE 'online|disabled'|wc -l` != 1 ] ;


then
outputW "Services: There are offline Inet services"
else
outputOK "Services: All Inet services are online"
fi

#Check zones are online


if [ `zoneadm list -civ | wc -l` != 2 ]
then
if [ `zoneadm list -civ | grep -v ID | grep -v template | wc -l` != `zoneadm list
-civ | grep running | wc -l` ]
then
outputW "Zones: Not all local zones are running"
else
outputOK "Zones: All local zones are running"
fi
else
outputOK "Zones: No local zones detected"
fi

#Check size of mail queue


if [ `mailq | grep "requests: 0" | wc -l` != 1 ]
then
outputW "Sendmail: mail queue greater than zero"
else
outputOK "Sendmail: mail queue is empty"
fi

#Find locked user accts.


for user in `grep '*LK*' /etc/shadow | /usr/xpg4/bin/grep -vE 'listen|gdm|webservd|
nobody|noaccess|nobody4|uucp|lp|daemon|bin|nuucp'|awk '{ FS=":";print $1 }'`
do
outputW "User: Account $user is locked"

done

You might also like