0% found this document useful (0 votes)
28 views

Solaris10 Monitoring Script

This script presents a menu of options to monitor various aspects of Sun servers, including SVM/LVM status, filesystem status, syslog, clusters, zones, ZFS, process statistics, network activity, and more. It displays a menu and allows the user to select an option to check the status of that component and view the output.

Uploaded by

rittal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Solaris10 Monitoring Script

This script presents a menu of options to monitor various aspects of Sun servers, including SVM/LVM status, filesystem status, syslog, clusters, zones, ZFS, process statistics, network activity, and more. It displays a menu and allows the user to select an option to check the status of that component and view the output.

Uploaded by

rittal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 9

#!

/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 ""

#############################------ Menu Display ------############################

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

METASVALUE2=`/usr/sbin/metastat -s $i |egrep -i "error|Needs maintenance|Last


erred|Unavailable"|wc -l`

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) ================================#

echo "Filesystem size used avail capacity Mounted-on"


df -h | egrep "tmp|dsk"
echo
echo
df -F ufs -o i
echo
echo " \n Please Press Enter Key ................"
read input
;;

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 ==================================#

echo "\n Cron Jobs in `uname -n`\n"


echo " UID PID PPID C STIME TTY TIME CMD/SCRIPT"
ps -ef | grep -i cron | grep -v grep
NUCRON=`ps -ef | grep -i cron | grep -v grep | wc -l`
echo "\n\n"$NUCRON" Cron Job(s) are Running in `uname -n`"
#echo "\n AT Jobs in `uname -n`"
#sudo su /usr/bin/atq
echo
echo " \n Please Press Enter Key ................"
read input
;;

8)
#============================ DATABASE STATUS ==============================#

ps -ef | grep -i sybase_monitor | grep -v grep


ps -ef | grep -i pmon | grep -v grep
echo
echo " \n Please Press Enter Key ................"
read input
;;

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 =====================================#

echo "\033[1;32;40m Vmstat output \033[0m"


/usr/bin/vmstat
echo "\033[1;32;40m Vmstat Paging output format \033[0m "
/usr/bin/vmstat -p
echo "\033[1;32;40m Display various system events Since Boot \033[0m "
/usr/bin/vmstat -s
echo "\033[1;32;40m Swap info \033[0m "
/usr/sbin/swap -s
echo
echo " \n Please Press Enter Key ................"
read input
;;

#12)
#============================ LAST COMMAND =================================#

#echo "\t******** Display Commands which are executed by Users ********\t"


#echo " \n Please Select Any one of these Option (a | na | dt | nt) !\n"
#echo " a -> Print All Commands which are executed by all users \n"
#echo " u -> Print All Commands which is executed by one user \n"
#echo " md -> Print All Commands Based on Month and Date \n"
#echo " nmd -> Print All Commands Based on Name, Month and Date \n"

#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 ==================================#

echo "\n\n Please Select Any Following Option to Continue*** \n "


echo "ps ---> ZFS Pool Status \n"
echo "pz ---> ZFS Pool Size \n"
echo "pi ---> ZFS Pool IO Statistics \n"
echo "fl ---> ZFS Datasets list( ZFS Filesystems info ) \n"
read value
if test "$value" = "ps" -o "value" = "PS"
then
echo " \n ******* ZFS Pool Status ******* \n"
/usr/sbin/zpool status
else

if test "$value" = "pz" -o "value" = "PZ"


then
echo " \n ******* ZFS Pool Size ******* \n"
/usr/sbin/zpool list
else

if test "$value" = "pi" -o "value" = "PI"


then
echo " \n ******* ZFS Pool IO Statistics ******* \n "
/usr/sbin/zpool iostat -v 1 3
else

if test "$value" = "fl" -o "value" = "FL"


then
echo " \n ******* ZFS Datasets Information ******* \n "
/usr/sbin/zfs list
else
echo " \n PLease Select Correct Option \n "

fi
fi
fi
fi

echo "\n Please Press Enter Key ................"


read input
;;
23)
#=========================== SMF (Service Mgmt Facility) ==================#

echo "\n\n Service Management Facility \n\n "


echo "Please Select an Option to Continue ... \n"
echo " all ---> List All Services "
echo " onl ---> List All Online Services "
echo " dis ---> List All Disabled Services "
echo " off ---> List All Offline Services "
echo " err ---> List All DEGRADED MAINTENANCE UNINITIALIZED Services "
echo " chk ---> Check a Particular Service Status "
read svalue

if test "$svalue" = "all" -o "$svalue" = "ALL"


then
echo "All Services Including Legacy Runlevel in `uname -n` \n"
/usr/bin/svcs -a | more

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

echo "\n Please Press Enter Key ................"


read input
;;
24)

#=========================== Root Mirror Status ===========================#

VOLUMES=`awk '/dsk/ {print $1}' /etc/vfstab|egrep -v "#"|grep "/dev/md/dsk"`


STATUS=`/usr/sbin/metastat $VOLUMES|grep "State:"|grep -v "Okay";echo $?`
NMIRRORS=`/usr/sbin/metastat -p $VOLUMES|grep -c "\-m"`
NSMIRRORS=`/usr/sbin/metastat -p $VOLUMES|grep -cv "\-m"`
MIRRORVALUE=`echo $NMIRRORS \* 2 | bc`
if test "$STATUS" -eq "0" -o "$MIRRORVALUE" -ne "$NSMIRRORS"
then
echo " \n****** Root Mirror Status is Not Okay PLease Update it to Admin
****** "
else
echo " \n ****** Root Mirror Status is OK ****** "
fi
echo "\n Please Press Enter Key ................"
read input

;;
25)

#echo " extended device statistics "


#echo "r/i w/i kr/i kw/i wait actv wsvc_t asvc_t %w %b device"
#/usr/bin/iostat -xnI 1 5 |grep "c[0-9]t[0-9]d[0-9]*"
iostat -cmnxz 1 3|egrep "c[0-9]t[0-9]d[0-9]*|device"

echo "\n Please Press Enter Key ................"


read input

;;
0)
clear
stty $saveterm
exit
break
;;
esac
echo "${UNBOLD}"
done
exit

You might also like