Page 4 of 5
Re: Error Argument exchange-serverhealth
Posted: Mon Nov 07, 2016 6:16 pm
by Box293
Looking at the plugin downloads page:
https://exchange.nagios.org/directory/P ... th/details
Very Important with this and all other Checks is that you use the 64bit verion of NSClient. Without you get an error that it cant load the needed Powershell commands.
Took me some time to figure this out ...
Do you have the 64bit version of NSClient++ installed? It should list this in Add/Remove programs.
Re: Error Argument exchange-serverhealth
Posted: Tue Nov 08, 2016 2:32 am
by nagiosjam
NSclient ++ 64 Bits 0.4.2.114
Re: Error Argument exchange-serverhealth
Posted: Tue Nov 08, 2016 5:36 pm
by rkennedy
PS C: \ Program Files \ NSClient ++ \ scripts> \ check_exchangehealth.ps1 OWA.
OK: OWA - 3 checks are OK
Are you using an ADMIN powershell, or a normal user powershell to execute this?
Let's do a final review of what you have, because based off of everything in this thread, it should be working. I am guessing there is something little that is missing at this point. Please post the following things for us, so we can review everything at play -
1. Your nsclient.ini file from the client machine
2. A copy of the plugin you are utilizing
Once we have that, we'll get it working over the CLI and then move into getting it working as a status check.
Re: Error Argument exchange-serverhealth
Posted: Wed Nov 09, 2016 2:38 am
by nagiosjam
I am using admin user to run the latest commands in powershell
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.17.17
; 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
[/settings/external scripts/scripts]
exchange_serverhealth=cmd /c echo scripts\exchange-serverhealth.ps1 $ARG1$; exit($lastexitcode) | powershell.exe -command -
Plugin exchange-serverhealth.ps1
Code: Select all
# Exchange 2013 Server Health Check
# Cameron Murray ([email protected])
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Param(
[string]$HealthSet
)
$status = 0
# Make all errors hard stopping for catching Exchange commandlet errors.
$global:ErrorActionPreference = "Stop";
# Error handling
trap {
write-host "SCRIPT EXCEPTION $($_.Exception.Message)";
exit 2;
}
# Check that the Microsoft Exchange Health Manager is running
if($(get-service MSExchangeHM).Status -ne "Running") {
write-host "Microsoft Exchange Health Manager is not running on server"
exit 2;
}
# Check that a health set has been passed to the script
if(!$HealthSet) {
write-host "You must specify a health set to this script via an argument"
exit 2;
}
# Check for Summary Health Check
if($HealthSet -eq "Summary") {
# Get health checks for role
$HealthSetResult = (get-serverhealth -identity (gc env:computername))
} else {
# Get health checks for role
$HealthSetResult = (get-serverhealth -identity (gc env:computername) -HealthSet $HealthSet)
}
# Filter by Degraded state
$DegradedHealthChecks = $HealthSetResult | Where-Object {($_.AlertValue -eq "Degraded") -or ($_.AlertValue -eq "Unhealthy")}
if($DegradedHealthChecks.Length -gt 0) {
# Atleast one health check is degraded or unhealthy
$status=2
foreach($healthCheck in $DegradedHealthChecks) {
$desc = "$desc $($DegradedHealthChecks.Name) ,"
}
$desc = "$desc checks in Degraded or Unhealthy State"
}
if ($status -eq "2") {
Write-Host "CRITICAL: $desc"
} elseif ($status -eq "0") {
Write-Host "OK: $HealthSet - $($HealthSetResult.Length) checks are OK"
}
exit $status
Re: Error Argument exchange-serverhealth
Posted: Wed Nov 09, 2016 1:08 pm
by rkennedy
I had to make changes to your NSClient++ configuration file to even get it to work properly for the SSL ciphers. Not sure how it was working for you previously. You'll want to uncomment the password / modify the allowed hosts field.
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
[/settings/NRPE/server]
; VERIFY MODE - Comma separated list of verification flags to set on the SSL socket. default-workarounds Various workarounds for what I understand to be broken ssl implementations no-sslv2 Do not use the SSLv2 protocol. no-sslv3 Do not use the SSLv3 protocol. no-tlsv1 Do not use the TLSv1 protocol. single-dh-use Always create a new key when using temporary/ephemeral DH parameters. This option must be used to prevent small subgroup attacks, when the DH parameters were not generated using "strong" primes (e.g. when using DSA-parameters).
ssl options =
; VERIFY MODE - Comma separated list of verification flags to set on the SSL socket. none The server will not send a client certificate request to the client, so the client will not send a certificate. peer The server sends a client certificate request to the client and the certificate returned (if any) is checked. fail-if-no-cert if the client did not return a certificate, the TLS/SSL handshake is immediately terminated. This flag must be used together with peer. peer-cert Alias for peer and fail-if-no-cert. workarounds Various bug workarounds. single Always create a new key when using tmp_dh parameters. client-once Only request a client certificate on the initial TLS/SSL handshake. This flag must be used together with verify-peer
verify mode = none
; ALLOW INSECURE CHIPHERS and ENCRYPTION - Only enable this if you are using legacy check_nrpe client.
insecure = true
allow arguments = true
; 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 = 192.168.3.115
; 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
[/settings/external scripts/scripts]
exchange_serverhealth=cmd /c echo scripts\exchange-serverhealth.ps1 $ARG1$; exit($lastexitcode) | powershell.exe -command -
As for the plugin, it appears to be working on my end (fails here as I don't have Exchange, but I added debugigng to ensure it is passing $ARG1$) -
Code: Select all
[root@localhost libexec]# ./check_nrpe -H 192.168.47.8 -c exchange_serverhealth -a OWA42
SCRIPT EXCEPTION Cannot find any service with service name 'MSExchangeHM'.
OWA42
Re: Error Argument exchange-serverhealth
Posted: Thu Nov 10, 2016 6:32 am
by nagiosjam
I have put your nsclient and it continues giving the same SCRIPT EXCEPTION failure that I measured before
Re: Error Argument exchange-serverhealth
Posted: Thu Nov 10, 2016 12:58 pm
by rkennedy
Can you show us the EXACT message you're receiving?
Re: Error Argument exchange-serverhealth
Posted: Fri Nov 11, 2016 2:26 am
by nagiosjam
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.
Re: Error Argument exchange-serverhealth
Posted: Fri Nov 11, 2016 2:32 pm
by tgriep
It could be that the Windows PowerShell Script Execution Policy is blocking the Power Shell script from running.
To allow it to run, login to the Windows system as an administrator an open op powershell and run the following to enable powershell scripts to run.
Try running the plugin again, if it still doesn't work, try running this on the Windows server instead.
Re: Error Argument exchange-serverhealth
Posted: Mon Nov 14, 2016 7:13 am
by nagiosjam
The same error
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.