Hi,
For Now I have to pass 5 command line arguments.
sh test.sh 0
tomcat bin /app/tomcat /app/tomcat/bin/logs
I need to implement the disk usage part in a loop instead of writing multiple times that part.
diskusage_value1=`du -k $4 | tail -1 | awk '{ print $1}'`
echo $diskusage_value1
if [ $diskusage_value1 -ge $THRESHOLD_VALUE ]; then
echo "Reached the Threshold limit for \"$4 ($diskusage_value1%)\" on `hostname` as on `date`" |
mailx -s "Alert: Almost out of diskspace for $4" $MAILER_LIST
fi
diskusage_value2=`du -k $5 | tail -1 | awk '{ print $1}'`
if [ $diskusage_value2 -ge $THRESHOLD_VALUE ]; then
echo "Reached the Threshold limit for \"$5 ($diskusage_value2%)\" on `hostname` as on `date`" |
mailx -s "Alert: Almost out of diskspace for $5" $MAILER_LIST
fi
This part should be in loop instead of writing two times.
for that I tried this one not able to get the results.
i=4
n=`expr $# + 1`
a='$'
while
test $i != $n
do
b=${a}$i
echo $b
diskusage_value1=`du -k $b | tail -1 | awk '{ print $1}'`
echo $diskusage_value1
if [ $diskusage_value1 -ge $THRESHOLD_VALUE ]; then
echo "Reached the Threshold limit for \"$4 ($diskusage_value1%)\" on `hostname` as on `date`" |
mailx -s "Alert: Almost out of diskspace for $4" $MAILER_LIST
fi
i=`expr $i + 1`
done
-----------------
diskusage_value1=`du -k $b | tail -1 | awk '{ print $1}'`
here $b becomes $4 not becoming $4value(/app/tomcat).
I think problem with this line b=${a}$i.
Please let me know how to solve this one.
Thanks,