Hello,
I recently transitioned from NSClient to NCPA for a custom plugin check. I have a custom powershell plugin that checks a text file for certain errors. The check works but I'm having trouble passing the ARGs to let Nagios XI know what the service state status is when ok, warning, critical. Below is the argument we're passing using check_xi_ncpa and the powershell script:
ARG:
-t 'mytoken' -P 5693 -M 'agent/plugin/check_log_file.ps1' -a 'E:\web\production\cache\scripterrorlog.txt'
Powershell Plugin
param(
[Parameter(Mandatory=$true)][string]$logfile
)
$ok = 0
$warning = 1
$critical = 2
$content = "Out of memory"
$content1 = "Out of string space"
$content2 = "Not enough storage"
$logresult = get-childitem $logfile | select-string $content -quiet
$logresult1 = get-childitem $logfile | select-string $content1 -quiet
$logresult2 = get-childitem $logfile | select-string $content2 -quiet
if (($logresult) -or ($logresult1) -or ($logresult2)){
Clear-Content $logfile
Write-Host "Critical: Content match within the log file"
exit $critical
}
Else {
Write-Host "OK: No content matches"
exit $ok
}
NCPA Return Codes (Ok, Warning, Critical)
-
FrontlineIT
- Posts: 94
- Joined: Tue Jul 26, 2016 8:46 am
NCPA Return Codes (Ok, Warning, Critical)
Last edited by FrontlineIT on Wed Dec 05, 2018 12:49 pm, edited 1 time in total.
-
FrontlineIT
- Posts: 94
- Joined: Tue Jul 26, 2016 8:46 am
Re: NCPA Passing Service state ARGs
Attached is an example of the issue.
You do not have the required permissions to view the files attached to this post.
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: NCPA Return Codes (Ok, Warning, Critical)
@FrontlineIT, Please manually execute the PowerShell script from the PowerShell terminal and then run the following command to check the exit code:
Next, run the remote ncpa command from the Nagios terminal and then the following:echo %errorlevel%
echo $?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.