Uncategorized

Unix Solaris Health check

#!/bin/sh
#this script is to perform health check to the system.

#########################
# Name:         Health Check Script                                             #
# Call:         Excecuting the script or cronjob Or By Run it Manually          #
# Purpose:      Perform Hardware Audit & Health check on the system to scan and exam            #
# Created:      2011-03-20/, Samer Odeh                               #
# Revised:      0                                                               #
##########################
#/usr/bin/clear
/usr/bin/echo “starting …”

# The Time and Date
TIME=`date ‘+20%y%m%d’`
HOST=`hostname`
OUTPUT_DIR=/tmp/
OUTPUT=$OUTPUT_DIR$HOST.$TIME.out
# Create Output File
/usr/bin/echo “Creating output file …”
/usr/bin/touch $OUTPUT
/usr/bin/echo “output file created … ”

/usr/bin/echo “############################Health Check############################” >> $OUTPUT

/usr/bin/hostname >> $OUTPUT
/usr/bin/echo “Uptime:” >> $OUTPUT
/usr/bin/uptime >> $OUTPUT
##checking Network:
/usr/bin/echo “Checking Network …”

/usr/bin/echo “##############################################################” >> $OUTPUT
/usr/bin/echo “Checking Network:” >> $OUTPUT
/usr/sbin/ifconfig -a >> $OUTPUT

##checking Disk space:
/usr/bin/echo “Checking Disk space …”

/usr/bin/echo “##############################################################” >> $OUTPUT
/usr/bin/echo “Checking Disks Capacity:” >> $OUTPUT
/usr/bin/df -kh >> $OUTPUT

/usr/bin/echo | format >> $OUTPUT

/usr/bin/echo “checking Processes status …”
/usr/bin/echo “##############################################################” >> $OUTPUT

/usr/bin/echo “Checking Processes:” >> $OUTPUT
/usr/bin/prstat -aR  1 2 >> $OUTPUT

/usr/bin/echo “##############################################################” >> $OUTPUT
/usr/bin/echo “Checking System messages …”
/usr/bin/echo “Checking System messages:” >> $OUTPUT
/usr/bin/dmesg | tail -20 >> $OUTPUT

/usr/bin/echo “##############################################################” >> $OUTPUT
/usr/bin/echo “Reporting  report virtual memory statistics …”
/usr/bin/echo “Reporting  report virtual memory statistics:” >> $OUTPUT
/usr/bin/vmstat 3 4 >> $OUTPUT
/usr/bin/echo “##############################################################” >> $OUTPUT

echo Reporting  report I/O statistics …
/usr/bin/echo “Reporting  report I/O statistics:” >> $OUTPUT
#/usr/bin/echo “Reporting I/O …”
/usr/bin/echo “Reporting I/O:” >> $OUTPUT
/usr/bin/iostat 4 3 >> $OUTPUT
/usr/bin/iostat -xPnce >> $OUTPUT
/usr/bin/echo “iostat -En:” >> $OUTPUT
/usr/bin/iostat -En| grep -i soft >> $OUTPUT
/usr/bin/echo “##############################################################” >> $OUTPUT
/usr/bin/echo “Reporting System Activities:” >> $OUTPUT
/usr/bin/sar 5 3 >> $OUTPUT
#/usr/bin/echo ” sar -d 3 5 Report activity for each block  device” >> $OUTPUT
#/usr/bin/echo ”           device        %busy   avque   r+w/s  blks/s  avwait  avserv” >> $OUTPUT
#/usr/bin/sar -d 3 5 >> $OUTPUT
/usr/bin/echo “kstat -m cpu_stat | egrep ‘user |idle |kernel |wait ‘ for Solaris 9 and earlier versions %wio won’t reported as 0” >> $OUTPUT
/usr/bin/date >> $OUTPUT
/usr/bin/kstat -m cpu_stat | egrep ‘user |idle |kernel |wait ‘ >> $OUTPUT
/usr/bin/sleep 10
/usr/bin/date >> $OUTPUT
/usr/bin/kstat -m cpu_stat | egrep ‘user |idle |kernel |wait ‘ >> $OUTPUT

/usr/bin/echo “##############################################################” >> $OUTPUT
/usr/bin/echo “report inter-process communication facilities status”
/usr/bin/echo “report inter-process communication facilities status ACTIVE Semaphores” >> $OUTPUT
/usr/bin/ipcs -s >> $OUTPUT
#/usr/bin/ipcs -mb>> $OUTPUT

/usr/bin/echo “##############################################################” >> $OUTPUT
/usr/bin/echo “Checking Swap Space …”
/usr/bin/echo “Checking Swap Space:” >> $OUTPUT
/usr/bin/echo “swap -l:” >> $OUTPUT
/usr/sbin/swap -l >> $OUTPUT
/usr/bin/echo “_______________________________________________” >> $OUTPUT
/usr/bin/echo “swap -s:” >> $OUTPUT
/usr/sbin/swap -s | nawk -F” ” ‘{print “used “$9 ” available ” $11 ” Free Memory: “substr(substr($11,1,8)/(substr($11,1,8)+substr($9,1,8))*100,1,5)”%” }’ >> $OUTPUT

/usr/bin/echo “##############################################################” >> $OUTPUT
/usr/bin/echo “Reporting  display status for metadevice or hot spare pool:” >> $OUTPUT
/usr/sbin/metadb >> $OUTPUT
/usr/bin/echo “Reporting  display status for metadevice or hot spare pool …”
/usr/sbin/metastat >> $OUTPUT

/usr/bin/echo “#################################################################################” >> $OUTPUT
/usr/bin/echo “” >> $OUTPUT
/usr/bin/echo “##############################################################” >> $OUTPUT
/usr/bin/echo “CPU / MEM Log and Overall Log Records:” >> $OUTPUT
/usr/bin/grep -i afsr /var/adm/me* >> $OUTPUT
/usr/bin/grep -i afar /var/adm/me* >> $OUTPUT
/usr/bin/grep -i error /var/adm/me*>> $OUTPUT
/usr/bin/grep -i fail /var/adm/me*>> $OUTPUT
/usr/bin/grep -i panic /var/adm/me*>> $OUTPUT
/usr/bin/grep -i scsi /var/adm/me*>> $OUTPUT

/usr/bin/echo “##############################################################” >> $OUTPUT
/usr/bin/echo “FCAL Disk and Loop Connection  Checkup:” >> $OUTPUT
/usr/sbin/luxadm probe >> $OUTPUT
/usr/sbin/luxadm -e port >> $OUTPUT
/usr/bin/echo “##############################################################” >> $OUTPUT
/usr/bin/echo “Reporting Crash Files:” >> $OUTPUT
/usr/bin/ls -lh /var/crash/`hostname`/ >> $OUTPUT
/usr/bin/echo “##############################################################” >> $OUTPUT

/usr/bin/echo “Reporting  Hardware issues:” >> $OUTPUT
/usr/platform/`uname -i`/sbin/prtdiag -v >> $OUTPUT
/usr/bin/echo “#################################################################################” >> $OUTPUT

/usr/bin/echo “script has been finished successfully …”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s