我无法聚合我编写的一些自定义图表。我知道聚合是可行的,因为我能够聚合默认插件,但我不确定我的插件出了什么问题。
munin.conf:
[myapp;web-servers;0-1]
address 1.2.3.4
use_node_name yes
[myapp;web-servers;0-2]
address 5.6.7.8
use_node_name yes
[myapp;web-servers;Aggregated]
update no
#does not work:
node_aggregate.graph_args --base 1000 -l 0
node_aggregate.graph_title Aggregated connects
node_aggregate.conns.label conns
node_aggregate.conns.sum myapp;web-servers;0-1:nodejs_numberOfConnects.conns myapp;web-servers;0-2:nodejs_numberOfConnects.conns
#works:
node_aggregate.graph_title Aggregated cpu
node_aggregate.cpu.label cpu.user
node_aggregate.cpu.sum myapp;web-servers;0-1:cpu.user myapp;web-servers;0-2:cpu.user
我的插件如下所示:
if [[ "$PARAM" == "numberOfConnects" ]]; then
echo "graph_title Active Connects";
echo "graph_info Active Connects";
echo "graph_vlabel Connections";
echo "$PARAM.label conns";
echo "$PARAM.type GAUGE";
echo "$PARAM.colour 0927EB"
exit 0;
elif ...
fi
echo $PARAM.value 15
为了测试目的,我可以硬编码“$PARAM.value 15”。然后我可以执行
munin-run --servicedir /etc/munin/plugins nodejs_numberOfConnects
此操作,这将返回numberOfConnects.value 15
我得到的错误是:
==> /var/log/munin/munin-graph.log <==
2016/03/15 13:57:01 [ERROR] filename is empty for $VAR1 = {
'#%#name' => 'z1_0',
'cdef' => 'z1_0,UN,0,z1_0,IF',
'graph' => 'no',
'label' => 'z1_0'
};
, myapp;web-servers;0-1:nodejs_numberOfConnects.conns
2016/03/15 13:57:01 [ERROR] filename is empty for $VAR1 = {
'#%#name' => 'z1_1',
'cdef' => 'z1_1,UN,0,z1_1,IF,z1_0,ADDNAN',
'colour' => undef,
'draw' => undef,
'graph' => 'yes',
'label' => 'conns'
};
, myapp;web-servers;0-2:nodejs_numberOfConnects.conns
答案1
您正在尝试通过康纳斯作为导出的值,但实际上连接数
node_aggregate.nodejs_numberOfConnects.label conns(or whatever)
node_aggregate.nodejs_numberOfConnects.sum \
myapp;web-servers;0-1:nodejs_numberOfConnects.numberOfConnects \
myapp;web-servers;0-2:nodejs_numberOfConnects.numberOfConnects
答案2
经过多次调试后,我意识到我错误地使用了标签而不是名称价值。
node_aggregate.conns.sum myapp;web-servers;0-1:nodejs_numberOfConnects.conns myapp;web-servers;0-2:nodejs_numberOfConnects.conns
需要是
node_aggregate.conns.sum myapp;web-servers;0-1:nodejs_numberOfConnects.numberOfConnects myapp;web-servers;0-2:nodejs_numberOfConnects.numberOfConnects
因为
if [[ "$PARAM" == "numberOfConnects" ]]; then
[...]
echo $PARAM.value 15
换句话说,在我的例子中,服务器行等于:
$arbitraryname1.arbitraryname2.sum $clientname;$hostgroup;$hostname:$pluginname.$valuename
cpu
我还对使用以下语法的示例感到非常困惑:
myapp;web-servers;0-1:cpu.user
但那是因为它的值名称实际上与标签名称一致!