NagiosXI set alert as Critical instead of Warning.

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
nshah
Posts: 20
Joined: Tue Oct 01, 2019 3:47 pm

NagiosXI set alert as Critical instead of Warning.

Post by nshah »

Hi,

We are monitoring HTTP services according to the paging file using the following command-

/usr/local/nagios/libexec/check_http -H 1.10.10.x http://1.10.10.x/mypage -m 2635:2635

Whenever the page file is less or greater than 2635 we receive a notification. But we are receiving a warning notification. How can we set that warning alert as critical?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: NagiosXI set alert as Critical instead of Warning.

Post by ssax »

You should be able to use the negate plugin for this:

Code: Select all

/usr/local/nagios/libexec/negate -w CRITICAL -s /usr/local/nagios/libexec/check_http -H 1.10.10.x -u http://1.10.10.x/mypage -m 2635:2635
nshah
Posts: 20
Joined: Tue Oct 01, 2019 3:47 pm

Re: NagiosXI set alert as Critical instead of Warning.

Post by nshah »

Great that worked! Thanks.

But I noticed that the alert doesn't include the host group, service display name and the service notes (Attachment). I have it configured but somehow it is not able to include in the notification. It may not be related but do you know what might be the possibilities?
You do not have the required permissions to view the files attached to this post.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: NagiosXI set alert as Critical instead of Warning.

Post by benjaminsmith »

Hi,
I have it configured but somehow it is not able to include in the notification.
Let's confirm that the extra variables have been added to the xi service notification handler? That's likely the issue here and you can double-check this by going to Configure > CCM > Commands and searching for xi_service_notification_handler. The process is described on page 9 of the following guide.

Understanding Notification Variables

Also, you'll find the complete list of available macros on the following page:

https://assets.nagios.com/downloads/nag ... olist.html

Let us know if that's the issue or if you have any questions.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
nshah
Posts: 20
Joined: Tue Oct 01, 2019 3:47 pm

Re: NagiosXI set alert as Critical instead of Warning.

Post by nshah »

Thanks Benajmin,

I tried to go thru that doc and it kind of makes sense but I am not clear

In my previous screenshot, Let's take a host group as an example.

%hostgroupnames% in username>Notification Options> Notification Message has to be like;

--hostgroupnames="$Hostgroup$" in Configure > CCM > Commands and searching for xi_service_notification_handler ?

That is how I understand. Please correct me if I am wrong.

Thanks in advance,
Nish
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: NagiosXI set alert as Critical instead of Warning.

Post by benjaminsmith »

Hi Nish,

You'll want to add --hostgroupnames="$HOSTGROUPNAMES$" to the end of the notification command. The full command for the host notification would is as follows.

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$" --hostgroupnames="$HOSTGROUPNAMES$"
Then save the changes and Appy configuration, and try to send a test message. You can do this by putting a host in a hard down state by sending passive check results.
passive-checks.png
Let me know if you get it working.

Best Regards,
Benjamin
You do not have the required permissions to view the files attached to this post.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
nshah
Posts: 20
Joined: Tue Oct 01, 2019 3:47 pm

Re: NagiosXI set alert as Critical instead of Warning.

Post by nshah »

Thanks Benjamin for detail instruction. I changed it but it didn't worked. (Attachment)



One last question-
So, in my case it has to be --hostgroupnames="$HOSTGROUPNAMES$" ? But the code that you have in previous posts,
It's --hostaddress="$HOSTADDRESS$".

Does it has to match with --hostgroupnames? I am asking it because the documentation has mentioned it can be anything.

Thank you!
Nish
You do not have the required permissions to view the files attached to this post.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: NagiosXI set alert as Critical instead of Warning.

Post by benjaminsmith »

Hi Nish,
Does it has to match with --hostgroupnames? I am asking it because the documentation has mentioned it can be anything.
The --houstgroupname is the variable set to the macro, so you can use any name in the notification command and access it in the email template using %-houstgroupname% or another name. You do have to use the defined system macros available in Nagios Core.

It should work, make sure to save the notification template after making changes, and apply it to the users.

You can send me the system profile and I check the syntax on the notification handlers for you.

Benjamin

To send us your system profile.
Login to the Nagios XI GUI using a web browser.
Click the "Admin" > "System Profile" Menu
Click the "Download Profile" button
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
nshah
Posts: 20
Joined: Tue Oct 01, 2019 3:47 pm

Re: NagiosXI set alert as Critical instead of Warning.

Post by nshah »

Hi Benjamin-
I have paste all the config here. I have noticed we have a variable missing in xi_host_notiication. I added those, Maybe that was an issue?

Our service notifications are working as expected with the right colors and variable. (Red for critical), Amber for 'warning' and green for 'OK' but not for hostnotification.

Here is the Notification Message configuration for Hosts and Services-
<html>
<head>
<style>.OK {color:green;}.WARNING {color:orange;}.UNKNOWN {color:orange}.CRITICAL {color:red}</style>
</head>
<body>
<h2 class='%hoststate%'>***** Nagios XI Alert *****</h2>

%alertsummary%

Notification Type: %type%
Host: %host%
State: <strong class='%hoststate%'>%hoststate%</strong>
Address: %hostaddress%
Hostgroup: %hostgroupnames%
Info: %hostoutput%
Date/Time: %datetime%
Host Notes: <font color="green">%hostnotes%</font>
Host Duration: %hostduration%

Respond: <href a="%responseurl%">%responseurl%</a>
Nagios URL: %xiserverurl%
</body>
</html>

<html>
<head>
<style>.OK {color:green;}.WARNING {color:orange;}.UNKNOWN {color:orange}.CRITICAL {color:red}</style>
</head>
<body>
<h3 class='%servicestate%'>***** Nagios XI Alert *****</h3>

%alertsummary%

Notification Type: %type%
Service Name: %service%
Service Displayname: %servicedisplayname%
Service Group: %servicegroupnames%
State: <strong class='%servicestate%'>%servicestate%</strong>
Host Name: %host%
Hostalias: %hostalias%
Address: %hostaddress%
Hostgroup: %hostgroupnames%

Info:
%serviceoutput%
%longserviceoutput%
Date/Time: %datetime%
Service Notes: <font color="green">%servicenotes%</font>

Respond: %responseurl%
Nagios URL: %xiserverurl%

</body>
</html>

And here is the xi_host_notification_handler

And xi_service_notification_handler.
/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --service="$SERVICEDESC$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --datetime="$LONGDATETIME$" --servicenotes="$SERVICENOTES$" --hostnotes="$HOSTNOTES$" --hostgroupnames="$HOSTGROUPNAMES$ --servicegroupnames="$SERVICEGROUPNAMES$" --servicedisplayname="$SERVICEDISPLAYNAME$"


/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$" --hostnotes="$HOSTNOTES$" --hostgroupnames="$HOSTGROUPNAMES$
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: NagiosXI set alert as Critical instead of Warning.

Post by benjaminsmith »

HI nshah,

I don't see anything wrong with the CSS in the host template. Does the correct state type show up in the email ( is it being passed into the message)? Can you post the full HTML source from the email for host? There's probably a tag somewhere that's not closed.

This maybe a cut and paste issue but the following item in the host notification message is missing the closing " character.

Code: Select all

 --hostgroupnames="$HOSTGROUPNAMES$"
Also, I don't see a variable for the Host Duration: %hostduration% added to the notification command, so add the to the end of the command string.

Regards,
Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked