I have a port monitoring script that monitors a port and alerts when it is down. I would like to send a string to a file to build a histogram.
Now I have:
netstat -Aan|grep 4446 1>/dev/null
RC=$?
echo RCb $RC
if [[ ${RC} -eq 1 ]]
then
# echo "Mailing"
mail -s "MIDAS Broker 4446 is unavailable" scrane@grhc.org</usr/local/scripts/broker_msg/broker4446_restart.txt
#mail -s "Production Broker 4446 is unavailable" scrane@grhc.org </usr/local/scripts/broker_msg/broker4446_restart.txt
date >> /usr/local/scripts/midis_histogram.txt
elif [[ ${RC} -eq 0 ]]
then
echo exiting
fi
exit 0
I would like the "date >> /usr/local/scripts/midis_histogram.txt" to get populated as follows:
# cat midis_histogram.txt
Thu May 10 09:15:06 MST 2012, UP
Thu May 10 09:17:17 MST 2012, DOWN
Thu May 10 09:20:00 MST 2012, UP
Thu May 10 09:30:05 MST 2012, UP
Now I have:
netstat -Aan|grep 4446 1>/dev/null
RC=$?
echo RCb $RC
if [[ ${RC} -eq 1 ]]
then
# echo "Mailing"
mail -s "MIDAS Broker 4446 is unavailable" scrane@grhc.org</usr/local/scripts/broker_msg/broker4446_restart.txt
#mail -s "Production Broker 4446 is unavailable" scrane@grhc.org </usr/local/scripts/broker_msg/broker4446_restart.txt
date >> /usr/local/scripts/midis_histogram.txt
elif [[ ${RC} -eq 0 ]]
then
echo exiting
fi
exit 0
I would like the "date >> /usr/local/scripts/midis_histogram.txt" to get populated as follows:
# cat midis_histogram.txt
Thu May 10 09:15:06 MST 2012, UP
Thu May 10 09:17:17 MST 2012, DOWN
Thu May 10 09:20:00 MST 2012, UP
Thu May 10 09:30:05 MST 2012, UP