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
#!/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
No comments:
Post a Comment