notification status to endpoint http URL

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
iqadmin
Posts: 12
Joined: Tue Oct 06, 2020 2:01 am

notification status to endpoint http URL

Post by iqadmin »

Hi,

I have configured an HTTP URL service to monitor on Nagios XI if in any case, it's down then the notification messages should call to the endpoint HTTP URL. Instead of email/or SMS notification, it should go to the direct HTTP endpoint.

How can we configure this on Nagios Xi.please your support on this if anyone has an idea about this?
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: notification status to endpoint http URL

Post by dchurch »

Sure, you can use an Event Handler to execute an arbitrary command. That command can send an HTTP request off to your server.

1. Create file on the Nagios XI system. In this case I'll just call it /tmp/send-curl-command.sh. Make sure it's chmodded +x.

Code: Select all

#!/bin/sh
HOSTADDRESS=$1
curl -s "https://example.com/path/to/notification?HOSTADDRESS=$HOSTADDRESS"
2. Create a Command in the CCM. In this case I'll call it notify-curl
Command Name: notify-curl
Command Line: /tmp/send-curl-command.sh $HOSTADDRESS$
Command Type: misc command
Active: Yes

3. Edit the host in the CCM and set the Check Settings -> Event Handler to notify-curl, and enable it.

There are probably more variables you can insert into the command line, but that's the basic gist of one way to do it.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
iqadmin
Posts: 12
Joined: Tue Oct 06, 2020 2:01 am

Re: notification status to endpoint http URL

Post by iqadmin »

thanks for your reply ,again we have issue with proxy server to post the messages, so i have added noproxy via below script, but still i could not get any logs ,
Pls your support for the curl script that to be configured on to sent status messages to dest url.
And also how can i check the log file of this cmd notify-curl.

#!/bin/sh
HOSTADDRESS=$1
HOSTSTATE=$2
SERVICESTATE=$3
curl --noproxy "*" "http://10.x.x.x?HOSTADDRESS=$HOSTADDRES ... $HOSTSTATE" >/tmp/curllog
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: notification status to endpoint http URL

Post by dchurch »

You'll want to use a & to separate arguments to the script. E.g. "https://example.com/foo.php?bar=baz&qux=quux"

And I'm pretty sure you need a slash (/) after the hostname in your URL.

Rewritten:

Code: Select all

#!/bin/sh
HOSTADDRESS=$1
HOSTSTATE=$2
SERVICESTATE=$3
curl --noproxy "*" "http://10.x.x.x/?HOSTADDRESS=$HOSTADDRESS&HOSTSTATE=$HOSTSTATE" >/tmp/curllog
As for getting the logs out, run the following command on the HTTP server 10.x.x.x:

Code: Select all

(CentOS / RHEL)
tail -f /var/log/httpd/access_log |grep HOSTADDRESS
(Ubuntu / Debian)
tail -f /var/log/apache2/access.log |grep HOSTADDRESS
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
Locked