Page 1 of 1
notification status to endpoint http URL
Posted: Fri Dec 11, 2020 5:24 pm
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?
Re: notification status to endpoint http URL
Posted: Fri Dec 11, 2020 6:17 pm
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.
Re: notification status to endpoint http URL
Posted: Sun Dec 13, 2020 11:06 am
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
Re: notification status to endpoint http URL
Posted: Mon Dec 14, 2020 12:38 pm
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