Question

NRPE3 - Lancement script Powershell

  • 28 September 2023
  • 11 replies
  • 440 views

Badge +2

Bonjour,

Nous avions un controle via NRPE qui fonctionnait sans probleme.
Ce controle exécutait un script Powershell.
Le fichier nsclient a été modifié pour accepter les scripts externes.

Nous avons voulu tester avec NRPE3 et impossible de le faire fonctionner.

Nous avons ce retour :
CHECK_NRPE STATE CRITICAL: Socket timeout after 30 seconds.

Même en agrandissant le Timeout, le résultat est le même.

Voici la commande :
./check_centreon_nrpe3  -H  HOST -p 5666 -t 30 -c eventps1

Faut il quelque chose de spécial pour utiliser NRPE3 ?

Merci d’avance de votre aide.



 

Good morning,

We had control via NRPE which worked without problem.
This control executed a Powershell script.
The nsclient file has been modified to accept external scripts.

We wanted to test with NRPE3 and couldn't get it to work.

We have this feedback:
CHECK_NRPE STATE CRITICAL: Socket timeout after 30 seconds.

Even if you enlarge the Timeout, the result is the same.

Here is the command :
./check_centreon_nrpe3 -H HOST -p 5666 -t 30 -c eventps1

Do I need anything special to use NRPE3?
​​​​​​​
Thank you in advance for your assistance.


11 replies

Userlevel 5
Badge +14

hello

can you just run 

/usr/lib64/nagios/plugins/check_centreon_nrpe3 -H monitored_host_ip -p 5666

it should at least report if the plugin is correctly communicating with the host

if you get a timeout try adding what is says in the doc in as extra option Windows NRPE 0.5 | Centreon Documentation

/usr/lib64/nagios/plugins/check_centreon_nrpe3 -H monitored_host_ip -p 5666 -u -2 -P 8192

i just tried on a random windows with the nrpe3 plugin I got a timeout without these option, and I got an “OK” with them.

 

these should be in the host template for windows NRPE host, you should add that to your host template macro

 

Badge +2

Hello 

With /usr/lib64/nagios/plugins/check_centreon_nrpe3 -H monitored_host_ip -p 5666 -u -2 -P 8192

I (0.5.2.41 2018-04-26) seem to be doing fine...


But with /usr/lib64/nagios/plugins/check_centreon_nrpe3 -H monitored_host_ip -p 5666

==>  Error: if a fixed payload size is specified, '-2' must also be specified

I must modified the nsclient.ini to add option payload ?

I have this :
payload length = 8192

Userlevel 5
Badge +14

I don’t really understand you last question, if it works on your first line where is says “seem to be doing fine”, now just add your command to that

 /usr/lib64/nagios/plugins/check_centreon_nrpe3 -H monitored_host_ip -p 5666 -u -2 -P 8192 -c eventps1

if you have an error or a timeout when running the command line without any -c option and you don’t get OK, you must first get the OK then you can your command -c.

 

in your case it was ok with  -u -2 -P 8192 → I (0.5.2.41 2018-04-26) seem to be doing fine…

so go with this options and don’t modify nsclient.ini

 

Badge +2

Thanks, I managed to get the powershell to work.

However, I wanted to put another script into operation.

Tested with nscp.exe: working script

Tested from the CENTREON poller: The script works.

In CENTREON, I have in detail: Command not allow

The command used:
/check_centreon_nrpe3 -H "IP_HOST -p 5666 -u -2 -P 8192 -c SCRIPT

Can you still help me?

THANKS !

Userlevel 5
Badge +14

Each command "-c xxx" must exist in your nsclient.ini, like nrpe.cfg on Linux

At the end of your nsclient.ini you should have the command you used previously, eventps1 

The line is 

eventps1=the real command 

 

Just add more command there, restart service and it should work

 

Badge +2

The script is present in the ini file and in the script folder.

Its execution is OK from the Poller CENTREON.

On CENTREON (WEB interface),
Unable to make this command work.

Userlevel 5
Badge +14

Oh I misunderstood, sorry…

 

can you screenshot the command from the web interface (in the detail of the service)

run it “as is” in your poller and screenshot that and send it here (you should mask your private info)

 

what is displayed by the web will executed “as is” by the poller.

Badge +2

And here !

Userlevel 5
Badge +14

ok, that’s much clearer

 

you didn’t put the correct “path”. the command is not in the “/” , you need to put the correct path, if it is a standard plugin, you should use the same $$ variable as the other commands, example ;

here on my setup it is “$CENTREONPLUGINS$” before “/”

Badge +2

On the other commands that work, we put this:
 

With the long path, I get this error message:
 

 

Userlevel 5
Badge +14

ok, for NRPE the “$$” variable is not $CENTREONPLUGINS$, it is $USER1$ (for old nagios and nrpe binaries, but the full path is ok to use.

 

for your last part, that is not an error message, it is “ok” but I fear you are trying to do something you are not understanding, or I don’t understand what is your problem... that help windows is not the execution of the command, it is just to run the command with --help to help you put the right parameters

(and that last screenshot is ok, it found the executable, ran it with --help and you get the output)

 

you are making a check command (“vérifier” = check) 

this is a command that will be used by a a centreon service, in host. 

normally you should make your command with macro like this

/usr/lib64/nagios/plugins/check_centreon_nrpe3 -H $HOSTADDRESS$ -p 5666 -u -2 -P 8192 -c eventps1

or a bit better : 

/usr/lib64/nagios/plugins/check_centreon_nrpe3 -H $HOSTADDRESS$ -p 5666 -u -2 -P 8192 -c $_SERVICECOMMAND$

 

with this command, you can use this command in your service,

it will use the ip address of the host and you will have an automatic MACRO on your service that will be called COMMAND, where you will set the command you want to call (here you will put eventps1)

then you push your config and run your service check

 

after it ran, you will see the command line “generated” on the detail pane in the ressource view : 

that is what you need to check if it is the right command, you can copy the command text and run that manually on the poller

 

Reply