Page 1 of 1
Auto Acknowlediments
Posted: Tue Mar 12, 2019 2:19 pm
by benhank
So I have been trying to get auto acknowledgements on service alerts working but cant figure out what I am doing wrong.
my goal is to have have nagios shoot out an email as well as automagically ackowledge a service when it enters a soft or hard down state.
I am trying to set up a scripted event handler that will be associated with service templates that have been associated to my hostgroups.
I have created this script:
Code: Select all
#!/bin/sh
# This is a sample shell script showing how you can submit the ACKNOWLEDGE_SVC_PROBLEM command
# to Nagios. Adjust variables to fit your environment as necessary.
host=$1
service=$2
now=`date +%s`
commandfile= '/usr/local/nagios/var/rw/nagios.cmd'
/bin/printf "[%lu] ACKNOWLEDGE_SVC_PROBLEM;host1;service2;1;1;1;bhankers;this issue has been automatically acknowedged by NagiosXi\n" $now > $commandfile
Command:
capture1.PNG
Service:
Capture3.PNG
Service:
Capture2.PNG
And associated it with my host, but Nagios doesn't acknowledge it.
What am I missing?
Re: Auto Acknowlediments
Posted: Tue Mar 12, 2019 2:40 pm
by npolovenko
Hello,
@benhank. Are you able to manually execute the acknowledgment.sh script from the command line with arguments and get a service acknowledged in the GUI?
/usr/local/nagios/libexec/acknowledgment.sh host service
*Replace "host" with the host name and replace "service" with the service name.
Re: Auto Acknowlediments
Posted: Tue Mar 12, 2019 2:58 pm
by benhank
thats a no :
Code: Select all
[root@lkennagiost01 ~]# /usr/local/nagios/libexec/auto_acknowledgement.sh 172.22.191.190
-bash: /usr/local/nagios/libexec/auto_acknowledgement.sh: /bin/sh^M: bad interpreter: No such file or directory
[root@lkennagiost01 ~]#
I think its having an issue with:
Code: Select all
commandfile= '/usr/local/nagios/var/rw/nagios.cmd'
and after looking into that directory it gets freaky.
nagios.cmd is not in that dir on my test server
On my secondary server only nagios.qh is in that dir and
on my production server nagios.qh and nagios.cmd is there.
lol
three different servers with three different contents in the same directory...SAYYY WHAT!
Re: Auto Acknowlediments
Posted: Tue Mar 12, 2019 3:05 pm
by npolovenko
@benhank, Here's how to fix this:
[root@lkennagiost01 ~]# /usr/local/nagios/libexec/auto_acknowledgement.sh 172.22.191.190
-bash: /usr/local/nagios/libexec/auto_acknowledgement.sh: /bin/sh^M: bad interpreter: No such file or directory
Open your script with VI, hit escape and type this:
:set fileformat=unix
Save the file and exit:
:wq!
nagios.cmd is not in that dir on my test server
Can you check where it is?
find / -name nagios.cmd
Re: Auto Acknowlediments
Posted: Tue Mar 12, 2019 3:16 pm
by benhank
Re: Auto Acknowlediments
Posted: Tue Mar 12, 2019 3:27 pm
by scottwilkerson
Then in your script you need to change to
Code: Select all
commandfile='/var/spool/nagios/cmd/nagios.cmd'
along with doing the other things
@npolovenko mentioned.
Also, this line
Code: Select all
/bin/printf "[%lu] ACKNOWLEDGE_SVC_PROBLEM;host1;service2;1;1;1;bhankers;this issue has been automatically acknowedged by NagiosXi\n" $now > $commandfile
needs to be changed to
Code: Select all
/bin/printf "[%lu] ACKNOWLEDGE_SVC_PROBLEM;$host;$service;1;1;1;bhankers;this issue has been automatically acknowedged by NagiosXi\n" $now > $commandfile
Re: Auto Acknowlediments
Posted: Tue Mar 12, 2019 3:29 pm
by scottwilkerson
I'm going to add, I have no idea why your test server doesn't have the nagios.cmd in the default location but it is set in the nagios.cfg
Re: Auto Acknowlediments
Posted: Wed Mar 13, 2019 9:28 am
by benhank
scottwilkerson wrote:I'm going to add, I have no idea why your test server doesn't have the nagios.cmd in the default location but it is set in the nagios.cfg
Scott....we both know the answer to that one...lol
Re: Auto Acknowlediments
Posted: Wed Mar 13, 2019 10:46 am
by scottwilkerson
benhank wrote:Scott....we both know the answer to that one...lol

Re: Auto Acknowlediments
Posted: Thu Mar 14, 2019 1:29 pm
by benhank
hey fellas we can lock this one up.
Thanks for all the help fellas!