We are suffering some problems with the NCPA agent and the passive monitoring. We've configured the agent and followed the tutorials to build custom scripts/plugins. The agent is installed on a Windows XP machine
There seems to be two issues:
- Every time we restart the NCPA passive service, the first check "seems" to be working, but all following ones fail because they could not find the plugins directory. We have used different paths in the configuration based in the information of the API: agent/plugin, plugins, and so on.
- We said "seem", because even the first time the check does not really succeed, the services get an OK status but the output is not for an OK status: "MS VBScript runtime error, subscript out of range" and "No exit code was suplied, aborting!". Apparently we are not passing the parameters in the correct way (both .bat and .vbs scripts work fine when called manually from command line).
vbs testing script:
Code: Select all
Wscript.Echo ":" & Wscript.Arguments(0)
Wscript.Quit(Wscript.Arguments(0))
Code: Select all
@echo off
if [%1] == [] echo No exit code was supplied, aborting! & exit /B 3
if [%2] == [] echo No dummy message was supplied, aborting! & exit /B 3
echo %~2
exit /B %1%
Code: Select all
2020-09-09 09:15:23,141:INFO:__init__:Parsed config from: ['C:\\monitoring\\NCPA\\etc\\ncpa.cfg']
2020-09-09 09:15:23,141:INFO:__init__:Looking for plugins at: C:\monitoring\NCPA\plugins
2020-09-09 09:15:23,141:INFO:__init__:Establishing passive handler: Handler
2020-09-09 09:15:23,217:INFO:connectionpool:Starting new HTTP connection (1): x.x.x.x
2020-09-09 09:15:23,280:WARNING:__init__:Server does not have a record for config.
2020-09-09 09:15:23,280:ERROR:__init__:get_plugin() takes exactly 5 arguments (1 given)
Traceback (most recent call last):
File "C:\ncpa\agent\ncpa_windows.py", line 192, in run_all_handlers
File "C:\monitoring\NCPA\passive\nrds.py", line 46, in run
self.get_plugin(plugin)
TypeError: get_plugin() takes exactly 5 arguments (1 given)
2020-09-09 09:15:23,296:INFO:__init__:Establishing passive handler: Handler
2020-09-09 09:15:23,296:INFO:__init__:Running check: /cpu/percent --warning 20 --critical 30
2020-09-09 09:15:24,325:INFO:__init__:Running check: /memory/swap/percent --warning 40 --critical 80
2020-09-09 09:15:24,325:INFO:__init__:Running check: /memory/virtual/percent --warning 60 --critical 80
2020-09-09 09:15:24,325:INFO:__init__:Running check: /agent/plugin/check_dummy.bat 2 SomethingIsCRITICAL
2020-09-09 09:15:24,355:INFO:__init__:Running check: /agent/plugin/check_a.vbs 2 SomethingIsCRITICAL
2020-09-09 09:15:24,559:INFO:connectionpool:Starting new HTTP connection (1): x.x.x.x
2020-09-09 09:15:24,605:INFO:__init__:Message from NRDP server: OK
2020-09-09 09:15:24,605:INFO:__init__:Meta output from NRDP server: 5 checks processed
2020-09-09 09:20:24,614:INFO:__init__:Establishing passive handler: Handler
2020-09-09 09:20:24,614:INFO:connectionpool:Starting new HTTP connection (1): x.x.x.x
2020-09-09 09:20:24,630:WARNING:__init__:Server does not have a record for config.
2020-09-09 09:20:24,630:ERROR:__init__:Encountered exception while trying to read plugin directory: WindowsError(3, 'The system cannot find the path specified')
2020-09-09 09:20:24,630:ERROR:__init__:get_plugin() takes exactly 5 arguments (1 given)
Traceback (most recent call last):
File "C:\ncpa\agent\ncpa_windows.py", line 192, in run_all_handlers
File "C:\monitoring\NCPA\passive\nrds.py", line 46, in run
self.get_plugin(plugin)
TypeError: get_plugin() takes exactly 5 arguments (1 given)
2020-09-09 09:20:24,630:INFO:__init__:Establishing passive handler: Handler
2020-09-09 09:20:24,630:INFO:__init__:Running check: /cpu/percent --warning 20 --critical 30
2020-09-09 09:20:25,642:INFO:__init__:Running check: /memory/swap/percent --warning 40 --critical 80
2020-09-09 09:20:25,642:INFO:__init__:Running check: /memory/virtual/percent --warning 60 --critical 80
2020-09-09 09:20:25,642:INFO:__init__:Running check: /agent/plugin/check_dummy.bat 2 SomethingIsCRITICAL
2020-09-09 09:20:25,642:WARNING:__init__:Unable to access directory plugins/
2020-09-09 09:20:25,642:WARNING:__init__:Unable to assemble plugins. Does the directory exist? - WindowsError(3, 'The system cannot find the path specified')
2020-09-09 09:20:25,642:INFO:__init__:Running check: /agent/plugin/check_a.vbs 2 SomethingIsCRITICAL
2020-09-09 09:20:25,642:WARNING:__init__:Unable to access directory plugins/
2020-09-09 09:20:25,642:WARNING:__init__:Unable to assemble plugins. Does the directory exist? - WindowsError(3, 'The system cannot find the path specified')
2020-09-09 09:20:25,657:INFO:connectionpool:Starting new HTTP connection (1): x.x.x.x
2020-09-09 09:20:25,674:INFO:__init__:Message from NRDP server: OK
2020-09-09 09:20:25,674:INFO:__init__:Meta output from NRDP server: 5 checks processed
Code: Select all
[listener]
uid = nagios
certificate = adhoc
loglevel = info
ip = 0.0.0.0
gid = nagcmd
logfile = var/ncpa_listener.log
port = 5693
pidfile = var/ncpa_listener.pid
# Available versions: PROTOCOL SSLv2, SSLv3, TLSv1
ssl_version = TLSv1
[passive]
uid = nagios
handlers = nrds,nrdp
loglevel = info
gid = nagcmd
sleep = 300
logfile = var/ncpa_passive.log
pidfile = var/ncpa_passive.pid
[nrdp]
token =NRDP_Token
hostname =STIC-Simatic-T02
parent =http://10.176.139.143/nrdp/
[nrds]
URL =http://10.176.139.143/nrdp/
CONFIG_VERSION =0
TOKEN =NRDP_Token
CONFIG_NAME =
CONFIG_OS = None
PLUGIN_DIR=plugins/
UPDATE_CONFIG=1
UPDATE_PLUGINS=1
[api]
community_string =
[plugin directives]
plugin_path = plugins/
.sh = /bin/sh $plugin_name $plugin_args
.ps1 = powershell -ExecutionPolicy Bypass -File $plugin_name $plugin_args
.vbs = cscript $plugin_name $plugin_args //NoLogo
[passive checks]
%HOSTNAME%|cpu usage = /cpu/percent --warning 20 --critical 30
%HOSTNAME%|swap usage = /memory/swap/percent --warning 40 --critical 80
%HOSTNAME%|memory usage = /memory/virtual/percent --warning 60 --critical 80
%HOSTNAME%|disk_array_1 = /agent/plugin/check_dummy.bat 2 SomethingIsCRITICAL
%HOSTNAME%|diskArray2 = /agent/plugin/check_a.vbs 2 SomethingIsCRITICAL