Good morning to you all
I�m kinda of a noob to scripting, and my knowledge is still very basic: anyway, I�ve developed a small .sh script with the following purpose:
- it will check a result file, checking if it has any values, or if it�s empty
- if it�s empty it will send an email
What i wanted to do, is eliminate the email part and generate some kind of snmp trap to be used for Nagios for instance, and create an alarm.
Does anybody know how to do that? Any help is apreciated. Thkx
Here goes the code:
##############################################
cat /var/www/monitor/scripts/TestProbes/probelist.txt | while read probe
do
if [[ -s /var/www/monitor/scripts/TestProbes/Probes/"$probe".txt ]] ; then
echo "Probe has data at $\(date \+%Y-%m-%d\) $\(date \+%H:%M:%S\)" > /var/www/monitor/scripts/TestProbes/results.txt
else
SUBJECT="No\\ Service\\ at\\ "$probe" "
EMAIL="XXXX@XXXX.com"
EMAILMESSAGE="mail"
echo "====================================================
A "$probe" ISN�T WORKING:"> $EMAILMESSAGE
echo "$(date -d "-3 hours" +%Y-%m-%d) $(date -d "-1 hours" +%H:%M:%S)
====================================================" >>$EMAILMESSAGE
su -c "/usr/bin/mail -s $SUBJECT $EMAIL < $EMAILMESSAGE" Probe_Tester
fi
rm /var/www/monitor/scripts/TestProbes/Probes/"$probe".txt
touch /var/www/monitor/scripts/TestProbes/Probes/"$probe".txt
chmod 777 /var/www/monitor/scripts/TestProbes/Probes/"$probe".txt
done
##############################################
---------- Post updated 10-07-09 at 04:31 AM ---------- Previous update was 10-06-09 at 06:21 AM ----------
Anyone?