Question about Auto generating Ack script

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

Question about Auto generating Ack script

Post by benhank »

If I modify this script by adding service and host macros will it work?

Original:

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.

now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'

/bin/printf "[%lu] ACKNOWLEDGE_SVC_PROBLEM;host1;service1;2;1;1;Some One;Some Acknowledgement Comment\n" $now > $commandfile   
modded:

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.

now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'

/bin/printf "[%lu] ACKNOWLEDGE_SVC_PROBLEM;%host%;%service%;2;1;1;NagiosXI;Acknowledgement has been auto generated by NagiosXI\n" $now > $commandfile   
Im just trying to have nagios acknowledge a service when it goes down. Im going to create an event handler that will run this script when the service goes down.
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: Question about Auto generating Ack script

Post by scottwilkerson »

You need something like this

script_name.sh

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'

`which printf` "[%lu] ACKNOWLEDGE_SVC_PROBLEM;$host;$service;2;1;1;nagiosadmin;Acknowledgement has been auto generated by NagiosXI\n" $now > $commandfile 
Then your command for the event handler would look like this

Code: Select all

$USER1$/script_name.sh "$HOSTNAME$" "$SERVICEDESC$"
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: Question about Auto generating Ack script

Post by benhank »

Thanks Scott that is as usual far more than I could have hoped for ! you can lock it.
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: Question about Auto generating Ack script

Post by scottwilkerson »

benhank wrote:Thanks Scott that is as usual far more than I could have hoped for ! you can lock it.
You're the best Ben!
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked