我在Centos 7机器上运行Nagios 3.5。 该设置用于通过NRPE(check_nrpe命令)监视某些Windows机器。 目前我正在使用'nsclient-full.ini'文件中预先configuration的'别名'命令。 到目前为止,一切正常。
我想使用'alias_updates'命令来监视主机上Windows Update的状态。
; 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
当然,我已经检查了我提供的path中存在“check_updates.vbs”。 毕竟,它与NSClient ++捆绑在一起。
我已经启用了外部脚本的执行:
; Check External Scripts - A simple wrapper to run external scripts and batch files. CheckExternalScripts = 1
其他相关的configuration选项(在我看来)是:
; 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 ++的文档只能给我带来…
更新1:
我遵循迈克尔·梅丁提供的指示信。 现在我的'nsclient-full.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'
在一个侧面说明,它看起来像插件返回“确定”,因为在Nagios的对应框是绿色的。
更新2:
在NSClient ++论坛search后,我发现有人有同样的问题。 原来我错过了一个'\':
check_updates=scripts\check_updates.vbs
应该:
check_updates=scripts\\check_updates.vbs
但是我仍然无法工作。 看起来脚本的通信和执行现在可以,但操作超时。 如果我从命令行用'-t'选项覆盖超时到120s,我得到这个错误消息:
CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.
正如krisFR指出,你需要用cscript.exe(和其他各种选项)前缀vbs文件。
在Windows中的脚本不像UNIX中的脚本那样工作,所以它们不是由它们自己(ish)“运行”的。 因此所有的脚本都必须以运行时为前缀。
理论上这应该logging在这里: http : //docs.nsclient.org/howto/external_scripts.html#languages,但我看到它是失踪,所以我会尽量更新它尽快。
check_updates=cscript.exe //T:30 //NoLogo "scripts\\check_updates.vbs"
解决这个问题的另一种方法是在NSClient ++中使用所谓的“包装”脚本,然后你可以定义“macros”来执行各种扩展。
[/settings/external scripts/wrappings] vbs=cscript.exe //T:30 //NoLogo %SCRIPT% %ARGS% [/settings/external scripts/wrapped scripts] check_updates=scripts\check_updates.vbs
更多细节可以在这里find: http : //docs.nsclient.org/howto/external_scripts.html#wrapped-scripts