我无法获取定义的插件,该插件是使用 Munin-node-win32 (1.6.1) 运行的批处理文件。
根据自述,它能够集成本[ExternalPlugin]
节中定义的外部插件:
* External Plugin:
* A plugin that supports external plugins in the style of munin-node.
* Configuration in [ExternalPlugin] section. Just add an entry with the
path to the program to run, It doesn't matter what the name of the
name=value pair is.
* The output of the external program should be similar to the following,
* Note: add quotes (") around the value if it has spaces! ::
>disk_free.py name
drive_free
>disk_free.py
drive_free_c.value 40.3635149113
.
>disk_free.py config
graph_title Filesystem free (in %)
graph_category disk
graph_info This graph shows the amount of free space on each disk.
graph_args --upper-limit 100 -l 0
graph_vlabel %
drive_free_c.label C:
.
我对插件的定义如下:
[ExternalPlugin]
; For External Plugins just add an entry with the path to the program to run
; It doesn't matter what the name of the name=value pair is
rdsessions="C:\Program Files\Monitoring-Scripts\munin-rdsessions.bat"
并且批处理文件似乎正在按照文档的要求返回输出:
C:\Program Files\Monitoring-Scripts>.\munin-rdsessions.bat name
rdsessions
C:\Program Files\Monitoring-Scripts>.\munin-rdsessions.bat
total.value "6.000000"
active.value "1.000000"
.
C:\Program Files\Monitoring-Scripts>.\munin-rdsessions.bat config
graph_title Remote Desktop Sessions
graph_category system
graph_args --upper-limit 15 -l 0 -r
graph_vlabel Sessions
graph_order total active
total.label Total sessions
active.label Active sessions
.
C:\Program Files\Monitoring-Scripts>
但是 Munin 节点没有在查询时将“rdsessions”列为可用插件:
$ telnet rdsh-02.example.com 4949
Trying 192.168.21.85...
Connected to rdsh-02.example.com.
Escape character is '^]'.
# munin node at rdsh-02
list
df memory processes network cpu hdd
到目前为止,我已经找到了Munin-node-win32 的错误报告关于.cmd
作为外部插件的答案暗示了最后的点对于插件的功能至关重要,并揭示了许多人在集成外部插件时遇到了问题。
基于此,我设置了批处理文件,在将输出写入 stdout 之前先将其写入临时文件,这样我就可以检查不可打印的字符、空格和换行符。但一切看起来都正常。我还尝试使用设置/p hack,但无济于事 - 该插件从未出现在列表中。每次我对批处理文件进行更改时,我都会重新启动 Munin 服务。
那么 Munin-node-win32 有什么问题,它不喜欢我的批处理?
批次上市:
@echo off
set OUTFILE=%TEMP%\munin-rdsessions.output
if "%1" == "config" goto config
if "%1" == "name" (echo rdsessions && goto end)
for /F "usebackq delims=, tokens=2,3,4" %%a IN (`typeperf -sc 1 "Terminaldienste\Sitzungen insgesamt" "Terminaldienste\Aktive Sitzungen" ^| find /V "(PDH-CSV"`) do (
echo total.value %%a>%OUTFILE%
echo active.value %%b>>%OUTFILE%
echo .>>%OUTFILE%
)
type %OUTFILE%
goto end
:config
type "%~dpn0.conf"
goto end
:end
答案1
事实证明,munin-node-win32 对于“name”输出末尾的空格非常谨慎。因此,如下所示的一行
if "%1" == "name" (echo rdsessions && goto end)
会导致 munin-node-win32 直接接受插件定义。调用末尾的空格echo
必须删除才能正常工作:
if "%1" == "name" (echo rdsessions&&goto end)