Could somebody have a look at my configs and say what's wrong?
I'm trying to send a phone call via Asteriks and have a script to initiate call
Code: Select all
#!/bin/bash
#what state of host?
case "$1" in
OK)
;;
UNREACHABLE)
;;
DOWN)
case "$2" in
SOFT)
case "$3" in
1) touch checkfile.txt
;;
3)
case "$4" in
'sip:300@localhost')
sudo /usr/local/bin/linphonec -s sip:300@localhost
;;
'sip:200@localhost')
sudo /usr/local/bin/linphonec -s sip:200@localhost
;;
esac
;;
esac
;;
HARD)
;;
esac
;;
esac
exit 0
if I initiate this script from command line like ./asteriks-host-phone-call DOWN SOFT 3 sip:300@localhost - everything works, and I receive a call, I'm doing this under root account. That means for me - script itself has no errors.
This is host definition
Code: Select all
define host {
host_name test-condor-site
alias test-condor-site
address 172.16.37.44
check_command check-host-alive
max_check_attempts 4
check_interval 1
retry_interval 1
active_checks_enabled 1
check_period 24x7
contacts vassiliy,vassiliy-phone ;mike,mike-phone
#contact_groups admins
notification_interval 3
notification_period 24x7
notification_options d
notifications_enabled 1
event_handler asteriks-host-phone-call
event_handler_enabled 1
}
contacts definitions
vassiliy
Code: Select all
define contact {
contact_name vassiliy
alias vassiliy
contactgroups admins
host_notifications_enabled 1
service_notifications_enabled 1
host_notification_period 24x7;vassiliy-oncall
service_notification_period 24x7;vassiliy-oncall
host_notification_options d,u
service_notification_options w,c,r
host_notification_commands notify-host-by-email
service_notification_commands notify-service-by-email
email vvins@starscriber.com
can_submit_commands 1
}
Code: Select all
define contact {
contact_name vassiliy-phone
alias vassiliy-phone
contactgroups admins-phone
host_notifications_enabled 1
service_notifications_enabled 1
host_notification_period 24x7;vassiliy-oncall
service_notification_period 24x7;vassiliy-oncall
host_notification_options d
service_notification_options c
# host_notification_commands notify-host-by-phone
# service_notification_commands notify-service-by-phone
host_notification_commands asteriks-host-phone-call
service_notification_commands asteriks-service-phone-call
email sip:300@localhost
can_submit_commands 1
}
Code: Select all
## these are commands to make calls via asteriks , comment them if you don't need them
define command {
command_name asteriks-host-phone-call
command_line /usr/lib64/nagios/plugins/eventhandlers/asteriks-host-phone-call $HOSTSTATE$ $HOSTSTATETYPE$ $HOSTATTEMPT$ $CONTACTEMAIL$
}
define command {
command_name asteriks-service-phone-call
command_line $USER2$/asteriks-service-phone-call $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $CONTACTEMAIL$
}
define command {
command_name notify-host-by-phone
command_line sudo /usr/local/bin/linphonec -s $CONTACTEMAIL$ && sleep 30s && killall linphonec
}
define command {
command_name notify-service-by-phone
command_line sudo /usr/local/bin/linphonec -s $CONTACTMAIL$ && sleep 30s && killall linphonec
}
If I remove $CONTACTMAIL$ macros from commands.cfg for asteriks-host-phone-call and make corresponding changes in script - I get a call from Nagios
sudoers have these strings:
Code: Select all
nagios ALL=(ALL) NOPASSWD:/usr/lib64/nagios/plugins/eventhandlers/*
nagios ALL=(ALL) NOPASSWD:/usr/local/bin/linphonec
Defaults:nagios !requiretty
if you need more info - let me know