您的位置:首页 > 运维架构 > Linux

Linux系统轻量级监控工具monitorix和munin安装

2016-02-26 19:36 731 查看
提到监控工具,大家都会想到zabbix等重量级的,这些好是好,但是需要安装数据库等等,如果有时候希望简单点其实可以借助一些轻量级的监控工具,例如monitorix和munin。

需要做点前置工作开启Nginx和php-fpm的status,因为可以利用监控工具monitorix和munin甚至于zabbix等来监控,要的就是实时的快照数据。

1.开启Nginx的status

nginx需要重新编译安装,关于nginx的安装可以参考此文:

Linux环境Nginx安装与调试以及PHP安装

# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
# make && make install

查看Nginx是否包含 stub_status 模块
# /usr/local/nginx/sbin/nginx -V



重新配置Nginx,建议单独配置一个端口比较好,这样不影响现有的网站。

location /nginx-status{
	stub_status on;
	access_log off;
	#allow 127.0.0.1;
	#deny all;    
	}


直接可以查看实时的nginx状态数据



2.开启php-fpm的status
修改php-fpm的配置文件,将下面这句注释去掉即可。

; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set 
;pm.status_path = /status
pm.status_path = /status

修改nginx的配置

location ~ ^/(status|ping)$    {        
	include fastcgi_params;        
	fastcgi_pass 127.0.0.1:9000;        
	fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;    
	}

最好是结束Nginx的进程而不是reload。
直接可以查看实时的php-fpm进程状态数据



一.monitorix安装与使用
monitorix官网:http://www.monitorix.org/downloads.html
# yum install monitorix
# yum install rrdtool rrdtool-perl perl-libwww-perl perl-MailTools perl-MIME-Lite perl-CGI perl-DBI perl-XML-Simple perl-Config-General perl-HTTP-Server-Simple perl-IO-Socket-SSL

# rpm -ivh http://www.monitorix.org/monitorix-3.8.1-1.noarch.rpm
注意,如果3.8.1不存在说明发布了新版,需要自行去官网找到即可。

修改monitorix配置

#cd /etc/monitorix/
#vim monitorix.conf
默认的monitorix配置并不符合我们的需求,可以做一些定制。

修改端口

<httpd_builtin>
	enabled = y
	host =
	port = 8080
	user = nobody
	group = nobody


启动nginx监控和process监控

<pre name="code" class="html"><graph_enable>
...
	nginx		= y
	process		= y


如果有不需要的改为n即可!

前面配置的nginx的status就发挥作用了

<nginx>
	url = http://localhost:8081/nginx-status 	port = 80
	rule = 24100
	rigid = 0, 0, 0
	limit = 100, 100, 100
</nginx>


process只监控我们感兴趣的进程

<process>
	<list>
		0 = nginx,php-fpm,java,redis-server,solr
	</list>


启动monitorix
# service monitorix start
重启monitorix
# service monitorix restart

查看monitorix http://xxx.xxx.xxx.xxx:端口/monitorix/
打开了默认的界面,选择按日,周,月,年进入即可





点击图片可以打开大图片:



处理器的运行信息:



定制化的进程信息:



Nginx的运行信息:



参考: http://monitorix.jincon.com/doc-redhat.html http://wuhuizhong.iteye.com/blog/2033096 http://dl528888.blog.51cto.com/2382721/863701
二.munin的安装
# yum install munin munin-node
# cd /etc/munin/
修改配置
munin.conf是munin服务端(munin master)的配置文件。
去掉路径配置的注释即可。除了tmpldir,其它可自行配置。但是tmpldir要配置到munin的HTML模板上,默认是在/etc/munin/templates 下。

dbdir	/var/lib/munin
htmldir /var/www/html/munin
logdir /var/log/munin
rundir  /var/run/munin

# Where to look for the HTML templates
#
tmpldir	/etc/munin/templates


localhost.localdomain节点是用于配置需要监控的目标机器的。默认会配置本机127.0.0.1。可新增需要监控的机器。可以增加多台机器,只要目标机器安装了munin-node就可以。

# a simple host tree
[localhost]
    address 127.0.0.1
    use_node_name yes


启动服务# service munin-node start

在munin.conf 配置文件里面指定了生成的监控的html监控结果"htmldir"/var/cache/munin/www”。
需要配置好nginx指向/var/cache/munin/www即可。生成的html都是静态文件。

在浏览器查看图形化的监控信息



参考:
http://www.freehao123.com/munin/ http://www.cnblogs.com/rond/p/3757804.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: