Solaris10 Monitoring Script
Solaris10 Monitoring Script
/bin/sh
###################################################################################
# #
# Name : Siddhant Varshney #
#
# Purpose : Monitoring Sun Servers #
# Date : 10th Aug 2009 #
# #
# This script presents a menu of options and monitors for SVM, Filesystem status, #
# Filesystem Inodes status, syslog, Sun clusters, zones, zfs, prstat, zfs, lan, #
# IPMP, process stat, sar, and root mirror status. #
###################################################################################
saveterm=`stty -g`
stty intr ""
stty eof ""
stty susp ""
i=1
while [ $i != 0 ]
do
clear
echo
echo "${BOLD}\t\t\t DCO-Unix--Monitoring--\033[1;31;40m`hostname`\033[0m "
echo "${BOLD}"
echo "###########################################################################"
echo "##--------Monitor Script----------|------------Monitor Script------------##"
echo "## | ##"
echo "## 1. SVM(Hp Ux LVM) | 21. ZONES(Virtual OS's) ##"
echo "## 2. DF | 22. ZFS ##"
echo "## 3. SYSLOG & DMESG | 23. SMF(SERVICE MGMT FACILITY) ##"
echo "## 4. CLUSTER STATUS | 24. ROOT MIRROR STATUS ##"
echo "## 5. IPMP(Teaming) STATUS | 25. IO STATISTICS ##"
echo "## 6. LAN STATUS | 26. ##"
echo "## 7. CRON & AT STATUS | 27. ##"
echo "## 8. DATABASE STATUS | 28. ##"
echo "## 9. PRSTAT (TOP IN HP-UX) | 29. ##"
echo "## 10. SAR | 30. ##"
echo "## 11. VMSTAT | 31. ##"
echo "## | ##"
echo "## 0. EXIT ##"
echo "###########################################################################"
echo "${UNBOLD} "
echo "${BOLD}"
read choice
case $choice in
1)
#====================== Solaris Volume Manager ====================#
echo "If u want to check Metadevice(LVM's) Status Press [ms] or Metadatabase status
[md]\n"
read meta
if [ "$meta" = "ms" -o "$meta" = "MS" ]
then
METASVALUE=`/usr/sbin/metastat|egrep -i "Needs maintenance|Last erred|Unavailable"|
wc -l`
VALUE=`/usr/sbin/metaset |grep -i set|tr -s " "|cut -d " " -f4|tr "," " "`
for i in `echo $VALUE`
do
done
if test "$METASVALUE" -ne "0" -o "$METASVALUE2" -ne "0"
then
echo
echo
echo "\n!!! Volumes are Having a Problem Please update this Message to
Admin !!!"
else
echo
echo
echo "\n ****** Volumes are up to date ******"
fi
else
if [ "$meta" = "md" -o "$meta" = "MD" ]
then
METAVALUE=`/usr/sbin/metadb | tail +2 | grep [A-Zr]|wc -l`
if test "$METAVALUE" -ne "0"
then
echo
echo " \n!!! Metadatabase is having a Problem Please Update this Message to
Admin !!!"
else
echo "\n ****** All Metadatabase's Are up to date ******"
fi
else
echo
echo
echo "Please Enter Proper Option !!"
fi
fi
echo
echo " \n Please Press Enter Key ................"
read input
;;
2)
#============================ df(Disk Free) ================================#
3)
#=========================== SYSLOG =================================#
echo " PLS Select any one the following [ kn - ke - dn - de - dm - tail ]"
echo "kn -- > Kernal Notice"
echo "ke -- > Kernal Error "
echo "dn -- > Daemon Notice"
echo "de -- > Daemon Error "
echo "dm -- > dmesg "
kn="kernal.notice"
ke="kernal.error"
dn="daemon.notice"
de="daemon.error"
read sys
if test "$sys" = "tail" -o "$sys" = "TAIL"
then
echo " PLS Enter the Tail value"
read tailv
tail -$tailv /var/adm/messages | more
else
if test "$sys" = "kn" -o "$sys" = "KN"
then
grep -i $kn /var/adm/messages | more
else
if test "$sys" = "ke" -o "$sys" = "KE"
then
grep -i $ke /var/adm/messages | more
else
if test "$sys" = "dn" -o "$sys" = "DN"
then
grep -i $dn /var/adm/messages | more
else
if test "$sys" = "de" -o "$sys" = "DE"
then
grep -i $de /var/adm/messages | more
else
if test "$sys" = "dm" -o "$sys" = "DM"
then
dmesg | more
else
echo "\n\n **** Please Enter Proper Option !!! ****"
fi
fi
fi
fi
fi
fi
echo
echo " \n Please Press Enter Key ................"
read input
;;
4)
#=========================== Cluster Status ===============================#
CLUSTERSTATUS=`/usr/cluster/bin/scstat -g | grep "Group:"`
echo " Group Name(Pkg in HP-Ux) Node-Name State Suspended "
echo "$CLUSTERSTATUS"
echo
echo " \n Please Press Enter Key ................"
read input
;;
5)
#=========================== IPMP STATUS ==================================#
/usr/cluster/bin/scstat -i
echo
echo " \n Please Press Enter Key ................"
read input
;;
6)
#============================ LAN STATUS ==================================#
netstat -in
echo
echo " \n Please Press Enter Key ................"
read input
;;
7)
#============================ CRON STATUS ==================================#
8)
#============================ DATABASE STATUS ==============================#
9)
#============================ PRSTAT (TOP In HP-UX) ========================#
prstat -a
echo
echo " \n Please Press Enter Key ................"
read input
;;
10)
#================================= SAR =====================================#
echo " PLS Select any one the following [cpu - cpuq - buffer - freemem ]"
read sys
#echo " if You want Quit press Ctrl + c "
if test "$sys" = "cpu" -o "$sys" = "CPU"
then
sar -u 1 4
fi
if test "$sys" = "cpuq" -o "$sys" = "CPUQ"
then
sar -q 1 4
fi
if test "$sys" = "buffer" -o "$sys" = "BUFFER"
then
sar -b 1 4
fi
if test "$sys" = "freemem" -o "$sys" = "FREEMEM"
then
sar -r 1 4
else
echo " \n\nPlease Enter Proper Option ...... "
fi
echo
echo "Please Press Enter To Continue ......"
read input
;;
11)
#============================== VMSTAT =====================================#
#12)
#============================ LAST COMMAND =================================#
#read command
#if [ "$command" = "a" -o "$command" = "A" ]
#then
#/usr/bin/lastcomm | more
#else
#if [ "$command" = "u" -o "$command" = "U" ]
#then
#echo "Please Enter a Valid Name : "
#read name
#/usr/bin/lastcomm | grep -w "$name" | more
#else
# if [ "$command" = "md" -o "$command" = "MD" ]
# then
# echo " PLease Enter Month [Eg: January - jan/JAN, December - dec/DEC ]: "
# read month
# echo " Please Enter Date : "
# read date
# /usr/bin/lastcomm | grep -i "$month $date" | more
#else
# if [ "$command" = "nmd" -o "$command" = "NMD" ]
# then
# echo " Please Enter Valid Name : "
# read name
# echo " PLease Enter Month [Eg: January - jan/JAN, December - dec/DEC ]: "
# read month
# echo " Please Enter Date : "
# read date
# /usr/bin/lastcomm | grep -wi "$name" | grep -i "$month $date" | more
#else
# echo "Please Enter Proper Option !!!!!! :"
#fi
#fi
#fi
#fi
# echo
# echo " \n Please Press Enter Key ................"
# read input
#;;
21)
#=================================== ZONES ================================#
echo "\n\n All Zones (Global / Non-Global Zones) Information in `uname -n` \n"
/usr/sbin/zoneadm list -cv
echo
echo "\n Please Press Enter Key ................"
read input
;;
22)
#=================================== ZFS ==================================#
fi
fi
fi
fi
else
if test "$svalue" = "onl" -o "$svalue" = "ONL"
then
echo "All Enabled Services in `uname -n` \n "
/usr/bin/svcs -a | grep -i online | more
else
if test "$svalue" = "dis" -o "$svalue" = "DIS"
then
echo "All Disabled Services in `uname -n` \n "
/usr/bin/svcs -a | grep -i disabled | more
else
if test "$svalue" = "off" -o "$svalue" = "OFF"
then
echo "All OFFLINE Services in `uname -n` \n "
/usr/bin/svcs -a | grep -i "offline" | more
else
if test "$svalue" = "err" -o "$svalue" = "ERR"
then
echo "\nAll DEGRADED, UNINITIALIZED, MAINTENANCE Services in `uname -n` "
/usr/bin/svcs -a|egrep -i "UNINITIALIZED|DEGRADED|MAINTENANCE" | more
else
if test "$svalue" = "chk" -o "$svalue" = "CHK"
then
echo " \n Enter The Service Name To Check Status "
read sname
SNAME=`svcs -a | grep -i "$sname" |tr -s " "| cut -d "/" -f3|cut -d ":" -f1`
echo " $SNAME Status in `uname -n` is .... \n "
echo " STATE STIME FMRI "
/usr/bin/svcs -a | grep -i "$sname"
else
echo " \n Please Select a Correct option ...... "
fi
fi
fi
fi
fi
fi
;;
25)
;;
0)
clear
stty $saveterm
exit
break
;;
esac
echo "${UNBOLD}"
done
exit