2

I am running Nagios 3.5 on a Centos 7 machine. The setup is used to monitor some Windows machines via NRPE (check_nrpe commands). For the time being I am using the preconfigured 'alias' commands that come in the 'nsclient-full.ini' file. Everything is working fine so far.

I want to monitor the state of the Windows Updates on my hosts, using the 'alias_updates' command.

; alias_updates - Alias for alias_updates.
alias_updates = check_updates -warning 0 -critical 0 ShowAll=long

Here is the section where all external scripts are defined:

; A list of scripts available to run from the CheckExternalScripts module.
[/settings/external scripts/scripts]
check_updates=C:\Program Files\NSClient++\scripts\check_updates.vbs

Of course I have checked that 'check_updates.vbs' exists in the path I provided. After all, it came bundled with NSClient++.

I have enabled the execution of external scripts:

; Check External Scripts - A simple wrapper to run external scripts and batch files.
CheckExternalScripts = 1

The other relevant configuration options (in my opinion) are:

; Section for NRPE (NRPEServer.dll) (check_nrpe) protocol options.
[/settings/NRPE/server]

; COMMAND ARGUMENT PROCESSING
allow arguments = true

; COMMAND ALLOW NASTY META CHARS
allow nasty characters = false

; PORT NUMBER - Port to use for NRPE.
port = 5666


; Section for external scripts configuration options (CheckExternalScripts).
[/settings/external scripts]

; COMMAND ARGUMENT PROCESSING
allow arguments = true

; COMMAND ALLOW NASTY META CHARS
allow nasty characters = false

; SCRIPT DIRECTORY
script path = 

; COMMAND TIMEOUT
timeout = 60

On the Nagios server, from the command prompt, I am trying this:

[root@mama365-account plugins]# ./check_nrpe -H 192.168.10.13 -c alias_updates

The response I am getting is this:

ExternalCommands: failed to create process (C:\Program Files\NSClient++\scripts\check_updates.vbs): it is not an exe file (check NSC.log for more info) - failed to lookup error code: 193( reson: 87)

I understand that NSClient can run plugins that are not executable (*.exe), but merely scripts. And this one is a VB script. Also, the same error message is displayed in the Nagios GUI, in the box corresponding with the command.

Anyone has any idea how to fix this? Reading the docs for NSClient++ has only brought me so far...

UPDATE 1:

I followed the instructions provided by Michael Medin to the letter. Now my 'nsclient-full.ini' looks like this:

; A list of wrappped scripts (ie. using the template mechanism)
[/settings/external scripts/wrapped scripts]
check_updates=scripts\check_updates.vbs

; VISUAL BASIC WRAPPING - 
vbs=cscript.exe //T:30 //NoLogo %SCRIPT% %ARGS%

The thing is, now I am getting another error, this time something to do with the execution of the vb script:

C:Program FilesNSClient++scriptscheck_updates.vbs(15, 1) Microsoft VBScript runtime error: Class not defined: 'NagiosPlugin' 

On a side note, it looks like the plugin returned 'OK' though, as the corresponding box in Nagios is green.

UPDATE 2:

After searching in the NSClient++ forums I found someone with the same issue. Turns out I was missing a '\':

check_updates=scripts\check_updates.vbs

Should be:

check_updates=scripts\\check_updates.vbs

But I still cannot make it work. It looks like the communication and execution of the script is OK now, but the operation times out. If I override the timeout to 120s with the '-t' option from the command line, I get this error message:

CHECK_NRPE: Received 0 bytes from daemon.  Check the remote server logs for error messages.
  • What if you try something like check_updates=cscript.exe "C:\Program Files\NSClient++\scripts\check_updates.vbs" ? – krisFR Oct 27 '14 at 20:01
  • Will try tomorow and report back. – dsljanus Oct 27 '14 at 20:02
  • Not sure if I should respond here as well... nsclient-full.ini is a sample file not a config file, so updating that wont change much... I really really regret the naming of that file... (see other comment to your comment below) – Michael Medin Oct 30 '14 at 7:01
3

As krisFR pointed out you need to prefix vbs file with cscript.exe (and various other options) .

Script in windows does not work like scripts in unix so they are not "runnable" by them selves (ish). Thus all scripts has to be prefixed with their runtime.

In theory this should be documented here: http://docs.nsclient.org/howto/external_scripts.html#languages but I see it is missing so I shall try to update it ASAP.

check_updates=cscript.exe //T:30 //NoLogo "scripts\\check_updates.vbs"

Another way to resolve this is to use the so called "wrapped" scripts in NSClient++ then you can define "macros" for how various extensions are executed:

[/settings/external scripts/wrappings]
vbs=cscript.exe //T:30 //NoLogo %SCRIPT% %ARGS%

[/settings/external scripts/wrapped scripts]
check_updates=scripts\check_updates.vbs

More details can be found here: http://docs.nsclient.org/howto/external_scripts.html#wrapped-scripts

  • Followed instructions. Please see update. – dsljanus Oct 29 '14 at 7:45
  • nsclient-full.ini is a sample file not a config file, so updating that wont change much... I really really regret the naming of that file... – Michael Medin Oct 29 '14 at 11:55
  • A few other things to be wary of: 1. The best way to debug this is running nsclient++ in "test mode" (i.e. nscp test), 2. The version is important as file format has changed between 03.x and 0.4.x – Michael Medin Oct 29 '14 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.