You are here

NRPE and parameter

5 posts / 0 new
Last post
Sebastien Trognon
sebastien.trognon's picture
NRPE and parameter

Hi,

I have a problem. I use OPSView server and the Opsview Windows Agent (last version).

I don't succeed to pass argument to my powershell script.

When I use this line in the .ini file:

allow_arguments=true
allow_nasty_meta_chars=1
check_DFSR_Backlog = cmd /c echo scripts\check_DFSR_Backlog.ps1 $ARG1$ ; exit($lastexitcode) | powershell.exe -command -

And check_nrpe -H $HOSTADDRESS$  -c check_DFSR_Backlog -a FolderName in the OPSView

The result is of args is  $   .  I have try with quote, double quote... always the same $

In the log :

2016-11-23 13:59:18: debug:NSClient++.cpp:1143: Injecting: check_DFSR_Backlog: Foldername
2016-11-23 13:59:19: debug:NSClient++.cpp:1179: Injected Result: OK '$
$'
2016-11-23 13:59:19: debug:NSClient++.cpp:1180: Injected Performance Result: ''

I have tried with : check_DFSR_Backlog = cmd /c echo scripts\check_DFSR_Backlog.ps1 foldername ; exit($lastexitcode) | powershell.exe -command -    and I have args -> foldername in my powershell and so in monitoring windows.

Is there someome that had the same ? or know to fix this

Thanks

 

Duncan Ferguson
dferguson's picture
Amend your ini file to

Amend your ini file to include the following sections

[External Script]
allow_arguments=1
allow_nasty_meta_chars=1

[External Scripts]
check_custom=cmd /c "echo scripts\check_custom $ARG1$; exit($lastexitcode) | powershell.exe -command -"

  Duncs

Sebastien Trognon
sebastien.trognon's picture
I have tried but them result:

I have tried but them result:

.ini file :
[External Script]
allow_arguments=true
allow_nasty_meta_chars=1

[External Scripts]
; The old plugins we'll deprecate
check_DFSR_Backlog=cmd /c "echo scripts\check_DFSR_Backlog $ARG1$; exit($lastexitcode) | powershell.exe -command -"

powershellScript:
$args
$statut = 0
$statutinfo = "The folder $args "  
write-host $args
exit $statut

on opsview:

     

Duncan Ferguson
dferguson's picture
I have proven it works on my

I have proven it works on my system:

powershell:

$statut = 1
$statutinfo = "The folder is $args"  
Write-Host $statutinfo
exit $statut

opsview.ini config

[External Script]
allow_arguments=1
allow_nasty_meta_chars=1

[External Scripts]
check_custom2=cmd /c echo scripts\custom2.ps1 $ARG1$; exit $lastexitcode | powershell.exe -noprofile -nologo -command -

Output:

$ libexec/check_nrpe -H 192.168.0.10 -c check_custom2 -a some_folder_name
The folder is some_folder_name
$ echo $?
1

 

  Duncs

Sebastien Trognon
sebastien.trognon's picture
I have tried with all your

I have tried with all your output and I have the same result: only

$ check_nrpe -H 10.3.1.22 -c check_custom2 -a some_folder_name Output: The folder is $ Errors: Return code: 0I think I have an issue with the .ini or nrpe module but I'm really not an expert. Thank you for your answers