Page 2 of 5

Re: Error Argument exchange-serverhealth

Posted: Tue Nov 01, 2016 9:19 am
by dwhitfield
I'm not sure how long this has been an issue, but looking at https://www.nagios.org/projects/nagios-core/history/4x/, 4.2.2 fixed a specific bug related to September!

Re: Error Argument exchange-serverhealth

Posted: Wed Nov 02, 2016 2:42 am
by nagiosjam
I have changed and continues to fail

ejecutado desde servidor windows exchange, todo ok
PS C:\Program Files\NSClient++\scripts> .\check_exchangehealth.ps1 OWA
OK: OWA - 3 checks are OK

but from the nagios server prompts you to enter the argument and the argument is OWA and still says that target the argument

[Nagios @ servernagios libexec] $ ./check_nrpe serverwindows H-exchange-serverhealth reere c -t 50
You must specify to health in September to this script via an argument

Re: Error Argument exchange-serverhealth

Posted: Wed Nov 02, 2016 2:34 pm
by rkennedy
The issue is probably in your definition for how it's defined, please post your nsclient.ini file for us to review.

Re: Error Argument exchange-serverhealth

Posted: Wed Nov 02, 2016 4:03 pm
by cammj
Hello,

I wrote this script, and it (did) work. Unfortunately, I haven't used it in a significant period of time - so it might be worthwhile me doing a revision of it (which i'll do in the coming days).

However, it's unlikely the script if it is working when you perform a manual check. The response you're getting seems to indicate that the param isn't making its way through from Nagios, to NSClient, and in to the Script.

As mentioned by @rkennedy, we really would need to have a look at your nsclient.ini file. Now there was a working example of what you need to add to the nsclient.ini file on the script download page, but it's best to be sure.

What you can do as a temporary work around, if you only want to monitor one health set, is manually code the default param in to the PS1 file.

To do this, change the following;

Code: Select all

Param(
  [string]$HealthSet
)
To be

Code: Select all

Param(
  [string]$HealthSet="OWA"
)
If you want to monitor multiple different healthsets, just copy the ps1 in to different PS1's and set up config for that within NSCLIENT/Nagios appropriately

This is a workaround while we figure out the problem.

Re: Error Argument exchange-serverhealth

Posted: Wed Nov 02, 2016 4:59 pm
by rkennedy
Thank you @cammj! Helps a lot when the original author joins in the conversation. :)

@nagiosjam - I'll watch for your nsclient.ini / nsc.ini and we'll work through it.

Re: Error Argument exchange-serverhealth

Posted: Thu Nov 03, 2016 3:15 am
by nagiosjam
This is my nsclient.ini

Code: Select all

# If you want to fill this file with all avalible options run the following command:
#   nscp settings --generate --add-defaults --load-all
# If you want to activate a module and bring in all its options use:
#   nscp settings --activate-module <MODULE NAME> --add-defaults
# For details run: nscp settings --help


; Undocumented section
[/modules]

; Undocumented key
NSClientServer = 1

; Undocumented key
CheckDisk = 1

; Undocumented key
CheckEventLog = 1

; Undocumented key
CheckExternalScripts = 1

; Undocumented key
CheckHelpers = 1

; Undocumented key
CheckNSCP = 1

; Undocumented key
CheckSystem = 1

; Undocumented key
CheckWMI = 1

; Undocumented key

NRPEServer = 1

; Section for NSClient (NSClientServer.dll) (check_nt) protocol options.
[/settings/NSClient/server]

; ENABLE SSL ENCRYPTION - This option controls if SSL should be enabled.
use ssl = 0

; PERFORMANCE DATA - Send performance data back to Nagios (set this to 0 to remove all performance data).
performance data = 1

; PORT NUMBER - Port to use for check_nt.
port = 12489

[/settings/NRPE/server]
allow arguments = 1

; Section for NSClient (NSClientServer.dll) (check_nt) protocol options.
[/settings/NSClient/server]




; Undocumented section
[/settings/default]

; Undocumented key
allowed hosts = 172.17.10.10

; Undocumented key
password = xxxxxx

[/settings/external scripts]
allow arguments = true
allow nasty characters = true
timeout = 90

[/settings/external scripts/wrappings]
bat = scripts\\%SCRIPT% %ARGS%
ps1 = cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -
vbs = cscript.exe //T:90 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%
exe = cmd /c %SCRIPT% %ARGS%


[/settings/external scripts/wrapped scripts]

test_bat = check_ok.bat
test_ps = check_test.ps1
test_vbs = check_test.vbs
test_ping = check_ping.bat
test_files = check_files.vbs
test_battery = check_battery.vbs
test_printers = check_printer.vbs
alias_process = checkProcState "$ARG1$=started"
check_test = check_test.ps1


exchange_serverhealth= exchange-serverhealth.ps1 -HealthSet $ARG1$
And this is the definition of service

define service{
use windowsmbx-service,srv-pnp
host_name servermbx
servicegroups windowsmbx-service
service_description COMPONENTNAME HealthSet OWA
check_command check_nrpe!exchange_serverhealth!OWA
}

I attached the image file with Nagios frontend. Does not display the error screen
1.jpg
If I run the plugin from the Nagios console, I get this error

[Nagios @ servernagios libexec] $ ./check_nrpe servermbx -c -H exchange_serverhealth servermbx OWA -t60

SCRIPT EXCEPTION The term 'get-serverhealth' is not recognized as the name of a cmdlet, function, script file or executable program. Check if you misspell the name or, if you include a path, verify that the path is correct and try again.

And from the windows server if I run from powershell plugin, if I work

PS C: \ Program Files \ NSClient ++ \ scripts> \ exchange-serverhealth.ps1 OWA.
OK: OWA - 18 checks are OK

I tried what it says cammy
health monitor multiple different sets, just copy the ps1 in to different PS1
and it's the same

Thank you very much

Re: Error Argument exchange-serverhealth

Posted: Thu Nov 03, 2016 9:47 am
by rkennedy
[Nagios @ servernagios libexec] $ ./check_nrpe servermbx -c -H exchange_serverhealth servermbx OWA -t60

SCRIPT EXCEPTION The term 'get-serverhealth' is not recognized as the name of a cmdlet, function, script file or executable program. Check if you misspell the name or, if you include a path, verify that the path is correct and try again.
There is no way that is the command you executed because NRPE will not accept those invalid arguments.

Code: Select all

[root@localhost libexec]# ./check_nrpe servermbx -c -H exchange_serverhealth servermbx OWA -t60
Incorrect command line arguments supplied

NRPE Plugin for Nagios
Copyright (c) 1999-2008 Ethan Galstad ([email protected])
Please show us EXACTLY what you're trying to pass over the CLI.

As for your configuration files, there are a few things that need to be changed.

Code: Select all

exchange_serverhealth= exchange-serverhealth.ps1 -HealthSet $ARG1$
PS C: \ Program Files \ NSClient ++ \ scripts> \ exchange-serverhealth.ps1 OWA.
It looks like you may be missing the 'scripts' folder part, what errors are you seeing in your nsclient.log file? Also, I believe you may be defining it wrong for the Powershell script in NSClient++. Try this -

Code: Select all

exchange_serverhealth=cmd /c echo scripts\\exchange-serverhealth.ps1 $ARG1$; exit($lastexitcode) | powershell.exe -command -

Re: Error Argument exchange-serverhealth

Posted: Fri Nov 04, 2016 2:52 am
by nagiosjam
I changed my settings file nsclient.ini

Code: Select all

[/settings/external scripts/scripts]

exchange_serverhealth=cmd /c echo scripts\\exchange-serverhealth.ps1 $ARG1$; exit($lastexitcode) | powershell.exe -command -
Run the command from the console nagios

[Nagios @ servernagios libexec] $ ./check_nrpe -t60 -c -H serverexchange exchange_serverhealth

SCRIPT EXCEPTION The term 'get-serverhealth' is not recognized as the name of a cmdlet, function, script file or executable program. Check if you misspell the name or, if you include a path, verify that the path is correct and try again.

and continues to give me the same error

Re: Error Argument exchange-serverhealth

Posted: Fri Nov 04, 2016 3:31 am
by nagiosjam
I have other plugins in the same server as if they work well

nsclient.ini

[/ Settings / external scripts / scripts]
check_ex2013dag = cmd / c I miss scripts \ CheckEX2013DAG.ps1; exit ($ lastexitcode) | powershell.exe -command -

run from the console and all ok nagios

[Nagios @ servernagios libexec] $ ./check_nrpe -t60 -c -H serverexchange check_ex2013dag
DB-1: Mounted - DB-2: Mounted - DB-3: Mounted - DB-4: Mounted - DB-TEST: Mounted

Re: Error Argument exchange-serverhealth

Posted: Fri Nov 04, 2016 10:12 am
by rkennedy
There are multiple issues going on at once here. Let's focus on one at a time, and get the command working over the CLI first.

Please show us the ACTUAL commands you are running over the command line to achieve working results. The ones you have posted are not valid.

Code: Select all

[Nagios @ servernagios libexec] $ ./check_nrpe -t60 -c -H serverexchange exchange_serverhealth

Code: Select all

[Nagios @ servernagios libexec] $ ./check_nrpe -t60 -c -H serverexchange check_ex2013dag