Turn off monitoring for servers shutdown gracefully.

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
NagiosIMCS
Posts: 20
Joined: Mon Mar 19, 2018 2:55 pm

Re: Turn off monitoring for servers shutdown gracefully.

Post by NagiosIMCS »

Hi Ben,

That looks amazing thank you very much. I am on leave for the next few days but on my return I will give it a try and let you know how I get on,

Thank you so much for all your help really appreciated, thank you.

Regards,

Stephen P
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Turn off monitoring for servers shutdown gracefully.

Post by benjaminsmith »

Hi Stephen,

Sounds good! We'll leave this open if you have any more 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!
NagiosIMCS
Posts: 20
Joined: Mon Mar 19, 2018 2:55 pm

Re: Turn off monitoring for servers shutdown gracefully.

Post by NagiosIMCS »

Thank you again Ben,

Apologies for the delay other priorities but this has become important again.

The plan is to use Group Policy to configure for the Start Up and Shutdown scripts.

Ideally what I would like is when the server is shut down for it to almost become like the server has been removed from Nagios entirely. Until the server get powered back on then I would like to start alerting in the normal fashion.

Would the DISABLE_HOST_CHECK command but suitable for when the server is shutdown?

https://assets.nagios.com/downloads/nag ... mand_id=54

Then when the server powers backup I was going to use the ENABLE_HOST_CHECK command

https://assets.nagios.com/downloads/nag ... mand_id=53
NagiosIMCS
Posts: 20
Joined: Mon Mar 19, 2018 2:55 pm

Re: Turn off monitoring for servers shutdown gracefully.

Post by NagiosIMCS »

Firstly thank you for all your help.

I was wondering if you cold assist with the following please?

I happy with the Group or Local Policy aspect of the process.

I am struggling with the script aspect. For instance, assuming I am using a Local Policy.

If I create a script called DISABLE_NOTIFICATIONS.

What file extension should I use i.e. .cmd or bat?

#!/bin/sh
# This is a sample shell script showing how you can submit the DISABLE_NOTIFICATIONS 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] DISABLE_NOTIFICATIONS\n" $now > $commandfile


Do I need to copy the script and place it in the folder C:\Program Files\NSClient++\Scripts

Then update the file C:\Program Files\NSClient++\nsclient.ini

Under the header [/settings/external scripts/scripts]

DISABLE_NOTIFICATIONS.bat = scripts\\DISABLE_NOTIFICATIONS.bat $ARG1$ "$ARG2$"

I am not sure what the variables $ARG1$ "$ARG2$ should be set to, can you please advise?

Apologies if I have misunderstood your advice I am still new to Nagios and this is my first attempt at a script. I am more Next, Next, Next, Finish.

The overall goal is stop any alerts whilst the server is powered off line and then to continue monitoring when the server is back on line.

The scripts I was thinking about using are

Server Shutdown Script:
https://assets.nagios.com/downloads/nag ... mand_id=54

Server Startup Script:
https://assets.nagios.com/downloads/nag ... mand_id=53

I did have a look at the article below but it didn't make a great deal of sense.

http://YOURXISERVER//nagiosxi/help/api- ... portconfig
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Turn off monitoring for servers shutdown gracefully.

Post by benjaminsmith »

Hi @NagiosIMCS,

If you are going to run those Nagios External Commands from the Azure VM, then you would want to use the API option here and send the request to the XI server over HTTP. You can view a sample command by going to Help > API Docs > System > Corecommand in the Nagios XI user interface.

As far as what type of script to use from the Windows machine, I would think Powershell would have the most functionality to send API calls.

We have a kb article on using plugins with NSClient. I would follow the example script in the article and get that working and then see if you can modify the script then to suit your requirements.

Nagios XI - Using Scripts / Plugins With NSClient++

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!
NagiosIMCS
Posts: 20
Joined: Mon Mar 19, 2018 2:55 pm

Re: Turn off monitoring for servers shutdown gracefully.

Post by NagiosIMCS »

Thank you Benjamin,

That's great going to give it a try. Thanks for all your help on this matter.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Turn off monitoring for servers shutdown gracefully.

Post by benjaminsmith »

That's great going to give it a try. Thanks for all your help on this matter.
Your welcome! Let us know how it goes.
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!
NagiosIMCS
Posts: 20
Joined: Mon Mar 19, 2018 2:55 pm

Re: Turn off monitoring for servers shutdown gracefully.

Post by NagiosIMCS »

Good morning, me again.

Thank you again for all your help.

I did find this article below:

https://gallery.technet.microsoft.com/I ... t-04476631

I was trying to use the Invoke-WebRequest in PowerShell

Code: Select all

Invoke-WebRequest -URI http://NagiosIP//nagiosxi/ -Credential $credential -Method POST -ContentType 'application/x-www-form-urlencoded' 
Due to time limitations I am struggling to get the script working I am going to continue working on it in the background.

This is brings to yet another question (sorry).

Would it be possible to create a host group. Which alerts one once when a server is shut down.

Thanks again for your help. I am going to carry on researching the script.

Have a good weekend.
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Turn off monitoring for servers shutdown gracefully.

Post by benjaminsmith »

Hi,
Would it be possible to create a host group. Which alerts one once when a server is shut down.
Yep, that can be done. A host group is really just a collection of hosts so the notification settings are defined at the host level, You can set the notification interval on those hosts to 0, and the only one notification will be sent. You can adjust those settings for a host group using the Bulk Mods Tool in the CCM. Go to Configure > CCM > Tools > Bulk Mods Tool.

--Benjamin
notification_interval: This directive is used to define the number of "time units" to wait before re-notifying a contact that this service is still down or unreachable. Unless you've changed the interval_length directive from the default value of 60, this number will mean minutes. If you set this value to 0, Nagios will not re-notify contacts about problems for this host - only one problem notification will be sent out.
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!
NagiosIMCS
Posts: 20
Joined: Mon Mar 19, 2018 2:55 pm

Re: Turn off monitoring for servers shutdown gracefully.

Post by NagiosIMCS »

Thank you very much. :D :D
Locked