Page 1 of 1

Command Line from Windows Servers

Posted: Tue Sep 29, 2020 6:37 am
by NagiosIMCS
Hi everyone,

I need some advise please.

I have come across this article:

https://serverfault.com/questions/58966 ... dows-linux

This is basically what I am trying to achieve. Once the host is shutdown a script executes that places the host into downtime.

This aforementioned article stipulates that its for both Windows and Linux.

How would I run the following script from a Windows server? Is it even possible?

now=`date +%s`
#Check first path nagios.cmd & printf
commandfile='/var/lib/nagios3/rw/nagios.cmd'

/usr/bin/printf "[%lu] DISABLE_HOST_NOTIFICATIONS;my-host\n" $now > $commandfile


Any help greatly appreciated apologies if I am asking silly questions

Re: Command Line from Windows Servers

Posted: Tue Sep 29, 2020 10:50 am
by mbellerue
Not a silly question at all. It's a great idea to have your servers put themselves in downtime when they go through a graceful shutdown.

That particular Stack link is for Nagios Core. You have a couple of different options available to you in Nagios XI. Most notably, the Nagios XI API. If you log into the Nagios XI web interface and go to Help -> API Docs -> System Reference, there is a section specifically for scheduling downtime.

The example is using the curl command, but if you need to execute this API call from a Windows machine, Powershell may be the way to go. The Invoke-WebRequest cmdlet is very similar to curl in functionality.

Take a look at the API documentation, and let me know if this would be a good route to build your solution around.

Re: Command Line from Windows Servers

Posted: Thu Oct 01, 2020 3:54 am
by NagiosIMCS
Thank you :D :D

Re: Command Line from Windows Servers

Posted: Thu Oct 01, 2020 4:03 pm
by benjaminsmith
Hi,
Thank you :D :D
Your welcome. Let us know if you have any other questions or if we may close this thread.