Config for external scripts for 0.4?


#1

Hi,

I installed 0.4.1.61 from the msi and tried the created sample ini.[[BR]]

I use nrpe and CheckExternalScripts=1[[BR]]

Nagios-checks like alias_disk or alias_mem work ok, but vbs scripts don’t.

Example:

alias_updates = check_updates.vbs -warning 0 -critical 0
(from sample config)

alias_updates is registered ok when starting “nscp test”, but a check ends up with

NSClient++.cpp:953 No handler for command: alias_update

No handler for command: check_updates.vbs

I tried several config lines for wrapping and setting script path from doku and web sites, but no success.[[BR]]

Could anyone give me the full config to enable the use of vbs and bat (or a link to a doc ) please?

Cereus


#2

Hi Cereus,

I am struggling with exactly the same problem for hours and I have no idea. Guess it is some sort of bug. Anyone? Please!

beaker


#3

I added the following options to my nsclient.ini:

{{{
/settings/NRPE/server]
allowed hosts =
allow arguments = true
allow nasty characters = true
port = 5666
timeout = 60
use ssl = 1
performance data = 1

[/settings/external scripts/wrappings]
vbs=cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs %SCRIPT% %ARGS%
bat=scripts\%SCRIPT% %ARGS%
ps1=cmd /c echo scripts\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -

[/settings/external scripts]
allow arguments = 1
allow nasty characters = 1
timeout = 60

[/settings/external scripts/scripts]
check_upd = cscript.exe //T:40 //NoLogo scripts/check_updates.vbs -warning 0 -critical 0
}}}

Running ‘nrpe test’ and testing on check_updates and check_upd I get the following output:

{{{

d rvice\NSClient++.cpp:612 NSClient++ - 0,4,1,61 2012-10-24 Started!
l ce\simple_client.hpp:32 Enter command to inject or exit to terminate…
check_updates
d rvice\NSClient++.cpp:933 Injecting: check_updates…
NOT FOUND
e rvice\NSClient++.cpp:953 No handler for command: check_updates avalible comma
nds: commands {, alias_cpu, alias_cpu_ex, alias_disk, alias_disk_loose, alias_ev
ent_log, alias_file_age, alias_file_size, alias_mem, alias_process, alias_proces
s_count, alias_process_hung, alias_process_stopped, alias_sched_all, alias_sched
_long, alias_sched_task, alias_service, alias_service_ex, alias_up, alias_update
s, alias_volumes, alias_volumes_loose, check_cpu, check_eventlog, check_memory,
check_nscp, check_ok, check_pattern, check_pdh, check_process, check_registry, c
heck_service, check_upd, check_uptime, check_win_updates, checkalwayscritical, c
heckalwaysok, checkalwayswarning, checkcounter, checkcpu, checkcritical, checkdr
ivesize, checkeventlog, checkfile2, checkfiles, checkfilesize, checkmem, checkmu
ltiple, checkok, checkprocstate, checkservicestate, checksingleregentry, checkup
time, checkversion, checkwarning, checkwmi, checkwmivalue, listcounterinstances,
nsca_exec, nsca_forward, nsca_help, nsca_query, nsca_submit}, plugins {, 0, 1,
2, 3, 4, 5, 6, 8}
l ce\simple_client.hpp:74 No handler for command: check_updates
check_upd
d rvice\NSClient++.cpp:933 Injecting: check_upd…
d kExternalScripts.cpp:258 Arguments: //T:40 //NoLogo scripts/check_updates.vbs
-warning 0 -critical 0
d rvice\NSClient++.cpp:958 Result check_upd: OK
l ce\simple_client.hpp:80 OK:C:\Program Files\NSClient++\scripts\check_updates
.vbs(15, 1) Laufzeitfehler in Microsoft VBScript: Klasse nicht definiert: ‘Nagio
sPlugin’
}}}

Looks like nsclient++ cannt access the handler check_updates at all. Defining my own leads to that error of a class ‘NagiosPlugin’ missing.

How much do I need to donate to get this fixed soon?

beaker


#4

Hm, I tried several vbs scripts at the command line of my windows xp machine:

Some interesting tools I found somewhere like

check_users_loggedin
check_updates_available (not the above check_updates)

are working OK from command line, check_updates doesn’t

but is resulting in error

class not defined: NagiosPlugin[[BR]]

code 800A01FA[[BR]]

source runtime eroor in VBscript

Running all these scripts via Nagios/nrpe results in the same
"no handler" error

Cereus


#5

The problem is that you are trying to run a VB script which use the NagiosPlugin lib.

To run them you need to use the wrapper script like so:
{{{
cscript //NOLOGO [c-script options] wrapper.vbs
}}}

// Michael Medin


#6

The Problem remains.

Running the script locally on the Windows Machine works fine:

{{{
C:\Program Files\NSClient++>cscript.exe //NOLOGO scripts\lib\wrapper.vbs check_updates.vbs
OK: Number of critical updates not installed: 1
Number of software updates not installed: 71
Critical updat
es name: Definition Update for Windows Defender - KB915597 (Definition 1.141.28.0)+
}}}

But defined as an Alias-Command it fails:

{{{
[/settings/external scripts/alias]

alias_updates_2k8 = cscript.exe //NoLogo scripts\lib\wrapper.vbs check_updates.vbs
}}}

{{{
$ /usr/local/icinga/libexec/check_nrpe -H 10.85.58.113 -t 60 -p 5666 -c alias_updates_2k8
No handler for command: cscript.exe
}}}

Using the full path to cscript.exe ({{{c:\windows\system32\cscript.exe}}}) does not help neither.

Is this a bug?

I would highly appreacitate if someone could point me into the right direction to solve this issue.

Thank you very much in advance.

beaker


#7

Ahh…
alias is one ting scripts is another…

/settings/external scripts/’’‘scripts’’’
{{{
[/settings/external scripts/scripts]

alias_updates_2k8 = cscript.exe //NoLogo scripts\lib\wrapper.vbs check_updates.vbs
}}}

/settings/external scripts/’’‘alias’’’
{{{
[/settings/external scripts/alias]

alias_updates_2k8 = CheckCPU…
}}}

Aliases are for wrapping internal commands, scripts is for running external commands…

// Michael Medin


#8

Thank you very much for your swift and helpful answer.

Your suggestion works:

{{{
$ /usr/local/icinga/libexec/check_nrpe -H 10.85.58.113 -t 60 -p 5666 -c alias_updates_2k8
OK: There is no critical updates
Number of software or driver updates not installed: 45
}}}

But it doesnt when using the “wrappings”-section:

{{{
[/settings/external scripts]
timeout = 60

[/settings/external scripts/wrappings]
bat = scripts\%SCRIPT% %ARGS%
ps1 = cmd /c echo scripts\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -
vbs = cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs %SCRIPT% %ARGS%

[/settings/external scripts/scripts]

; Windows updates
alias_updates_2k8 = cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs scripts\check_updates.vbs
alias_check_win_updates = check_updates.vbs
}}}

{{{
$ /usr/local/icinga/libexec/check_nrpe -H 10.85.58.113 -t 60 -p 5666 -c alias_check_win_updates
ExternalCommands: failed to create process (scripts\check_updates.vbs ): it is not an exe file (check NSC.log for more info) - failed to lookup error code: 193( reson: 87)
}}}

What do I do wrong this time? Would be great if you could help me with this one too.

beaker


#9

Don’t know the syntax off the top of my head. wrapped scripts are in a different section…

So (and I am guessing here, since I don’t have NSClient++ at work):
{{{
[/settings/external scripts/wrapped scripts]
alias_check_win_updates = check_updates.vbs
}}}

Would work…

You can generate a config file with relevant section by running:
{{{
nscp settings --generate --add-defaults
}}}

Which is a nice way to get the right sections and keywords…
’’‘please notice’’’ this will add a lot of keys…
You can remove them (ish) using the following command (if I recall correctly):
{{{
nscp settings --remove-defaults
}}}

‘’‘PLEASE NOTICE’’’ These commands ‘’‘CHANGE your config’’’ so please make a backup before so you want break things…

// Michael Medin


#10

Thank you. This hint helped me to fix the problem. It should be:

{{{
[/settings/external scripts/wrappings]
vbs = cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs %SCRIPT% %ARGS%
[/settings/external scripts/wrapped scripts]
alias_check_win_updates = scripts\check_updates.vbs
}}}

These two commands are as well really nice to find errors in configuration. Specifically keywords in wrong sections.

{{{
nscp settings --generate --add-defaults
nscp settings --generate --remove-defaults
}}}

beaker


#11

Since there is the alias-command “alias_updates” in the default configuration file I modified it as follows:

{{{
[/settings/external scripts/wrappings]
bat = scripts\%SCRIPT% %ARGS%
ps1 = cmd /c echo scripts\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command -
vbs = cscript.exe //T:30 //NoLogo scripts\lib\wrapper.vbs %SCRIPT% %ARGS%

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

[/settings/external scripts/alias]
alias_updates = check_updates -warning 0 -critical 0
}}}

This works now:

{{{
$ /usr/local/icinga/libexec/check_nrpe -H 10.85.58.113 -t 60 -p 5666 -c alias_updates
OK: There is no critical updates
Number of software or driver updates not installed: 45
}}}

Great!!!

Please consider to add this to the default configuration. There must be other fans out there who struggle with this.

Thank you again for pointing me into the right direction.

beaker


#12

I found another isse related to this configuration. It works but validation is sort of unhappy:

{{{
C:\Program Files\NSClient++>nscp.exe settings --validate
Invalid key: /settings/external scripts/wrapped scripts.check_updates
Invalid key: /settings/external scripts/wrappings.bat
Invalid key: /settings/external scripts/wrappings.ps1
Invalid key: /settings/external scripts/wrappings.vbs
}}}

Any idea?

beaker


#13

Probably a bug…

Validation compares actual config to “reistred config” ie. what the module says it knows about.
So the module probaby dont tell anyone about the wrapped scripts section.

Will fix…


#14

Hi,

I do have similar problems with my nsclient++.

check_upadtes:

local on the win server: cscript.exe //NOLOGO scripts\lib\wrapper.vbs check_updates.vbs OK …

on icinga2: /check_nrpe -H IP -t 60 -p 5666 -c alias_updates_2k8 CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.

My sec. problems: Uptime does ony show up critical:

alias_up CRITICAL: uptime: 0:36h, boot: 2016-Dez-21 08:58:26 (UTC)|‘uptime’=2210s;172800;86400

Client version 0.4.3

Thanks