NCPA and windows Passive checks over NRDP

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: NCPA and windows Passive checks over NRDP

Post by gmills »

mbellerue,

man, I've never used a VBSCript before, it has been a struggle to get it usable.
had to change the windows registry and set the default script engine to CScript.exe
all new to me

Anyway, I can successfully run the plugin script on the client windows machine.

C:\Program Files (x86)\Nagios\NCPA\plugins>check_files.vbs -p "D:\Delta Incoming\incomingData\PersistentStore\Delta IBM MQ Series" -w 50 -c 60
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

OK: 19 files were matched.|count=19

BUT I cannot seem to get the Nagios server to call it successfully??

[root@alpcts000001083 libexec]# ./check_ncpa.py -H 3.239.245.147 -t gold3726 -M plugins/check_files.vbs -a '-p "D:\Delta Incoming\IncomingData\PersistentStore\Delta IBM MQ Series" -w 100 -c 200'

CScript Error: Can't find script engine "VBScript" for script "C:\Program Files (x86)\Nagios\NCPA\plugins\check_files.vbs".

I fixed it so cscript.exe doesn't need to proceed the plugin call. I had corrected this issue on the Windows server.

would you have any ideas? seems I'm missing something, I'll keep looking, see if I can get it first this time :) thank you!
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: NCPA and windows Passive checks over NRDP

Post by gmills »

this is my service definition

define service {
host_name GEIPALPDLTPRC01
service_description Delta File Count
check_command check_ncpa!-t 'gold3726' -P 5693 -M 'plugins/check_files.vbs' -a '-p D:\Delta Incoming\IncomingData\PersistentStore\Delta IBM MQ Series' -w 180 -c 200
max_check_attempts 5
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contact_groups Delta-Admins
register 1
}
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: NCPA and windows Passive checks over NRDP

Post by mbellerue »

That sounds like it was quite the adventure. Let's do this. What version of Windows is NCPA running on? Can you send me your ncpa.cfg file? And can you also send me the registry changes that you needed to make?

Speaking of the registry changes. You said you needed to change the script engine in order to run the plugin. What was the error that caused you to make that change?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: NCPA and windows Passive checks over NRDP

Post by gmills »

thanks mbellerue, and happy Friday! have a great weekend!

Windows Version: Windows 12 R2
registry changes:

HKCR\CLSID\{B54F3741-5B07-11cf-A4B0-00AA004A55E8}\InprocServer32
changed to C:\Windows\system32\vbscript.dll WAS pointing to McAfee

I also performed the following - didn't do anything
cd %windir%\system32
regsvr32 vbscript.dll

lastly...
wscript.exe //H:cscript - set cscript.exe as default script host globally and persistent

NCPA.cfg is attached

the ERROR that started all this due that the VB Script was not executable.

the ERROR
there was also, invalid handle caused by scripts sending to STDIN,STDOUT, STDERROR
CScript Error: Cant find script engine VBScript for script C:\Program Files (x86)\Nagios\NCPA\plugins

Now it runs successfully on the Windows machine, I can't get it to successfully run from NRPE on Nagios server
thank you for your help!!!
Attachments
ncpa.cfg
NCPA.CFG
(8.33 KiB) Downloaded 158 times
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: NCPA and windows Passive checks over NRDP

Post by mbellerue »

Hey, have a great weekend yourself!

I will probably look at this a little more closely next week, but the first thing that's jumping out at me is this.
HKCR\CLSID\{B54F3741-5B07-11cf-A4B0-00AA004A55E8}\InprocServer32
changed to C:\Windows\system32\vbscript.dll WAS pointing to McAfee
That's the current user registry. And if I'm understanding this correctly, running the VB script via NCPA is giving you the same error that you got when you ran it manually, and that prompted you to make the registry change.

What I'm getting at here is that the current user registry is for your user alone. So when NCPA tries to run the VB script, it uses whatever user the service is assigned (system by default), and that doesn't have the registry tweak, so it's running into the same error.

That's the result of my quick overview from what you've sent in. I would advise great caution if you're considering making a change to the system wide registry at 4PM on a Friday. This is how weekends are ruined. :lol:
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: NCPA and windows Passive checks over NRDP

Post by gmills »

right on... I get it. makes sense...

yeah, because it runs on Windows box, and not from Nagios call.

let me look in to this...

thank you!!!!

funny, but correct... no long weekend this weekend :D
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: NCPA and windows Passive checks over NRDP

Post by ssax »

Sounds good, in addition, please see here as well for the NPCA Passives doc, I didn't see it listed earlier:

https://assets.nagios.com/downloads/ncp ... Checks.pdf

@mbellerue is correct about the reg fix though, when the service runs in the backend it runs in the local system context an not as a specific user.

This could be McAfee limiting it as well, please try these:

http://lifeofageekadmin.com/cant-find-s ... dows-2008/
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: NCPA and windows Passive checks over NRDP

Post by gmills »

thank you Saax,

I have actually used that procedure. I still cannot call the vbs script successfully.
I'm in a pickle too, I have not very much windows experience, wonder if you have any trouble shooting help here?

I can't find anything in any logs????
gmills
Posts: 114
Joined: Wed Jun 12, 2019 2:08 pm

Re: NCPA and windows Passive checks over NRDP

Post by gmills »

Is my command correct?
###############################################################################
# NCPA(Nagios Cross Platform Agent) CHECK COMMAND
#
# Command to use NRPE to check remote host systems
###############################################################################

define command {
command_name check_ncpa
command_line $USER1$/check_ncpa.py -H $HOSTADDRESS$ $ARG1$ $ARG2$
}
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA and windows Passive checks over NRDP

Post by lmiltchev »

Let's clarify a few things. You would like to run a script on the Windows machine as a passive check, and send results back to your Nagios server via NRDP, correct?

If this is the case, you would need to make some modifications in the ncpa.cfg file.

1. Add nrdp as your handler by changing this:

Code: Select all

handlers =None
to this:

Code: Select all

handlers =nrdp
2. Under the [nrdp] section, set the parent:

Code: Select all

parent = http://<ip address>/nrdp
token =<nrdp token>
3. Define your passive check in the nrdp.cfg file if you haven't done it yet.

Code: Select all

[passive checks]

%HOSTNAME%|<Service Description> = plugins/<your script> <args and thresholds if required>
Read more on configuring passive checks in NCPA here:
https://www.nagios.org/ncpa/help.php#passive

4. Save exit, and restart both services - "NCPA Listener" and "NCPA Passive" on the Windows machine.

5. Wait for 5+ minutes, and check the ncpa_passive.log to see if your script ran, and results were sent to your Nagios server.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked