Oct
Do you want to integrate your perfectly working op5 Monitor or Nagios installation with Asterisk?
I’ve configured op5 Monitor to call me when it detects a problem, to listen to an example click on link below:
The text below is op5 Monitor centric. op5 Monitor is based on Nagios so the principle is the same the only difference in this case is the possibility to test it from the op5 Monitor webconfig GUI.
Here is how I did it.
- Have a working asterisk with connected phones
- Create a notify script on the op5 Monitor Server or Nagios server
Add the following to misccommands.cfg
 # command ‘host-notify-call’
 define command{
 command_name                   host-notify-call
 command_line                   sudo -u monitor  /opt/monitor/op5/notify/call_asterisk_message.sh  ‘A\ message\ from\  Op5\ monitor.\ Host\ “$HOSTNAME$”\ is\ “$HOSTSTATE$”‘
 }
 and
 # command ‘service-notify-call’
 define command{
 command_name                   service-notify-call
 command_line                   sudo -u monitor  /opt/monitor/op5/notify/call_asterisk_message.sh ‘A\ message\ from\ Op5\  monitor.\ “$SERVICESTATE$”.\ Service\ “$SERVICEDESC$”
 \ on\ host\ “$HOSTNAME$”\ is\ $SERVICESTATE$’
 }
 
 Comment: sudo to monitor is probably unnecessary but I had som problems with ‘test this service’ in op5 Monitor webconfig GUI because it runs as apache and when the script is run when a problem occour it runs as monitor.
3. call_asterisk_message.sh
 
 ssh dull sudo /root/scripts/make_call3.sh $1
 
 i.e. run make_call3.sh with first argument, dull is my asterisk server.
4. On dull /root/scripts/make_call3.sh
 
 #!/bin/sh
 #Creates a phone call via asterisk to a certian number and reads a message
#By Peter Andersson, peter@it-slav.net
 echo “$1” | /usr/bin/text2wave -scale 1.5 -F 8000 -o /tmp/$$larm.wav
 echo “$1” >/tmp/$$larm.txt
 cat <<EOF > /tmp/$$monitorcall.call
 Channel: SIP/6000
 Callerid: Op5 Monitor
 MaxRetries: 5
 RetryTime: 60
 WaitTime: 60
 Application: Playback
 Data: /tmp/$$larm
 EOF
 mv /tmp/$$monitorcall.call /var/spool/asterisk/outgoing
 #rm /tmp/$$larm.wav
 echo “rm /tmp/$$larm.*” |at now + 1 day #Removes the wav and txt file tomorrow
 
 Comment: 6000 is the phonenumber to call, in my case a softphone.
And now it should work.
3 Responses to “Use Asterisk to call a number and read the errormessage from op5Monitor/Nagios”
Leave a Reply
You must be logged in to post a comment.
 
	



October 31st, 2009 at 4:11 pm
Helllo, there..I have a question..Im using asterisk and nagios on the same machine..how can I set it up that way?
Thanks
November 2nd, 2009 at 9:09 am
Then you can skip the ssh part and let nagios do it localy.
December 1st, 2011 at 8:34 pm
Thanks a lot, was exactly what I was looking for :-)))