lost and found ( for me ? )

KVM : monitor VMs resources with munin and munin-libvirt-plugins

munin で KVM上のVMのリソースをグラフ化する。
VMのCPU Time ,Memory Usage ,Network I/O , Block Device I/O のグラフ化が可能。

root@hat1:~# tail -1 /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 10.10"

[ 手順 ]

・munin をインストール
・muninの設定
・Apacheの設定
・動作確認

[ 設定例 ]

・munin をインストール

root@hat1:~# apt-get install -y munin munin-libvirt-plugins

root@hat1:~# dpkg -l | grep munin
ii  munin                                1.4.5-1ubuntu2                                  network-wide graphing framework (grapher/gatherer)
ii  munin-common                         1.4.5-1ubuntu2                                  network-wide graphing framework (common)
ii  munin-libvirt-plugins                0.0.6-1                                         Munin plugins using libvirt
ii  munin-node                           1.4.5-1ubuntu2                                  network-wide graphing framework (node)

root@hat1:~# dpkg -L munin-libvirt-plugins | grep plugins
/usr/share/munin/plugins
/usr/share/munin/plugins/libvirt-cputime
/usr/share/munin/plugins/libvirt-blkstat
/usr/share/munin/plugins/libvirt-ifstat
/usr/share/munin/plugins/libvirt-mem
/usr/share/doc/munin-libvirt-plugins
/usr/share/doc/munin-libvirt-plugins/README
/usr/share/doc/munin-libvirt-plugins/copyright
/usr/share/doc/munin-libvirt-plugins/changelog.Debian.gz
/usr/sbin/munin-libvirt-plugins-detect

・muninの設定

- プラグインの設定

libvirt プラグイン。cpu , network , memory , block device I/O

root@hat1:~# ls /usr/share/munin/plugins/libvirt-*
/usr/share/munin/plugins/libvirt-blkstat  /usr/share/munin/plugins/libvirt-ifstat
/usr/share/munin/plugins/libvirt-cputime  /usr/share/munin/plugins/libvirt-mem

muninの監視リソースに libvirt-* を追加。

root@hat1:~# ln -s /usr/share/munin/plugins/libvirt-* /etc/munin/plugins/

muninが収集したグラフが作成ディレクトリ。 /var/cache/munin/www

root@hat1:~# less /etc/munin/munin.conf
# Example configuration file for Munin, generated by 'make build'

# The next three variables specifies where the location of the RRD
# databases, the HTML output, logs and the lock/pid files.  They all
# must be writable by the user running munin-cron.  They are all
# defaulted to the values you see here.
#
# dbdir /var/lib/munin
# htmldir /var/cache/munin/www
# logdir /var/log/munin
# rundir  /var/run/munin

- localhost を監視

root@hat1:~# egrep -v ^# /etc/munin/munin.conf | egrep -v ^$
includedir /etc/munin/munin-conf.d
[localhost.localdomain]
   address 127.0.0.1
   use_node_name yes

・Apacheの設定

munin インストール時に下記ファイルが生成されていた。
http://muninが動作しているIP/munin でグラフが見れるように設定。

root@hat1:~# cat /etc/apache2/conf.d/munin
Alias /munin /var/cache/munin/www

       Order allow,deny
       Allow from localhost 127.0.0.0/8 ::1
       Options None

       # This file can be used as a .htaccess file, or a part of your apache
       # config file.
       #
       # For the .htaccess file option to work the munin www directory
       # (/var/cache/munin/www) must have "AllowOverride all" or something
       # close to that set.
       #

       # AuthUserFile /etc/munin/munin-htpasswd
       # AuthName "Munin"
       # AuthType Basic
       # require valid-user

       # This next part requires mod_expires to be enabled.
       #

       # Set the default expiration time for files to 5 minutes 10 seconds from
       # their creation (modification) time.  There are probably new files by
       # that time.
       #

   
       ExpiresActive On
       ExpiresDefault M310
   



・apache , munin-node の起動

root@hat1:~# /etc/init.d/munin-node start
root@hat1:~# /etc/init.d/apache2 start

5分ごとに情報収集。

root@hat1:~# cat /etc/cron.d/munin
#
# cron-jobs for munin
#

MAILTO=root

*/5 * * * *     munin if [ -x /usr/bin/munin-cron ]; then /usr/bin/munin-cron; fi
14 10 * * *     munin if [ -x /usr/share/munin/munin-limits ]; then /usr/share/munin/munin-limits --force --contact nagios --contact old-nagios; fi

・動作確認

http://muninのIP/munin にアクセス。
libvirt に関しては下記のようなグラフが生成される。

CPU


Memory


Network I/O


Block Device I/O

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.