Page 1 of 1

Powershell script->no output returned from the command

Posted: Fri Jul 13, 2018 10:05 am
by sannatar16
Hello team,

I have created a simple powershell script to test mirroring status, it works as expected from the powershell prompt. I have created a service in nagios for that and it always shows OK, with the output "no output available from command(check_mirroring_status)"

My code returns db name along with status and exit code when i run in the server. Please help

I have installed nsclient 0.5.62 version



Regards,
sannatar

Re: Powershell script->no output returned from the command

Posted: Fri Jul 13, 2018 4:01 pm
by npolovenko
Hello, @sannatar16. Are you using the NSClient to run this PowerShell script? Can you show me the command definition on the Nagios server as well as in the NSclient.ini file.

Re: Powershell script->no output returned from the command

Posted: Mon Jul 16, 2018 6:45 am
by sannatar16
Hi Please find the details. I have only one db mirrored so I have hard-coded that in the script itself. So i have no arguments to be passed
Service definition:
define service {
host_name xxxxxxxxx
service_description mirroring_status
check_command check_mssql_mirroring_status
initial_state u
max_check_attempts 1
check_interval 1
retry_interval 1
check_period 24x7
notification_period 24x7
notification_options w,c,r,
register 1
}

Command definition:

define command {
command_name check_mssql_mirroring_status
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c check_mirroring_status

}

NSclient.ini entry in external scripts:
check_mirroring_status = cmd /c echo scripts\\mirroring.ps1;exit($lastexitcode) | powershell.exe -command -

Re: Powershell script->no output returned from the command

Posted: Mon Jul 16, 2018 3:09 pm
by npolovenko
@sannatar16. Thank you. Could you upload the script and the nsclinet.ini file here as well?