Tuesday, August 13, 2013

script to check Veritas dgname, available space in each dg and zone name of all vxfs mount points in Sun Servers

This script can be run from a centralized server on all the servers and will list the DG name, zone name and space available in each DG correspondig to all Veritas Mount Points available in server.


#!/usr/bin/ksh
#########################################################################################
#       Description:    Check space available to extend mount point and its             #
#                       corresponding DG name                                           #
#                       This Script is designed to work on Solaris 10 Global Zones      #
#                       Solaris 8 and Solaris 9 Only                                    #
#       Author:         Yogesh Aggarwal                                   #
#       Created:        2013-Aug-6                                                      #
#       Last Modified:  2013-Aug-6                                                      #
#       Last Mod by:    Yogesh Aggarwal                                                 #
#       Version:        1.1                                                             #
#                                                                                       #
#########################################################################################



PATH=/sbin:/usr/sbin:/usr/bin:/opt/VRTS/bin:/usr/local/bin ; export PATH


zn=`/sbin/zonename 2>/dev/null`
if [[ $zn == "global" ]] || [[ `uname -r` == 5.9 ]] || [[ `uname -r` == 5.8 ]]
then
{


rm -rf /var/tmp/DGSPACECHECK
mkdir -p /var/tmp/DGSPACECHECK


cat /etc/mnttab | grep vxfs > /var/tmp/DGSPACECHECK/vxfsfslist
cat /var/tmp/DGSPACECHECK/vxfsfslist | awk '{print $1}' > /var/tmp/DGSPACECHECK/vxfsdevicelist
cat /var/tmp/DGSPACECHECK/vxfsdevicelist | cut -d / -f5 > /var/tmp/DGSPACECHECK/vxfsdglist
for i in `cat /var/tmp/DGSPACECHECK/vxfsdglist`
do
size=`vxassist -g $i maxsize  2>/dev/null`
if [ $? -eq 0 ]
then echo "$size" | awk '{print $5}'>> /var/tmp/DGSPACECHECK/vxfsdgspacelist
else echo "No Space Left in DG" >> /var/tmp/DGSPACECHECK/vxfsdgspacelist
fi
done
cat /var/tmp/DGSPACECHECK/vxfsfslist | awk '{print $2}' > /var/tmp/DGSPACECHECK/vxfsmountlist


dgs=$(wc -l /var/tmp/DGSPACECHECK/vxfsdglist )
mounts=$(wc -l /var/tmp/DGSPACECHECK/vxfsmountlist)


for i in `cat /var/tmp/DGSPACECHECK/vxfsmountlist`; do echo $i| grep root > /dev/null
if [ $? -eq 0 ]
then echo $i |sed -e 's/root/:/g' | awk -F':' '{print $1}' | sed -e 's/\//\:/g' | awk -F':' '{print $3}'>> /var/tmp/DGSPACECHECK/zonename
echo $i |sed -e 's/root/:/g' | awk -F':' '{print $2}' >>  /var/tmp/DGSPACECHECK/mpname
else echo $i |sed -e 's/root/:/g' | awk -F':' '{print $1}' >> /var/tmp/DGSPACECHECK/mpname
echo "NA" >> /var/tmp/DGSPACECHECK/zonename
fi
done


###Final to get requried output in required format.

a=1 b=1 c=1 d=1
while [ $a -le $dgs -a $b -le $mounts ]; do
zone=`sed -n -e "${a}p" /var/tmp/DGSPACECHECK/zonename`
mount=`sed -n -e "${b}p" /var/tmp/DGSPACECHECK/mpname`
dg=`sed -n -e "${c}p" /var/tmp/DGSPACECHECK/vxfsdglist`
space=`sed -n -e "${d}p" /var/tmp/DGSPACECHECK/vxfsdgspacelist`
echo "`uname -n` \t $zone \t $mount \t $dg \t $space " >> /var/tmp/DGSPACECHECK/final
a=$(( a + 1 )); b=$(( b + 1)); c=$(( c + 1)); d=$(( d + 1));
done


### Print the final Output to screen.

}
else echo " This is neither a Global Zone, nor a Soalris 8 or 9 Server"
fi
cat /var/tmp/DGSPACECHECK/final

lpsched dying automatically again and again in Solaris

In case lpsched is dying again and again in Solaris, please check the logs in /var/spoo/lp/logs using below command.
# tail lpsched
received unexpected signal 11: terminating

If lpsched logs shows the above mentioned logs, please follow the below procedure to fix the issue:

## lpshut
Print services stopped.
## cd /var/spool/lp
## ps -ef | grep "lp -c" | awk '{print $2}' > /tmp/testy
## for i in `cat /tmp/testy`
> do
> kill -9 $i
> done
bash: kill: (21483) - No such process
##
## cd /var/spool/lp/tmp
## mv -r localhost/ /var/tmp/localhost.lp.tmp
## cd /var/spool/lp/requests
## mv -r localhost/ /var/tmp/localhost.lp.request 
## /usr/lib/lp/local/lpsched
Print services started.
##
## svcadm enable -r /application/print/server
##
## svcs -a | grep -i print
online 2012 svc:/application/print/ppd-cache-update:default
online 4:03:42 svc:/application/cde-printinfo:default
online 11:30:55 svc:/application/print/ipp-listener:default
online 11:30:55 svc:/application/print/server:default
online 11:30:55 svc:/application/print/rfc1179:default
##

## lpstat -lp lpd_chatpa-prt22
printer lpd_chatpa-prt22 now printing lpd_chatpa-prt22-15. enabled since Thu Apr 25 16:59:32 2013. available.
Form mounted:
Content types: application/octet-stream
Description:
Printer types: unknown
Connection: direct
Interface: /usr/lib/lp/model/netstandard
On fault: write root
After fault: continue
Users allowed:
(all)
Forms allowed:
(none)
Media supported:
(none)
Banner page never printed
Character sets:
(none)
Default pitch:
Default page size:
Default port setting:
Options: dest=3.8.90.37:9100, protocol=tcp
##
##
 

Script to test IPMP in Solaris Servers

Below script is to test the IPMP running status as well as configuration status on a Solaris Server. It will test below failure conditions
1. If each the NIC is under IPMP or not.
2. Running config and File config is same.
3. NIC Flag is running or not
4. Minimum two NICs are there in IPMP.
5. It will list the output in below columns:

Server Name > Zone Name > NIC NAME > IP Address > Netmask > Group >  Ether >  Success/Failure

#!/usr/bin/ksh
#########################################################################################
#       Description:    IPMP Auditing Script                                            #
#                       This Script is designed to work on Solaris 10 Global Zones      #
#                       Solaris 8 and Solaris 9 Only                                    #
#       Author:         Yogesh Aggarwal                                      #
#       For:            Solaris Admins                                          #
#       Created:        2012-June-27                                                    #
#       Last Modified:  23 July 2012                                                    #
#       Last Mod by:    Yogesh Aggarwal                                                 #
#       Version:        1.3                                                             #
#                                                                                       #
#########################################################################################



PATH=/sbin:/usr/sbin:/usr/bin:/opt/VRTS/bin:/usr/local/bin ; export PATH


zn=`/sbin/zonename 2>/dev/null`
if [[ $zn == "global" ]] || [[ `uname -r` == 5.9 ]] || [[ `uname -r` == 5.8 ]]
then
{


rm -rf /var/tmp/IPMPTEST
mkdir -p /var/tmp/IPMPTEST
/sbin/ifconfig -a | grep -v inet | grep -v zone | grep -v groupname | grep -v ether | awk '{print $1}' | grep -v lo0 > /var/tmp/IPMPTEST/tmp_nic
sed -e 's/:$//' /var/tmp/IPMPTEST/tmp_nic > /var/tmp/IPMPTEST/ifnics
cut -f1 -d : /var/tmp/IPMPTEST/ifnics > /var/tmp/IPMPTEST/nics


### To find out IPMP Group Information

for i in `cat /var/tmp/IPMPTEST/nics`
do
grp=`/sbin/ifconfig $i | grep groupname | awk '{print $2}'` ; count=`/sbin/ifconfig $i | grep groupname | awk '{print $2}' | wc -l`
if [ $count  -ne  0 ]
then echo "$grp" >> /var/tmp/IPMPTEST/ipmp_group
else echo "Null" >> /var/tmp/IPMPTEST/ipmp_group
fi
done


### To find out MAC Information

for i in `cat /var/tmp/IPMPTEST/nics`
do
ether=`/sbin/ifconfig $i | grep ether | awk '{print $2}'` ; count=`/sbin/ifconfig $i | grep ether | awk '{print $2}' | wc -l`
if [ $count  -ne  0 ]
then echo "$ether" >> /var/tmp/IPMPTEST/ether
else echo "Null" >> /var/tmp/IPMPTEST/ether
fi
done


for i in `cat /var/tmp/IPMPTEST/ifnics`
do
grptemp=`/sbin/ifconfig $i | grep groupname | awk '{print $2}'` ; count2=`/sbin/ifconfig $i | grep groupname | awk '{print $2}' | wc -l`
if [ $count2  -ne  0 ]
then echo "$grptemp" >> /var/tmp/IPMPTEST/ipmp_group_temp
else echo "Null" >> /var/tmp/IPMPTEST/ipmp_group_temp
fi
done


### To find out Zones Information

for ifnics in `cat /var/tmp/IPMPTEST/ifnics`
do
zone=`/sbin/ifconfig $ifnics | grep zone | awk '{print $2}'` count1=`/sbin/ifconfig $ifnics | grep zone | awk '{print $2}'| wc -l`
if [ $count1  -ne  0 ]
then echo "$zone" >> /var/tmp/IPMPTEST/zone
else echo "Null" >> /var/tmp/IPMPTEST/zone
fi
done


### To find out if NIC Flag is Running and IPMP Config file has same group name as Running Configuration.

groups=$(wc -l /var/tmp/IPMPTEST/ipmp_group )
NICS=$(wc -l /var/tmp/IPMPTEST/nics  )
k=1 m=1
while [ $k -le $groups -a $m -le $NICS ]; do
group=`sed -n -e "${k}p" /var/tmp/IPMPTEST/ipmp_group`
nic=`sed -n -e "${m}p" /var/tmp/IPMPTEST/nics`
count=`grep $group /etc/hostname.$nic 2>/dev/null | wc -l`
count1=`/sbin/ifconfig $nic | grep RUNNING | wc -l`
count3=`grep -w $group /var/tmp/IPMPTEST/ipmp_group_temp | grep -v Null | wc -l`
if [ $count1 -ge 1 ] && [ $count -ge 1 ] && [ $count3 -eq 2 ]
then
echo "Success" >> /var/tmp/IPMPTEST/check1
else
echo "Failure" >> /var/tmp/IPMPTEST/check1
fi
k=$(( k + 1 )); m=$(( m + 1));
done


### To find out IP Addresses against each NIC.

for ifnics in `cat /var/tmp/IPMPTEST/ifnics`
do
echo "$ifnics \t `/sbin/ifconfig $ifnics | grep inet | awk '{print $2}'` \t `/sbin/ifconfig $ifnics | grep inet | awk '{print $4}'`" >> /var/tmp/IPMPTEST/first
done


###Final to get requried output in required format.

a=1 b=1 c=1 d=1 e=1
while [ $a -le $groups -a $b -le $NICS ]; do
group1=`sed -n -e "${a}p" /var/tmp/IPMPTEST/ipmp_group`
check1=`sed -n -e "${b}p" /var/tmp/IPMPTEST/check1`
first=`sed -n -e "${c}p" /var/tmp/IPMPTEST/first`
zone=`sed -n -e "${d}p" /var/tmp/IPMPTEST/zone`
ether=`sed -n -e "${e}p" /var/tmp/IPMPTEST/ether`
echo "`uname -n` \t $zone \t $first \t $group1 \t $ether \t $check1 " >> /var/tmp/IPMPTEST/final
a=$(( a + 1 )); b=$(( b + 1)); c=$(( c + 1)); d=$(( d + 1)); e=$(( e + 1));
done


### Print the final Output to screen.

}
else echo " This is neither a Global Zone, nor a Soalris 8 or 9 Server"
fi
cat /var/tmp/IPMPTEST/final