Page 1 of 1

Creating A Custom Notification?

Posted: Mon Apr 16, 2018 5:17 am
by Sjwdavies
Hi there,

Firstly - what a great product. It's so powerful, I can't believe i've never deployed this solution in our business before!

My question is regarding custom notifications. We're based in the UK and I'd like certain members of the team to receive text notifications when an alert is generated. We use a service called FireText and they have a great API. I've written the script below and it's in place on the Server running NagiosXI, on CentOS 7:

(File location /usr/bin/notify-host-by-firetext.sh, file permissions 777)

Code: Select all

#!/bin/bash

type=$1
host=$2

curl "https://www.firetext.co.uk/api/sendsms?username=development@xxx&password=xxx&message=Type%3A%20${type}%0AHost%3A%20${host}&from=NagiosXI&to=07527552110" >> /var/log/firetext.log
echo "" >> /var/log/firetext.log
I've tested this from the command line and it indeed works and i receive a text message with the variables in it I pass to the script.

I've also created a NagiosXI custom command called ''notify-host-by-firetext', and added it to the Alert Settings for the nagiosadmin user (the only user I have for now):

Code: Select all

/usr/bin/notify-host-by-firetext.sh $NOTIFICATIONTYPE$ $HOSTNAME$ $HOSTSTATE$ $HOSTADDRESS$ $HOSTOUTPUT$
This command has been created as a 'Misc Command'.

The problem I have is that the above doesn't appear to be working. I can generate an outage, I receive the email notification, but not a text notification.

Do you know where i'm going wrong?

Re: Creating A Custom Notification?

Posted: Mon Apr 16, 2018 7:38 am
by scottwilkerson
When you tested it form the command line did you test it as the nagios user?

What are the permissions of this file? Is it writable by nagios?

Code: Select all

ls -al /var/log/firetext.log

Re: Creating A Custom Notification?

Posted: Mon Apr 16, 2018 8:30 am
by Sjwdavies
scottwilkerson wrote:When you tested it form the command line did you test it as the nagios user?

What are the permissions of this file? Is it writable by nagios?

Code: Select all

ls -al /var/log/firetext.log
Thanks, great questions. I tested it as root but it has 777 permissions...

Re: Creating A Custom Notification?

Posted: Mon Apr 16, 2018 8:34 am
by scottwilkerson
Can you test it as nagios

Code: Select all

sudo su nagios -c '/usr/bin/notify-host-by-firetext.sh arg arg arg ...'

Re: Creating A Custom Notification?

Posted: Mon Apr 16, 2018 8:59 am
by Sjwdavies
@scottwilkerson - I think you were right. I think it was a permissions issue on the log file.

I've got it working now.

Nagios is Amazing!

Re: Creating A Custom Notification?

Posted: Mon Apr 16, 2018 9:16 am
by scottwilkerson
Sjwdavies wrote:@scottwilkerson - I think you were right. I think it was a permissions issue on the log file.

I've got it working now.

Nagios is Amazing!
Excellent! Glad to hear it is sorted out.