NCPA Passing Parameters Issue

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
FrontlineIT
Posts: 94
Joined: Tue Jul 26, 2016 8:46 am

NCPA Passing Parameters Issue

Post by FrontlineIT »

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
}
FrontlineIT
Posts: 94
Joined: Tue Jul 26, 2016 8:46 am

Re: NCPA Passing Parameters Issue

Post by FrontlineIT »

In the meantime, I just removed the two parameters and added them as variables in the script. The check works now.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: NCPA Passing Parameters Issue

Post by npolovenko »

@FrontlineIT , Can you try running the command like this?
-t '<your token>' -M 'plugins/EventLogCheck.ps1' -q 'args='T1 Circuit might be Unusable' 5'
Also, if you open the web browser on the windows server and type in the URL:https://localhost:5693, you should see the NCPA interface. Go to the API menu, in the API endpoint choose plugins, select EventLogCheck.ps1 from the drop down list below. Type arguments in the Plugin Arguments field. Once you find the combination that works click on "View in alternative format" -> As active check using check_ncpa.py. This should give you the command with the right syntax.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked