NCPA and return codes
Posted: Wed Apr 12, 2017 9:11 am
NCPA 2.0.3 on Windows Server 2008 R2 Standard
PowerShell 2.0
Nagios XI 5.3.3 on CentOS 7
NCPA Wizard 1.4.4, check_ncpa.py 1.1.0
I've written a custom plugin in PowerShell to check the free space on vSphere datastores. When I check the plugin's output when running it directly on the Windows box, I see the expected return codes:
However, when I run it from the command line from my Nagios XI server, I always get a return code of 0:
Any idea what I'm doing wrong or missing?
PowerShell 2.0
Nagios XI 5.3.3 on CentOS 7
NCPA Wizard 1.4.4, check_ncpa.py 1.1.0
I've written a custom plugin in PowerShell to check the free space on vSphere datastores. When I check the plugin's output when running it directly on the Windows box, I see the expected return codes:
Code: Select all
PS C:\Users\cbeattie> & 'C:\Program Files (x86)\Nagios\NCPA\plugins\Get-DatastoreSingle.ps1' -VIServer myviserver -Datastore mydatastore -Warn 85 -Crit 95 -Verbose ; $LASTEXITCODE
VERBOSE: myviserver
VERBOSE: mydatastore
VERBOSE: 85
VERBOSE: 95
VERBOSE: myviserver
VERBOSE: 4/12/2017 7:50:55 AM Get-Datastore Started execution
VERBOSE: 4/12/2017 7:50:55 AM Get-Datastore Finished execution
VERBOSE: mydatastore
CRITICAL: mydatastore - 98.14% used
2
PS C:\Users\cbeattie>Code: Select all
[nagios@dnagios libexec]$ ./check_ncpa.py --hostname=myhost --token=mytoken --metric='plugins/Get-DatastoreSingle.ps1' --arguments='-VIServer myviserver -Datastore mydatastore -Warn 85 -Crit 95 -Verbose' --verbose --debug ; echo $?
Connecting to: https://myhost:5693/api/plugins/Get-DatastoreSingle.ps1/-VIServer/myviserver/-Datastore/mydatastore/-Warn/85/-Crit/95/-Verbose?token=mytoken&check=1
File returned contained:
{
"returncode": 0,
"stdout": "VERBOSE: myviserver\nVERBOSE: mydatastore\nVERBOSE: 85\nVERBOSE: 95\nVERBOSE: myviserver\nVERBOSE: 4/12/2017 7:52:44 AM Get-Datastore Started execution\nVERBOSE: 4/12/2017 7:52:47 AM Get-Datastore Finished execution\nVERBOSE: mydatastore\nCRITICAL: mydatastore - 98.14% used"
}
VERBOSE: myviserver
VERBOSE: mydatastore
VERBOSE: 85
VERBOSE: 95
VERBOSE: myviserver
VERBOSE: 4/12/2017 7:52:44 AM Get-Datastore Started execution
VERBOSE: 4/12/2017 7:52:47 AM Get-Datastore Finished execution
VERBOSE: mydatastore
CRITICAL: mydatastore - 98.14% used
0
[nagios@nagios libexec]$