#!/bin/sh
dsk='enterprises.ucdavis.dskTable.dskEntry.dskPercent'
path='enterprises.ucdavis.dskTable.dskEntry.dskPath'
cmd='/usr/bin/snmpwalk'
cmd1='/usr/bin/snmpget'
str='public enterprise'
d=$(date +%d)
m=$(date +%m)
dir='/home/mcli/diskmoninter'
for ip in `cat $dir/ipaddr`
do
$cmd $ip $str | grep dskPercent | grep
-v dskPercentNode >> $dir/$ip.tmp
$cmd $ip $str | grep dskPath >> $dir/$ip.tmp
id=`cat $dir/$ip.tmp | grep dskPercent |
grep -v dskPercentNode | cut -d"." -f6 | cut -d"=" -f1`
id1=`cat $dir/$ip.tmp | grep dskPath | cut -d"." -f6 |cut
-d"=" -f1`
for i in `echo $id`
do
for j in `echo $id1`
do
if [ $i = $j ] && [ $i -lt
8 ]; then
diskpath=`grep
"$path.$i " $dir/$ip.tmp | cut -d"=" -f2`
diskpercent=`grep
"$dsk.$i " $dir/$ip.tmp | cut -d"=" -f2`
if [ $diskpercent -gt 85 ]
; then
echo $ip >>
$dir/disk.$m$d
echo "Partition
$diskpath = %$diskpercent" >> $dir/disk.$m$d
fi
fi
done
done
rm -rf $dir/$ip.tmp
done
if [ -f $dir/disk.$m$d ] ; then
(
cat <<!
From: [email protected]
Subject: emon disk alert
To: [email protected]
!
echo `date`
echo 'The following host disk partition over %85'
cat $dir/disk.$m$d
) | /usr/sbin/sendmail -t
fi