Page 2 of 2

Re: Servicios

Posted: Thu Apr 01, 2021 3:54 pm
by abpro
dchurch wrote:
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.





I have done what you described to me when executing it inside nagios console mode it executes it but it does not open the application
[root@ABP-VMS01P-NAG libexec]# ./check_ncpa.py -H 10.20.10.84 -P 5693 -t RJ11tabar_nagios -M 'plugins/restart_chrome.bat'

Re: Servicios

Posted: Thu Apr 01, 2021 4:41 pm
by dchurch
What computer user is the service running as (check this in the service options in the Windows management console)? The only way for a GUI program to pop open is if it's the same as the user currently logged in.

Re: Servicios

Posted: Tue Apr 06, 2021 11:14 am
by abpro
Hello, thank you very much for answering
My question is .sh how to create the scrips so that nagios detects it and makes the change when executing the program in nagios

Re: Servicios

Posted: Tue Apr 06, 2021 1:46 pm
by dchurch
Well, you'd need to change the user that the NCPA Listener service runs as. Do that by going into the Windows services list and opening the Properties from the right-click menu on the NCPA Listener service, then modifying the setting on the Log On tab.

Re: Servicios

Posted: Tue Apr 06, 2021 1:53 pm
by abpro
dchurch wrote:Well, you'd need to change the user that the NCPA Listener service runs as. Do that by going into the Windows services list and opening the Properties from the right-click menu on the NCPA Listener service, then modifying the setting on the Log On tab.

Thanks, I want to understand is that within the nagios console of the libexec directory, what command I enter to develop a scrips for nagios to activate that complement

Re: Servicios

Posted: Tue Apr 06, 2021 4:52 pm
by dchurch
I'm not sure what you mean. Is there another way you can phrase it?

Re: Servicios

Posted: Tue Apr 06, 2021 5:01 pm
by abpro
dchurch wrote:I'm not sure what you mean. Is there another way you can phrase it?

Create Event Handler Script
#! / bin / sh
case "$ 1" in
OKAY)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
/usr/local/nagios/libexec/check_ncpa.py -H "$ 2" -P 5693 -t "$ 3" -M 'plugins / restart_service.bat' -a "$ 4"
;;
that C
exit 0

How would it be to create the event to open the application in nagios xi??

Re: Servicios

Posted: Wed Apr 07, 2021 11:04 am
by dchurch
Oh, adding the trigger to Nagios XI is covered later in the Restarting Windows Services With NCPA document, starting where it says "Create Event Handler."

Also, the script you pasted into the forum won't work; there are spaces added for some reason. When writing to a file on the server, make sure to delete all of them. E.g. replace "#! / bin / sh" with "#!/bin/sh"; replace "$ 1" with "$1" etc. And remove that weird "that C" line you added - that may cause the script to error. It's probably easier to just copy-paste the script from the PDF.