Page 1 of 2

Servicios

Posted: Tue Mar 30, 2021 1:02 pm
by abpro
Question: If a service gets deactivated, nagios xi can perform an operation to force an execution of the service?

Re: Servicios

Posted: Tue Mar 30, 2021 3:06 pm
by dchurch
If a service is deactivated in Nagios XI, then it doesn't get written out to configs when you push Apply Config.

This means Nagios Core (sometimes called the Monitoring Engine) doesn't know anything about it.

Maybe if I had a better idea of what you were trying to do, I'd be able to help you accomplish it a different way. So, at a high level what are you trying to do, and why?

Re: Servicios

Posted: Tue Mar 30, 2021 5:29 pm
by abpro
Well, for example, a service of a widows client that is turned off, I would like to know if nagios xi can turn that service on, such as:

A windows service is monitoring it nagios xi I get an ok where it is monitoring correctly but out of nowhere it restarts or turns off the service.

how could I turn on that service from nagios xi?

Re: Servicios

Posted: Wed Mar 31, 2021 9:05 am
by dchurch
Restarting Windows services thru NCPA: https://assets.nagios.com/downloads/nag ... h-NCPA.pdf

NCPA is our free, open-source agent for remote monitoring. Basically you install NCPA on the Windows machine and create a plugin .bat file to restart the service, then use a Nagios XI event handler to trigger the plugin. A step-by-step process to do all this is explained in the document.

Try that and let me know if you run into any issues.

Re: Servicios

Posted: Wed Mar 31, 2021 2:31 pm
by abpro
Hello dchurch
Thank you very much for answering .

I have managed to start a windows service I have another question that same code can you start .exe applications? If I am monitoring a running application it closes, can I start that Windows application that is running?

Re: Servicios

Posted: Wed Mar 31, 2021 4:40 pm
by dchurch
Sure, in the .bat file just swap out "net start" with the full path to the program, e.g.:

Code: Select all

@echo off
"C:\Program Files\Mozilla Firefox\firefox.exe"
That'll start the program instead of restarting the service.

Re: Servicios

Posted: Wed Mar 31, 2021 5:37 pm
by abpro
dchurch wrote:Sure, in the .bat file just swap out "net start" with the full path to the program, e.g.:

Code: Select all

@echo off
"C:\Program Files\Mozilla Firefox\firefox.exe"
That'll start the program instead of restarting the service.
Hello, for example, this is how I would execute it .bat '?

@echo off
"C:\Program Files\Mozilla Firefox\firefox.exe"

@exit 0

Re: Servicios

Posted: Thu Apr 01, 2021 10:28 am
by dchurch
Yes, that's exactly right; that bat file will start Firefox on a remote windows machine.
Replace the path to firefox.exe with any program you want to launch remotely.

Try it and let me know if you run into any issues.

Re: Servicios

Posted: Thu Apr 01, 2021 10:46 am
by abpro
Hello, thanks for helping me. I have a problem with the .bat in windows it already executes it and opens the application without problems now when executing it in the nagios console when entering this command it does not open the application.

./check_ncpa.py -H 10.20.10.84 -P 5693 -t RJ11tabar_nagios -M 'plugins / restart_aplicacion.bat' -a "chrome.exe"

I did it in 2 ways in nagios none did I run the command

the .bat is already inside the ncpa folder inside the plugins

./check_ncpa.py -H 10.20.10.84 -P 5693 -t RJ11tabar_nagios -M 'plugins / restart_aplicacion.bat' -a "C: \ Program Files \ Google \ Chrome \ Application / chrome.exe"

inside nagios console don't run it

Re: Servicios

Posted: Thu Apr 01, 2021 2:30 pm
by dchurch
abpro wrote:./check_ncpa.py -H 10.20.10.84 -P 5693 -t RJ11tabar_nagios -M 'plugins / restart_aplicacion.bat' -a "C: \ Program Files \ Google \ Chrome \ Application / chrome.exe"
I wasn't able to lab this up. Too many quoting errors. I don't think it's possible to pass an argument with a space in it and NOT have it break it up when trying to pass it to a generalized script.

I'd make one plugin called restart_chrome.bat:

Code: Select all

@echo off
"C:\Program Files\Google\Chrome\Application\chrome.exe"
exit 0
Then call it using the NCPA plugin:

Code: Select all

./check_ncpa.py -H 10.20.10.84 -P 5693 -t RJ11tabar_nagios -M 'plugins/restart_chrome.bat'
Also, don't insert spaces surrounding your slashes. Not sure why you did that.

Also don't use forward slashes in place of backslashes. In windows they mean something completely different.