![如何在 munin 中获取总带宽图](https://linux22.com/image/540592/%E5%A6%82%E4%BD%95%E5%9C%A8%20munin%20%E4%B8%AD%E8%8E%B7%E5%8F%96%E6%80%BB%E5%B8%A6%E5%AE%BD%E5%9B%BE.png)
我的所有服务器上的 munin-node 都具有基本的默认配置,我想创建一个显示 http 输入/输出总带宽的摘要图表,以及另一个显示所有接口输入/输出总带宽的图表。
[编辑] 按照第一个发帖人的建议后,我目前到这里;
我正在尝试实现 if_eth0 服务的正常运行/宕机的汇总 SUM 图
根据常见问题解答中的详细信息; http://munin-monitoring.org/wiki/faq#Q:HowdoIusefieldname.sum
以及详细的例子; http://munin-monitoring.org/wiki/aggregate_examples
以及这篇关于聚合物的有趣文章; http://blog.loftninjas.org/2010/04/08/an-evening-with-munin-graph-aggregation/
我在 /etc/munin/munin.conf 中定义以下内容我的主机;
[cirrusj1605.hpl.com]
address 19x.xx.xx.205
use_node_name yes
[cirrusj1606.hpl.com]
address 19x.xx.xx.206
use_node_name yes
...
以及像这样的聚合虚拟主机;
[hpl.com;aggregates] 更新 无联系人 无
total_bandwidth.graph_title Aggregated bandwidth
total_bandwidth.upload.label upload
total_bandwidth.upload.sum \
cirrusj1605.hpl.com:if_eth0:up \
cirrusj1606.hpl.com:if_eth0:up
如果我尝试手动运行 munin-graph,则在生成每个图表时会出现以下错误;
2011/02/24 20:04:39 [RRD 错误] 无法绘制图表 /var/www/html/munin/hpl.com/aggregates/total_bandwidth-month.png : az1_0、UN、0、az1_0、IF、、+ 中的 rpn 表达式无效
完整的跟踪如下,对于问题可能是什么,有什么建议吗?
谢谢,T
> -bash-3.2$ /usr/share/munin/munin-graph --debug
> --nofork --nolazy --host aggregates 2011/02/24 20:04:39 [DEBUG] Creating
> new lock file
> /var/run/munin/munin-graph.lock
> 2011/02/24 20:04:39 [DEBUG] Creating
> lock : /var/run/munin/munin-graph.lock
> succeeded 2011/02/24 20:04:39 Starting
> munin-graph 2011/02/24 20:04:39
> [DEBUG] Doing work synchrnonously
> 2011/02/24 20:04:39 [DEBUG] Node name:
> total_bandwidth 2011/02/24 20:04:39
> [DEBUG] Expanding specials for
> total_bandwidth: "upload". 2011/02/24
> 20:04:39 DEBUG: expand_specials
> (cirrusj1605.hpl.com:if_eth0:up):
> Doing sum... 2011/02/24 20:04:39
> [DEBUG] Checking field lengths for
> total_bandwidth:
> "z1_0=cirrusj1605.hpl.com:if_eth0:up".
> 2011/02/24 20:04:39 [DEBUG] Treating
> fields
> "z1_0=cirrusj1605.hpl.com:if_eth0:up","upload".
> 2011/02/24 20:04:39 [DEBUG] Processing
> field "z1_0" [z1_0]. 2011/02/24
> 20:04:39 [PERL WARNING] Use of
> uninitialized value in subroutine
> entry at
> /usr/lib/perl5/vendor_perl/5.8.8/Munin/Master/GraphOld.pm
> line 757. 2011/02/24 20:04:39 DEBUG:
> single_value: Checking field "z1_0".
> 2011/02/24 20:04:39 DEBUG:
> single_value: Checking field "upload".
> 2011/02/24 20:04:39 [DEBUG] service
> hpl.com :: aggregates ::
> total_bandwidth has 2 elements.
> 2011/02/24 20:04:39 [PERL WARNING] Use
> of uninitialized value in
> concatenation (.) or string at
> /usr/lib/perl5/vendor_perl/5.8.8/Munin/Master/GraphOld.pm
> line 774. 2011/02/24 20:04:39 [DEBUG]
> RRD name / filename: z1_0 / 2011/02/24
> 20:04:39 [PERL WARNING] Use of
> uninitialized value in concatenation
> (.) or string at
> /usr/lib/perl5/vendor_perl/5.8.8/Munin/Master/GraphOld.pm
> line 783. 2011/02/24 20:04:39 [PERL
> WARNING] Use of uninitialized value in
> concatenation (.) or string at
> /usr/lib/perl5/vendor_perl/5.8.8/Munin/Master/GraphOld.pm
> line 785. 2011/02/24 20:04:39 [PERL
> WARNING] Use of uninitialized value in
> concatenation (.) or string at
> /usr/lib/perl5/vendor_perl/5.8.8/Munin/Master/GraphOld.pm
> line 786. 2011/02/24 20:04:39 [DEBUG]
> Field name after cdef set to cdefz1_0
> 2011/02/24 20:04:39 [DEBUG] Drawing
> field "z1_0". 2011/02/24 20:04:39
>
> rrdtool 'graph' '--font' \
> 'LEGEND:7:/usr/share/fonts/bitstream-vera/VeraMono.ttf'
> \
> '--font' \
> 'UNIT:7:/usr/share/fonts/bitstream-vera/VeraMono.ttf'
> \
> '--font' \
> 'AXIS:7:/usr/share/fonts/bitstream-vera/VeraMono.ttf'
> \
> '-W' \
> 'Munin 1.4.5' \
> '/var/www/html/munin/hpl.com/aggregates/total_bandwidth-month.png'
> \
> '--title' \
> 'Aggregated bandwidth - by month' \
> '--start' \
> '-33d' \
> '--height' \
> '175' \
> '--width' \
> '400' \
> '--imgformat' \
> 'PNG' \
> 'DEF:az1_0=:42:MAX' \
> 'DEF:iz1_0=:42:MIN' \
> 'DEF:gz1_0=:42:AVERAGE' \
> 'CDEF:acdefz1_0=az1_0,UN,0,az1_0,IF,,+'
> \
> 'CDEF:icdefz1_0=iz1_0,UN,0,iz1_0,IF,,+'
> \
> 'CDEF:gcdefz1_0=gz1_0,UN,0,gz1_0,IF,,+'
> \
> 'CDEF:ccdefz1_0=gcdefz1_0' \
> 'COMMENT: ' \
> 'COMMENT: Cur\:' \
> 'COMMENT:Min\:' \
> 'COMMENT:Avg\:' \
> 'COMMENT:Max\: \j' \
> 'LINE1.6:gcdefz1_0#00CC00:upload ' \
> 'GPRINT:ccdefz1_0:LAST:%6.2lf%s' \
> 'GPRINT:icdefz1_0:MIN:%6.2lf%s' \
> 'GPRINT:gcdefz1_0:AVERAGE:%6.2lf%s' \
> 'GPRINT:acdefz1_0:MAX:%6.2lf%s\j' \
> 'COMMENT:Last update\: Wed Dec 31 16\:00\:00 1969\r' 2011/02/24 20:04:39
> [RRD ERROR] Unable to graph
> /var/www/html/munin/hpl.com/aggregates/total_bandwidth-month.png
> : invalid rpn expression in:
> az1_0,UN,0,az1_0,IF,,+ 2011/02/24
> 20:04:39
>
> rrdtool 'graph' '--font' \
> 'LEGEND:7:/usr/share/fonts/bitstream-vera/VeraMono.ttf'
> \
> '--font' \
> 'UNIT:7:/usr/share/fonts/bitstream-vera/VeraMono.ttf'
> \
> '--font' \
> 'AXIS:7:/usr/share/fonts/bitstream-vera/VeraMono.ttf'
> \
> '-W' \
> 'Munin 1.4.5' \
> '/var/www/html/munin/hpl.com/aggregates/total_bandwidth-week.png'
> \
> '--title' \
> 'Aggregated bandwidth - by week' \
> '--start' \
> '-8d' \
> '--height' \
> '175' \
> '--width' \
> '400' \
> '--imgformat' \
> 'PNG' \
> 'DEF:az1_0=:42:MAX' \
> 'DEF:iz1_0=:42:MIN' \
> 'DEF:gz1_0=:42:AVERAGE' \
> 'CDEF:acdefz1_0=az1_0,UN,0,az1_0,IF,,+'
> \
> 'CDEF:icdefz1_0=iz1_0,UN,0,iz1_0,IF,,+'
> \
> 'CDEF:gcdefz1_0=gz1_0,UN,0,gz1_0,IF,,+'
> \
> 'CDEF:ccdefz1_0=gcdefz1_0' \
> 'COMMENT: ' \
> 'COMMENT: Cur\:' \
> 'COMMENT:Min\:' \
> 'COMMENT:Avg\:' \
> 'COMMENT:Max\: \j' \
> 'LINE1.6:gcdefz1_0#00CC00:upload ' \
> 'GPRINT:ccdefz1_0:LAST:%6.2lf%s' \
> 'GPRINT:icdefz1_0:MIN:%6.2lf%s' \
> 'GPRINT:gcdefz1_0:AVERAGE:%6.2lf%s' \
> 'GPRINT:acdefz1_0:MAX:%6.2lf%s\j' \
> 'COMMENT:Last update\: Wed Dec 31 16\:00\:00 1969\r' 2011/02/24 20:04:39
> [RRD ERROR] Unable to graph
> /var/www/html/munin/hpl.com/aggregates/total_bandwidth-week.png
> : invalid rpn expression in:
> az1_0,UN,0,az1_0,IF,,+ 2011/02/24
> 20:04:39
>
> rrdtool 'graph' '--font' \
> 'LEGEND:7:/usr/share/fonts/bitstream-vera/VeraMono.ttf'
> \
> '--font' \
> 'UNIT:7:/usr/share/fonts/bitstream-vera/VeraMono.ttf'
> \
> '--font' \
> 'AXIS:7:/usr/share/fonts/bitstream-vera/VeraMono.ttf'
> \
> '-W' \
> 'Munin 1.4.5' \
> '/var/www/html/munin/hpl.com/aggregates/total_bandwidth-day.png'
> \
> '--title' \
> 'Aggregated bandwidth - by day' \
> '--start' \
> '-30h' \
> '--height' \
> '175' \
> '--width' \
> '400' \
> '--imgformat' \
> 'PNG' \
> 'DEF:az1_0=:42:MAX' \
> 'DEF:iz1_0=:42:MIN' \
> 'DEF:gz1_0=:42:AVERAGE' \
> 'CDEF:acdefz1_0=az1_0,UN,0,az1_0,IF,,+'
> \
> 'CDEF:icdefz1_0=iz1_0,UN,0,iz1_0,IF,,+'
> \
> 'CDEF:gcdefz1_0=gz1_0,UN,0,gz1_0,IF,,+'
> \
> 'CDEF:ccdefz1_0=gcdefz1_0' \
> 'COMMENT: ' \
> 'COMMENT: Cur\:' \
> 'COMMENT:Min\:' \
> 'COMMENT:Avg\:' \
> 'COMMENT:Max\: \j' \
> 'LINE1.6:gcdefz1_0#00CC00:upload ' \
> 'GPRINT:ccdefz1_0:LAST:%6.2lf%s' \
> 'GPRINT:icdefz1_0:MIN:%6.2lf%s' \
> 'GPRINT:gcdefz1_0:AVERAGE:%6.2lf%s' \
> 'GPRINT:acdefz1_0:MAX:%6.2lf%s\j' \
> 'COMMENT:Last update\: Wed Dec 31 16\:00\:00 1969\r' 2011/02/24 20:04:39
> [RRD ERROR] Unable to graph
> /var/www/html/munin/hpl.com/aggregates/total_bandwidth-day.png
> : invalid rpn expression in:
> az1_0,UN,0,az1_0,IF,,+ 2011/02/24
> 20:04:39
>
> rrdtool 'graph' '--font' \
> 'LEGEND:7:/usr/share/fonts/bitstream-vera/VeraMono.ttf'
> \
> '--font' \
> 'UNIT:7:/usr/share/fonts/bitstream-vera/VeraMono.ttf'
> \
> '--font' \
> 'AXIS:7:/usr/share/fonts/bitstream-vera/VeraMono.ttf'
> \
> '-W' \
> 'Munin 1.4.5' \
> '/var/www/html/munin/hpl.com/aggregates/total_bandwidth-year.png'
> \
> '--title' \
> 'Aggregated bandwidth - by year' \
> '--start' \
> '-400d' \
> '--height' \
> '175' \
> '--width' \
> '400' \
> '--imgformat' \
> 'PNG' \
> 'DEF:az1_0=:42:MAX' \
> 'DEF:iz1_0=:42:MIN' \
> 'DEF:gz1_0=:42:AVERAGE' \
> 'CDEF:acdefz1_0=az1_0,UN,0,az1_0,IF,,+'
> \
> 'CDEF:icdefz1_0=iz1_0,UN,0,iz1_0,IF,,+'
> \
> 'CDEF:gcdefz1_0=gz1_0,UN,0,gz1_0,IF,,+'
> \
> 'CDEF:ccdefz1_0=gcdefz1_0' \
> 'COMMENT: ' \
> 'COMMENT: Cur\:' \
> 'COMMENT:Min\:' \
> 'COMMENT:Avg\:' \
> 'COMMENT:Max\: \j' \
> 'LINE1.6:gcdefz1_0#00CC00:upload ' \
> 'GPRINT:ccdefz1_0:LAST:%6.2lf%s' \
> 'GPRINT:icdefz1_0:MIN:%6.2lf%s' \
> 'GPRINT:gcdefz1_0:AVERAGE:%6.2lf%s' \
> 'GPRINT:acdefz1_0:MAX:%6.2lf%s\j' \
> 'COMMENT:Last update\: Wed Dec 31 16\:00\:00 1969\r' 2011/02/24 20:04:39
> [RRD ERROR] Unable to graph
> /var/www/html/munin/hpl.com/aggregates/total_bandwidth-year.png
> : invalid rpn expression in:
> az1_0,UN,0,az1_0,IF,,+ 2011/02/24
> 20:04:39 Graphed service :
> total_bandwidth (0.01 sec * 4)
> 2011/02/24 20:04:39 Munin-graph
> finished (0.11 sec)
答案1
是的,它是在服务器端通过创建组合图来完成的。
基本上,它是通过在 munin 服务器配置 ( munin.conf
) 中描述一个新图表来完成的,其中绘制的数据是两个数据源的总和:
[some.machine.boo]
total_http_bw.graph_order total_received
total_http_bw.graph_title HTTP traffic recived by machine1 and machine2
total_http_bw.graph_vlabel Kb/s
total_http_bw.total_received.label HTTP received traffic
total_http_bw.total_received.sum \
machine1.machine.boo:http_bw:received \
machine2.machine.boo:http_bw:received
您可以找到一个例子堆叠(将两个数据源绘制成一个在另一个之上的图形)在 munin 网站上。如果您想要绘制两个数据源的总和,则可以使用函数total_received.sum
代替total_received.stack
。
[编辑] 我在这个答案中添加了需要网络接口带宽的部分,因为它可以更完整地回答原始问题(我无法选择 2 个正确的答案等)
我曾有一个很多让网络接口放弃它们的值作为 SUM 的麻烦,因此这里是大量随机试验和错误更改的最终结果,以获得多个 munin 节点的 SUM 折线图
[mydomain.com;aggregates]
total_bandwidth.graph_args --base 1000 -l 0
total_bandwidth.cdef 0
total_bandwidth.graph_category Network
total_bandwidth.graph_title Aggregated bandwidth
total_bandwidth.graph_vlabel Bits/sec
total_bandwidth.upload.label upload
total_bandwidth.total.graph yes
total_bandwidth.upload.sum \
mybox1.mydomain.com:if_eth0.up \
mybox2.mydomain.com:if_eth0.up
total_bandwidth.upload.type COUNTER
total_bandwidth.download.type COUNTER
total_bandwidth.download.label download
total_bandwidth.graph_order upload download
total_bandwidth.total.graph no
total_bandwidth.download.sum \
mybox1.mydomain.com:if_eth0.down \
mybox2.mydomain.com:if_eth0.down
我怀疑其中一些指令要么是不必要的,要么是完全错误的,但我希望它能成为任何试图实现相同目标的人的一个工作起点。
我还怀疑,如果您明确确保所有主机都在聚合组中,例如 mydomain.com,即使您的主机在本地命名不正确,例如hostname -f
错误,它也会更好地工作