A simple way to check solaris IPMP network configuration and interface status.
#!/usr/bin/ksh
############################################
# Description: IPMP Auditing Script #
# This Script is designed to work “Solaris Env” #
# Author: Abdurrahim Yıldırım #
# For: Solaris Admins #
# Last Mod by: Abdurrahim Yıldırım #
# #
##############################################
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/fina