I want to send sms notification and I’m using these scripts:
I’m running CentOS 7 with Icinga2 version: 2.11.2-1
I have configured commands.conf, notifications.conf, templates.conf, users.conf and hosts.conf but when for example host is down I cannot receive SMS.
The error in log file is:
warning/PluginNotificationTask: Notification command for checkable ‘TEST HOST’ and notification ‘TEST HOST!Host Alarm By SMS’ (PID: 18873, arguments: ‘/etc/icinga2/scripts/host-by-sms.sh’ ‘-d’ ‘2020-01-10 17:17:44 -0500’ ‘-l’ ‘TEST HOST’ ‘-n’ ‘TEST HOST’ ‘-o’ ‘CRITICAL - Plugin timed out’ ‘-r’ ‘’ ‘-s’ ‘DOWN’ ‘-t’ ‘PROBLEM’) terminated with exit code 128, output: execvpe(/etc/icinga2/scripts/host-by-sms.sh) failed: Permission denied
object Host “TEST HOST2” {
import “generic-host”
vars.ping_wrta = “190, 5%”
vars.ping_crta = “230, 15%”
address = "ServerAddress
vars.os = “WebSites”
vars.notification[“pager”] = {
users = [ “icingaadmin” ]
}
}
Maybe my eyes are tired but I still not getting where I’m wrong, do you have any suggestions ?
Email notifications will work for sure.
About errors.
If I run this from command line with nagios user:
sudo -u nagios ./host-by-sms.sh \ -d ‘LONGDATE’ \ -l ‘HOSTALIAS’ \ -n ‘HOSTDISPLAYNAME’ \ -o ‘HOSTOUTPUT’ \ -r ‘+15142375458’ \ -s ‘HOSTSTATE’ \ -t ‘NOTIFICATIONTYPE’
I get error: sudo: unable to execute ./host-by-sms.sh: Permission denied
But if I run this from command line with icinga user:
sudo -u icinga ./host-by-sms.sh \ -d ‘LONGDATE’ \ -l ‘HOSTALIAS’ \ -n ‘HOSTDISPLAYNAME’ \ -o ‘HOSTOUTPUT’ \ -r ‘+15142375458’ \ -s ‘HOSTSTATE’ \ -t ‘NOTIFICATIONTYPE’
There is no error.
Thi is from Icinga2 log file when Host goes down, SMS not send and this is error:
warning/PluginNotificationTask: Notification command for checkable ‘TEST
HOST’ and notification ‘TEST HOST!Host Alarm By SMS’ (PID: 18873,
arguments: ‘/etc/icinga2/scripts/host-by-sms.sh’ ‘-d’ ‘2020-01-10 17:17:44
-0500’ ‘-l’ ‘TEST HOST’ ‘-n’ ‘TEST HOST’ ‘-o’ ‘CRITICAL - Plugin timed
out’ ‘-r’ ‘’ ‘-s’ ‘DOWN’ ‘-t’ ‘PROBLEM’) terminated with exit code 128,
output: execvpe(/etc/icinga2/scripts/host-by-sms.sh) failed: Permission
denied
In .conf files there is no need to call sudo, I attach that .conf files because maybe I have configured something wrong, this is my first time to trying SMS notification configuration.
If I run this from command line with nagios user:
sudo -u nagios ./host-by-sms.sh \ -d ‘LONGDATE’ \ -l ‘HOSTALIAS’ \ -n
‘HOSTDISPLAYNAME’ \ -o ‘HOSTOUTPUT’ \ -r ‘+15142375458’ \ -s ‘HOSTSTATE’
-t ‘NOTIFICATIONTYPE’ I get error: sudo: unable to execute
./host-by-sms.sh: Permission denied
What do you get for “grep nagios /etc/passwd”?
But if I run this from command line with icinga user:
sudo -u icinga ./host-by-sms.sh \ -d ‘LONGDATE’ \ -l ‘HOSTALIAS’ \ -n
‘HOSTDISPLAYNAME’ \ -o ‘HOSTOUTPUT’ \ -r ‘+15142375458’ \ -s ‘HOSTSTATE’
-t ‘NOTIFICATIONTYPE’ There is no error.
What do you get for “grep icinga /etc/passwd”?
Thi is from Icinga2 log file when Host goes down, SMS not send and this
is error: warning/PluginNotificationTask: Notification command for
checkable ‘TEST HOST’ and notification ‘TEST HOST!Host Alarm By SMS’ (PID:
18873,
arguments: ‘/etc/icinga2/scripts/host-by-sms.sh’ ‘-d’ ‘2020-01-10 17:17:44
-0500’ ‘-l’ ‘TEST HOST’ ‘-n’ ‘TEST HOST’ ‘-o’ ‘CRITICAL - Plugin timed
out’ ‘-r’ ‘’ ‘-s’ ‘DOWN’ ‘-t’ ‘PROBLEM’) terminated with exit code 128,
output: execvpe(/etc/icinga2/scripts/host-by-sms.sh) failed: Permission
denied
So, you;re saying that if you set up a notification by email, the script gets
run, but substituting that for host-by-sms.sh, it gives this error?
I’m getting as puzzled as you are now
In .conf files there is no need to call sudo,
Okay, I was confused by your original posting which showed an error message
from sudo - I thought that’s what was being output by the notification handler.
For: What do you get for “grep nagios /etc/passwd”?
nagios:x:996:993::/var/spool/nagios:/bin/bash
For: What do you get for “grep icinga /etc/passwd”?
icinga:x:997:995:icinga:/var/spool/icinga2:/bin/bash
So, you;re saying that if you set up a notification by email, the script gets
run, but substituting that for host-by-sms.sh, it gives this error?
Exactly