Unable to send mail via Nagios

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
klpang
Posts: 1
Joined: Tue May 30, 2017 2:34 am

Unable to send mail via Nagios

Post by klpang »

Operating system name and version: : Fedora 15
Version of smsd: 3.1.14
Name and model of a modem / phone: Itegno w3800u
Interface: USB

Currently I'm working for sending alert notification (SMS) through Nagios 3.2.3 I have configured Nagios to send SMS using smstools3 but it doesn't send out any SMS.

Below is the config file
i) /usr/local/nagios/etc/objects/commands.cfg

define command{
command_name notify-host-by-sms
command_line /usr/local/bin/sendsms -d $CONTACTPAGER$ "** Nagios ** $NOTIFICATIONTYPE$ $HOSTACKCOMMENT$ $HOSTNAME$ is $HOSTSTATE$ Add: $HOSTADDRESS$ $SHORTDATETIME$"
}

# 'notify-service-by-sms' command definition
define command{
command_name notify-service-by-sms
command_line /usr/local/bin/sendsms -d $CONTACTPAGER$ "** Nagios ** $NOTIFICATIONTYPE$ $SERVICEACKCOMMENT$ Host: $HOSTNAME$ Alert: $SERVICEDESC$ is $SERVICESTATE$ Address: $HOSTADDRESS$ Info: $SERVICEOUTPUT$ $SHORTDATETIME$"
}

ii) /etc/smsd.conf
# Example smsd.conf. Read the manual for a description
devices = GSM1
logfile = /var/log/smsd/smsd.log
loglevel = 7
user = smstools
# 3.1.5 introduced smart logging
# once your configuration is OK, set log level lower (5 is good in most cases)
smart_logging = yes

[GSM1]
device = /dev/ttyUSB1
incoming = yes
#pin = 1111

Belos is folder permission
i) folder permission under /var/spool/sms
drwxr-xr-x 7 smstools smstools 4096 May 17 11:21 .
drwxr-xr-x. 17 root root 4096 May 11 10:12 ..
drwxr-x--- 2 smstools smstools 4096 May 30 13:27 checked
drwxr-x--- 2 smstools smstools 4096 Feb 9 2011 failed
drwxr-x--- 2 smstools smstools 4096 May 30 13:26 incoming
drwxrwxrwx 2 smstools nagios 2019328 May 30 16:29 outgoing
drwxr-x--- 2 smstools smstools 4096 Feb 9 2011 sent


ii) file permission under /var/spool/sms/outgoing
drwxrwxrwx 2 smstools nagios 2019328 May 30 16:31 .
drwxr-xr-x 7 smstools smstools 4096 May 17 11:21 ..
-rw------- 1 nagios nagios 89 May 30 13:39 send_0L3v2r
-rw------- 1 nagios nagios 98 May 30 13:39 send_2USLqL
-rw------- 1 nagios nagios 98 May 30 13:39 send_3M9YXw
-rw------- 1 nagios nagios 89 May 30 13:39 send_4xO19E
-rw------- 1 nagios nagios 98 May 30 13:39 send_cO1dRx
-rw------- 1 nagios nagios 89 May 30 13:39 send_ctLGpi
-rw------- 1 nagios nagios 98 May 30 13:39 send_DO7tHM
-rw------- 1 nagios nagios 89 May 30 13:39 send_gIgqsb

When compiling Nagios using /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg it shows no error. I can send SMS manually using sendsms command.

When nagios trigger notify-host-by-sms, the sms file format will use username (nagios) and group (nagios) to send sms out. But it smstools, it only allow username(smstools) and group(smstools) to send sms out. How to change file /folder permission to deliver sms succesfully in nagios.

Kindly advise.
User avatar
tacolover101
Posts: 432
Joined: Mon Apr 10, 2017 11:55 am

Re: Unable to send mail via Nagios

Post by tacolover101 »

I can send SMS manually using sendsms command.
show us how you're doing so.
When nagios trigger notify-host-by-sms, the sms file format will use username (nagios) and group (nagios) to send sms out. But it smstools, it only allow username(smstools) and group(smstools) to send sms out. How to change file /folder permission to deliver sms succesfully in nagios.
this is probably the issue then. your question may be asked better to whomever created smstools, as the notifications will attempt to send as the nagios user.

the other option, is perhaps using some sudo -u command to run-as the user 'smstools'.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Unable to send mail via Nagios

Post by tmcdonald »

Thanks for the assist, @tacolover101!
Former Nagios employee
Locked