Servicios

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
abpro
Posts: 50
Joined: Wed Feb 24, 2021 5:31 pm

Servicios

Post by abpro »

Question: If a service gets deactivated, nagios xi can perform an operation to force an execution of the service?
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Servicios

Post 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?
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
abpro
Posts: 50
Joined: Wed Feb 24, 2021 5:31 pm

Re: Servicios

Post 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?
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Servicios

Post 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.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
abpro
Posts: 50
Joined: Wed Feb 24, 2021 5:31 pm

Re: Servicios

Post 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?
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Servicios

Post 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.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
abpro
Posts: 50
Joined: Wed Feb 24, 2021 5:31 pm

Re: Servicios

Post 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
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Servicios

Post 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.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
abpro
Posts: 50
Joined: Wed Feb 24, 2021 5:31 pm

Re: Servicios

Post 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
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: Servicios

Post 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.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
Locked