Auto Acknowlediments

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
benhank
Posts: 1264
Joined: Tue Apr 12, 2011 12:29 pm

Auto Acknowlediments

Post 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?
You do not have the required permissions to view the files attached to this post.
Proudly running:
NagiosXI 5.4.12 2 node Prod Env 2500 hosts, 13,000 services
Nagiosxi 5.5.7(test env) 2500 hosts, 13,000 services
Nagios Logserver 2 node Prod Env 500 objects sending
Nagios Network Analyser
Nagios Fusion
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Auto Acknowlediments

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
benhank
Posts: 1264
Joined: Tue Apr 12, 2011 12:29 pm

Re: Auto Acknowlediments

Post 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!
Proudly running:
NagiosXI 5.4.12 2 node Prod Env 2500 hosts, 13,000 services
Nagiosxi 5.5.7(test env) 2500 hosts, 13,000 services
Nagios Logserver 2 node Prod Env 500 objects sending
Nagios Network Analyser
Nagios Fusion
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Auto Acknowlediments

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
benhank
Posts: 1264
Joined: Tue Apr 12, 2011 12:29 pm

Re: Auto Acknowlediments

Post by benhank »

it's in

Code: Select all

/var/spool/nagios/cmd/nagios.cmd
Proudly running:
NagiosXI 5.4.12 2 node Prod Env 2500 hosts, 13,000 services
Nagiosxi 5.5.7(test env) 2500 hosts, 13,000 services
Nagios Logserver 2 node Prod Env 500 objects sending
Nagios Network Analyser
Nagios Fusion
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Auto Acknowlediments

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Auto Acknowlediments

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
User avatar
benhank
Posts: 1264
Joined: Tue Apr 12, 2011 12:29 pm

Re: Auto Acknowlediments

Post 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
Proudly running:
NagiosXI 5.4.12 2 node Prod Env 2500 hosts, 13,000 services
Nagiosxi 5.5.7(test env) 2500 hosts, 13,000 services
Nagios Logserver 2 node Prod Env 500 objects sending
Nagios Network Analyser
Nagios Fusion
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Auto Acknowlediments

Post by scottwilkerson »

benhank wrote:Scott....we both know the answer to that one...lol
:lol:
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
User avatar
benhank
Posts: 1264
Joined: Tue Apr 12, 2011 12:29 pm

Re: Auto Acknowlediments

Post by benhank »

hey fellas we can lock this one up.
Thanks for all the help fellas!
Proudly running:
NagiosXI 5.4.12 2 node Prod Env 2500 hosts, 13,000 services
Nagiosxi 5.5.7(test env) 2500 hosts, 13,000 services
Nagios Logserver 2 node Prod Env 500 objects sending
Nagios Network Analyser
Nagios Fusion
Locked