Monitor volumes and Aggregates using simple Script

 To run scripts from any Linux Server you have create a Password Less connection to Netapp Storage.


Then Create the Directories as mentioned below.

~]# mkdir -P /netapp/monitoring/


copy the below Script and Paste in one file. Save file with .sh Extension provide executable permissions to that file.

Replace 'YOUREMAILID' with your email address.

################## SCRIT START #################
#!/bin/bash

## Purpose: Calculate the Volume usage percentage as specified, If usage is more then specified send Mail
## Date: 21-08-2015
## Author: Ankam Ravi Kumar

ssh 192.168.1.5 df -h > /netapp/monitoring/volumes.txt
echo "Date: `date`" > /netapp/monitoring/temp.txt
echo "Below volumes usage is more then 95%" >> /netapp/monitoring/temp.txt
echo " " >> /netapp/monitoring/temp.txt
echo "Filer: NETAPP01" >> /netapp/monitoring/temp.txt
cat /netapp/monitoring/volumes.txt | awk ' length($5) > 2 && (substr($5,1,length($5)-1) >= 95)  { print $0  }' >> /netapp/monitoring/temp.txt
echo " " >> /netapp/monitoring/temp.txt
echo " " >> /netapp/monitoring/temp.txt
ssh 192.168.1.6 df -h > /netapp/monitoring/volumes1.txt
echo "Date: `date`" >> /netapp/monitoring/temp.txt
echo "Filer: NETAPP02" >> /netapp/monitoring/temp.txt
cat /netapp/monitoring/volumes1.txt | awk ' length($5) > 2 && (substr($5,1,length($5)-1) >= 95)  { print $0  }' >> /netapp/monitoring/temp.txt
echo " " >> /netapp/monitoring/temp.txt
echo "Below Aggregates Usage is more then 95%" >> /netapp/monitoring/temp.txt
echo "NETAPP01" >> /netapp/monitoring/temp.txt
ssh 192.168.1.5 df -Ah > /netapp/monitoring/aggr1.txt
cat /netapp/monitoring/aggr1.txt | awk ' length($5) > 2 && (substr($5,1,length($5)-1) >= 95)  { print $0  }' >> /netapp/monitoring/temp.txt

echo " " >> /netapp/monitoring/temp.txt
echo "NETAPP02 " >> /netapp/monitoring/temp.txt
ssh 192.168.1.6 df -Ah > /netapp/monitoring/aggr2.txt
cat /netapp/monitoring/aggr2.txt | awk ' length($5) > 2 && (substr($5,1,length($5)-1) >= 95)  { print $0  }' >> /netapp/monitoring/temp.txt

count=`cat /netapp/monitoring/temp.txt | wc -l`
if [ $count -gt 17 ]
then
mail -s "Volumes and Aggregates Usage more then 95%" YOUREMAILID < /netapp/monitoring/temp.txt
else
echo " " > /netapp/monitoring/temp.txt
fi

###################### END SCRIPT #############################


~]#chmod +x file-name.sh

Then Execute the file.

~]#sh file-name.sh

 Below is the Sample Out Mail



Schedule this script using crontab based on your requirement, Every 4 Hours as a example.

~]#crontab -e
* 04 * * * sh /PATH/file-name.sh

:wq

Enjoy ........... Waiting for your Comments

No comments:

Post a Comment