Munin 은 트래픽 분석 툴이며 RRDTool 를 이용하여 그래프를 그려 보여줍니다.

Munin 데모

http://munin.ping.uio.no/
http://munin.ping.uio.no/ping.uio.no/rossum.ping.uio.no.html


– Munin 설치

[root@yongbok ~]# pkg_add -r munin-master
You need a group “munin”.
Would you like me to create it [y]? y
Done.
You need a user “munin”.
Would you like me to create it [y]? y
Done.

[root@yongbok ~]# pkg_add -r munin-node

– Munin 설정
Munin-node 를 서비스에 등록 해줍니다.

[root@yongbok ~]# echo ‘munin_node_enable=”YES”‘ >> /etc/rc.conf

설정 파일을 생성 해줍니다.

[root@yongbok ~]# cd /usr/local/etc/munin
[root@yongbok ~]# cp munin.conf.sample munin.conf
[root@yongbok ~]# ee munin.conf
# 기록이 저장될 디렉토리 지정
dbdir /usr/local/var/munin
htmldir /usr/local/www/munin
logdir /var/log/munin-main
rundir /var/run/munin

# HTML 템플릿 디렉토리 지정
tmpldir /usr/local/etc/munin/templates

# 사용할 노드를 추가 해줍니다.
[ruo91]
address 127.0.0.1
use_node_name yes

[root@yongbok ~]# cp munin-node.conf.sample munin-node.conf
[root@yongbok ~]# ee munin-node.conf
# 로그 설정
log_level 4
log_file /var/log/munin-node.log
pid_file /var/run/munin/munin-node.pid

background 1
setseid 1

user root
group wheel
setsid yes

# 정규식 파일 무시 (Regexps for files to ignore)
ignore_file ~$
ignore_file \.bak$
ignore_file %$
ignore_file \.dpkg-(tmp|new|old|dist)$
ignore_file \.rpm(save|new)$
ignore_file \.pod$

# A list of addresses that are allowed to connect. This must be a
# regular expression, due to brain damage in Net::Server, which
# doesn’t understand CIDR-style network notation. You may repeat
# the allow line as many times as you’d like

allow ^127\.0\.0\.1$

# IP 주소 입력
host 127.0.0.1

# 포트 지정
port 4949

Munin 에 사용할 플러그인을 링크 또는 복사 해줍니다.

플러그인 디렉토리 : /usr/local/share/munin/plugins
사용할 플러그인 디렉토리 : /usr/local/etc/munin/plugins/

[root@yongbok ~]# ln -s /usr/local/share/munin/plugins/apache_* /usr/local/etc/munin/plugins/
[root@yongbok ~]# ln -s /usr/local/share/munin/plugins/mysql_* /usr/local/etc/munin/plugins/
[root@yongbok ~]# ln -s /usr/local/share/munin/plugins/cpu /usr/local/etc/munin/plugins/
[root@yongbok ~]# ln -s /usr/local/share/munin/plugins/load /usr/local/etc/munin/plugins/
[root@yongbok ~]# ln -s /usr/local/share/munin/plugins/memory /usr/local/etc/munin/plugins/
[root@yongbok ~]# ln -s /usr/local/share/munin/plugins/named /usr/local/etc/munin/plugins/
[root@yongbok ~]# ln -s /usr/local/share/munin/plugins/proccess /usr/local/etc/munin/plugins/
[root@yongbok ~]# ln -s /usr/local/share/munin/plugins/swap /usr/local/etc/munin/plugins/

아파치 플러그인을 사용시 httpd.conf 설정 파일에 server-status 을 추가 해줍니다.

[root@yongbok ~]# ee /usr/local/apache2/conf/httpd.conf
ExtendedStatus On
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.0.1
</Location>
[root@yongbok ~]# /usr/local/apache2/bin/apachectl restart

MySQL 플러그인 사용시 루트로 접근 가능하도록 해줘야 하기 때문에 아래 설정 파일을 수정 해줍니다.

[root@yongbok ~]# cd /usr/local/etc/munin/plugin-conf.d
[root@yongbok ~]# cp plugins.conf.sample plugins.conf
[root@yongbok ~]# ee plugins.conf
[mysql*]
user root
group wheel
env.mysqladmin /usr/local/bin/mysqladmin
env.mysqlshow /usr/local/bin/mysqlshow
env.mysqlopts -u root -p123456

Munin 을 시작합니다.

[root@yongbok ~]# /usr/local/etc/rc.d/munin-node start
Starting munin_node.

포트 4949 가 정상 작동하는지 확인

[root@yongbok ~]# netstat -ant | grep 4949
tcp4 0 0 127.0.0.1.4949 *.* LISTEN

– Apache 설정
트래픽 상황을 웹페이지에서 보기 위해 설정 해줍니다.

[root@yongbok ~]# ee /usr/local/apache2/conf/extra/httpd-vhosts.conf

NameVirtualHost *:80
<VirtualHost *:80>
ServerName munin.yongbok.net
ServerAdmin ruo91@yongbok.net
ServerAlias munin.yongbok.net
DocumentRoot /usr/local/www/munin/
<Directory “/usr/local/www/munin/”>
Options FollowSymLinks
AllowOverride None
</Directory>
CustomLog “/home/apache2-log/munin/munin-access.log” combined
ErrorLog /home/apache2-log/munin/munin-error.log
</VirtualHost>

[root@yongbok ~]# /usr/local/apache2/bin/apachectl restart

참고
http://munin.projects.linpro.no/wiki/Documentation