Welcome to It-Slav.Net blog
Peter Andersson

I've already got a female to worry about. Her name is the Enterprise.
-- Kirk, "The Corbomite Maneuver", stardate 1514.0

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.

  1. Have a working asterisk with connected phones
  2. 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$”‘
# 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

#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
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”

  1. Russ Says:

    Helllo, there..I have a question..Im using asterisk and nagios on the same machine..how can I set it up that way?

  2. peter Says:

    Then you can skip the ssh part and let nagios do it localy.

  3. michael Says:

    Thanks a lot, was exactly what I was looking for :-)))

Leave a Reply

Book reviews
FreePBX 2.5
Powerful Telephony Solutions

Asterisk 1.6
Build a feature rich telephony system with Asterisk

Learning NAGIOS 3.0

Cacti 0.8 Network Monitoring,
Monitor your network with ease!