我正在Centos 7机器上运行Nagios 3.5。该设置用于通过NRPE (check_nrpe命令)监视某些Windows机器。目前,我正在使用“nsclient-ful.ini”文件中预先配置的“别名”命令。到目前为止一切都很顺利。
我希望使用'alias_updates‘命令监视我的主机上的Windows更新的状态。
; alias_updates - Alias for alias_updates.
alias_updates = check_updates -warning 0 -critical 0 ShowAll=long以下是定义所有外部脚本的部分:
; 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当然,我已经检查了“check_updates.vbs”是否存在于我提供的路径中。毕竟,它与NSClient++捆绑在一起。
我已经启用了外部脚本的执行:
; Check External Scripts - A simple wrapper to run external scripts and batch files.
CheckExternalScripts = 1其他相关的配置选项(我认为)是:
; 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在Nagios服务器上,在命令提示符下,我尝试这样做:
[root@mama365-account plugins]# ./check_nrpe -H 192.168.10.13 -c alias_updates我得到的回应是:
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)我知道NSClient可以运行不是可执行的插件(*.exe),而仅仅是脚本。这是一个VB脚本。此外,Nagios GUI中也会显示相同的错误消息,并显示在与命令对应的框中。
有人知道怎么解决这个问题吗?读NSClient++的文档只给我带来了..。
我按照迈克尔·梅丁的指示写了这封信。现在我的‘nsclient-ful.ini’看起来是这样的:
; 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%问题是,现在我又收到了另一个错误,这一次与vb脚本的执行有关:
C:Program FilesNSClient++scriptscheck_updates.vbs(15, 1) Microsoft VBScript runtime error: Class not defined: 'NagiosPlugin' 另外,看起来插件返回了'OK‘,因为Nagios中的相应框是绿色的。
在NSClient++论坛上搜索之后,我发现了一个有同样问题的人。原来我错过了一个“\”:
check_updates=scripts\check_updates.vbs应:
check_updates=scripts\\check_updates.vbs但我还是不能让它起作用。看起来脚本的通信和执行现在还可以,但是操作超时了。如果我使用命令行中的“-t”选项将超时重写为120,则会得到以下错误消息:
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.发布于 2014-10-28 07:41:27
正如krisFR所指出的,您需要在vbs文件前面加上cscript.exe (以及其他各种选项)。
windows中的脚本不像unix中的脚本那样工作,因此它们不能由自己(ish)“运行”。因此,所有脚本都必须以其运行时为前缀。
理论上,应该在这里记录这一点:http://docs.nsclient.org/howto/external_scripts.html#languages,但我发现它缺少,所以我将尝试尽快更新它。
check_updates=cscript.exe //T:30 //NoLogo "scripts\\check_updates.vbs"
解决这一问题的另一种方法是在NSClient++中使用所谓的“包装”脚本,然后您可以定义“宏”用于执行各种扩展:
[/settings/external scripts/wrappings]
vbs=cscript.exe //T:30 //NoLogo %SCRIPT% %ARGS%
[/settings/external scripts/wrapped scripts]
check_updates=scripts\check_updates.vbs更多细节可以在这里找到:http://docs.nsclient.org/howto/external_Scripts.html#外包装-脚本
https://serverfault.com/questions/639991
复制相似问题