Munin提示min must be less than max in DS definition

因为家中使用的树莓派意外损坏,使用NAS上的虚拟机来代替原来树莓派的工作.在配置Munin的时候出现错误,当更新网络设备数据时,munin服务器端报错

2016/12/20 17:30:05 [INFO] creating rrd-file for if_ens3->down: '/var/lib/munin/ARCHLINUX/mx.ARCHLINUX-if_ens3-down-d.rrd'
2016/12/20 17:30:05 [ERROR] Unable to create '/var/lib/munin/ARCHLINUX/mx.ARCHLINUX-if_ens3-down-d.rrd': min must be less than max in DS definition
2016/12/20 17:30:05 [ERROR] In RRD: Error updating /var/lib/munin/ARCHLINUX/mx.ARCHLINUX-if_ens3-down-d.rrd: opening '/var/lib/munin/ARCHLINUX/mx.ARCHLINUX-if_ens3-down-d.rrd': No such file or directory
2016/12/20 17:30:05 [INFO] creating rrd-file for if_ens3->up: '/var/lib/munin/ARCHLINUX/mx.ARCHLINUX-if_ens3-up-d.rrd'
2016/12/20 17:30:05 [ERROR] Unable to create '/var/lib/munin/ARCHLINUX/mx.ARCHLINUX-if_ens3-up-d.rrd': min must be less than max in DS definition
2016/12/20 17:30:05 [ERROR] In RRD: Error updating /var/lib/munin/ARCHLINUX/mx.ARCHLINUX-if_ens3-up-d.rrd: opening '/var/lib/munin/ARCHLINUX/mx.ARCHLINUX-if_ens3-up-d.rrd': No such file or directory

 

在做了一些搜索之后发现文章 https://github.com/mail-in-a-box/mailinabox/issues/896

 

执行munin-run if_ens3 config 后出现以下输出

graph_order down up
graph_title ens3 traffic
graph_args --base 1000
graph_vlabel bits in (-) / out (+) per ${graph_period}
graph_category network
graph_info This graph shows the traffic of the ens3 network interface. Please note that the traffic is shown in bits per second, not bytes. IMPORTANT: On 32-bitsystems the data source for this plugin uses 32-bit counters, which makes the plugin unreliable and unsuitable for most 100-Mb/s (or faster) interfaces, where traffic is expected to exceed 50 Mb/s over a 5 minute period.  This means that this plugin is unsuitable for most 32-bit production environments. To avoid this problem, use the ip_ plugin instead.  There should be no problems on 64-bit systems running 64-bit kernels.
down.label received
down.type DERIVE
down.graph no
down.cdef down,8,*
down.min 0
up.label bps
up.type DERIVE
up.negative down
up.cdef up,8,*
up.min 0
up.max -1000000
up.info Traffic of the ens3 interface. Maximum speed is -1 Mb/s.
down.max -1000000

根据文章的内容,应用munin-monitoring/munin@f982751到插件中即可修复这个问题.

 

使用以下patch可以解决问题

--- if_.orig    2016-08-02 23:52:05.691224811 +0200
+++ if_ 2016-08-02 23:52:49.563223127 +0200
@@ -91,7 +91,7 @@
     # iwlist first)
     if [[ -r /sys/class/net/$INTERFACE/speed ]]; then
             SPEED=$(cat /sys/class/net/$INTERFACE/speed 2>/dev/null)
-            if [[ -n "$SPEED" ]]; then
+            if [ -n "$SPEED" -a "$SPEED" -gt "0" ]; then
                 echo $SPEED
                 return
             fi

 

使用Munin来监控Nginx

前言:

Munin是一款很高效的监控工具,拥有大量的插件. 对于Nginx来言,监控需要一点点的设置. 这一篇小轿车的目的就是手把手的来教你使用Munin来监控nginx请求数和状态.

本文中所有的操作都在Centos 7.1下完成, 理论上其他的发行版本也可以套用(或许需要一点点的修改)

 

正文:

首先,确定你的Nginx有http_stub_status_module模块. 执行nginx -V

[root@jp02 ~]# nginx -V
nginx version: nginx/1.11.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabledconfigure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules 
 --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log 
 --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock 
 --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp 
 --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp 
 --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module 
 --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module
 --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module 
 --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module 
 --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic 
 --with-http_perl_module=dynamic --add-dynamic-module=njs-0.1.0/nginx --with-threads --with-stream --with-stream_ssl_module 
 --with-stream_geoip_module=dynamic --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 
 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong 
 --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic'

 

如果你在输出中没有找到–with-http_stub_status_module那你或许需要重新编译你的Nginx,或者安装Epel源中的版本

 

现在,增加nginx status到默认的虚拟主机内

location /nginx_status {
    stub_status on;    # activate stub_status module
    access_log off;    
    allow 127.0.0.1;   # restrict access to local only
    deny all;
}

 

当你完成之后,重新加载你的Nginx配置文件

sudo systemctl reload nginx

 

现在我们来配置Munin-node

使用任意一个你喜欢的文件编辑器,打开/etc/munin/plugin-conf.d/munin-node 增加以下内容(如果不存在)

[nginx_*]
env.url http://localhost/nginx_status

 

如果你的Nginx不是跑在80端口上或者绑定的是其他的域名请自行修改env.url

现在来更新Munin-node的插件

执行 munin-node-configure –suggest –shell | bash -x 将会自动链接Nginx插件.

[root@jp02 ~]# munin-node-configure --suggest --shell | bash -x
# The following plugins caused errors:
# http_loadtime:
# 	Junk printed to stderr
# pgbouncer_connections:
# 	Junk printed to stderr
# pgbouncer_requests:
# 	Junk printed to stderr
# postgres_autovacuum:
# 	Non-zero exit during autoconf (255)
# postgres_bgwriter:
# 	Non-zero exit during autoconf (255)
# postgres_cache_:
# 	Non-zero exit during autoconf (255)
# postgres_checkpoints:
# 	Non-zero exit during autoconf (255)
# postgres_connections_:
# 	Non-zero exit during autoconf (255)
# postgres_connections_db:
# 	Non-zero exit during autoconf (255)
# postgres_locks_:
# 	Non-zero exit during autoconf (255)
# postgres_oldest_prepared_xact_:
# 	Non-zero exit during autoconf (255)
# postgres_prepared_xacts_:
# 	Non-zero exit during autoconf (255)
# postgres_querylength_:
# 	Non-zero exit during autoconf (255)
# postgres_scans_:
# 	Non-zero exit during autoconf (255)
# postgres_size_:
# 	Non-zero exit during autoconf (255)
# postgres_transactions_:
# 	Non-zero exit during autoconf (255)
# postgres_tuples_:
# 	Non-zero exit during autoconf (255)
# postgres_users:
# 	Non-zero exit during autoconf (255)
# postgres_xlog:
# 	Non-zero exit during autoconf (255)
# proc:
# 	In family 'auto' but doesn't have 'autoconf' capability
# redis_:
# 	Junk printed to stderr
# slony_lag_:
# 	Junk printed to stderr
+ ln -s /usr/share/munin/plugins/nginx_request /etc/munin/plugins/nginx_request
+ ln -s /usr/share/munin/plugins/nginx_status /etc/munin/plugins/nginx_status

 

最后,重启Munin-node

sudo systemctl restart munin-node

 

稍等片刻之后即可在Munin的页面中看到Nginx的图表