NCPA Passing Parameters Issue
Posted: Thu Feb 14, 2019 3:12 pm
Hello. We have some Windows 2003 servers that I have NCPA version 1.8.1 setup on. I have a custom powershell plugin I setup to monitor for certain event log errors and to go critical if more than 5 are found during an interval. It works properly, however, it's not working when running from the Nagios server. The first parameter is the event log message and the 2nd parameter is the integer 5. I keep getting an OK status when I know for sure there are over 5 event log matched errors.
Here's the full argument:
-t 'somepassword' -P 5693 -M 'agent/plugin/EventLogCheck.ps1' -a "'T1 Circuit might be Unusable' 5"
Here's the local plugin:
param(
[Parameter(Mandatory=$true)][string]$description,
[Parameter(Mandatory=$true)][int]$c
)
$ok = 0
$warning = 1
$critical = 2
$eventstatus = Get-EventLog -LogName Application -EntryType Error -After (Get-Date).AddMinutes(-5) | Where-Object {$_.Message -match $description}
if ($eventstatus.count -ge $c){
Write-Host Critical: $eventstatus.count event log errors with that description
exit $critical
}
Else {
Write-Host OK: not enough event log errors with that description
exit $ok
}
Here's the full argument:
-t 'somepassword' -P 5693 -M 'agent/plugin/EventLogCheck.ps1' -a "'T1 Circuit might be Unusable' 5"
Here's the local plugin:
param(
[Parameter(Mandatory=$true)][string]$description,
[Parameter(Mandatory=$true)][int]$c
)
$ok = 0
$warning = 1
$critical = 2
$eventstatus = Get-EventLog -LogName Application -EntryType Error -After (Get-Date).AddMinutes(-5) | Where-Object {$_.Message -match $description}
if ($eventstatus.count -ge $c){
Write-Host Critical: $eventstatus.count event log errors with that description
exit $critical
}
Else {
Write-Host OK: not enough event log errors with that description
exit $ok
}