使用collectd与visage收集kvm虚拟机性能实时图形,collectdkvm


软件功能:

通过collectd软件来监控收集kvm虚拟机的性能数据,包括cpu,memory、磁盘IO、网络流量等

通过visage软件将收集到的数据绘制图形。


安装:

系统环境:ubuntu12.04

collectd

首先、在collectd官网下载collectd包collectd-5.4.0

安装collectd依赖包

apt-get install bison flex autoconf pkg-config libtool libgcrypt11-dev librrd-dev
安装完成后,到collectd-5.4.0目录下编译源码并安装

./configure --prefix=/ --exec-prefix=/usr  --enable-cpu --enable-network --enable-libvirt --enable-logfile --enable-rrdtool  --enable-rrdcached
make&&make install

修改配置

mkdir /etc/collect
mv /etc/collectd.conf /etc/collect
vi /etc/collect/collectd.conf
在collectd.conf文件中修改内容

LoadPlugin syslog
LoadPlugin logfile

<Plugin logfile>
        LogLevel info
        File STDOUT
        Timestamp true
        PrintSeverity false
</Plugin>

<Plugin syslog>
        LogLevel info
</Plugin>

LoadPlugin cpu
LoadPlugin df
LoadPlugin disk
LoadPlugin interface
LoadPlugin irq
LoadPlugin libvirt
LoadPlugin load
LoadPlugin memory
LoadPlugin network
LoadPlugin processes
LoadPlugin rrdcached
LoadPlugin rrdtool
LoadPlugin users

<Plugin network>
#       # client setup:
        Server "192.168.0.12" "25826"          //客户端配置收集数据的服务端 IP +端口
        Server "192.168.0.16" "25826" 
#       <Server "239.192.74.66" "25826">
#               SecurityLevel Encrypt
#               Username "user" 
#               Password "secret" 
#               Interface "eth0" 
#       </Server>
#       TimeToLive "128" 
#
#       # server setup:
        Listen "192.168.0.16" "25826"            //collectd作为收集服务端需要打开listen IP + 端口
#       <Listen "239.192.74.66" "25826">
</Plugin>

<Plugin libvirt>
        Connection "qemu:///system" 
        RefreshInterval 60
#       Domain "name" 
        BlockDevice "/:hdc/" 
#       InterfaceDevice "name:device" 
        IgnoreSelected true
        HostnameFormat uuid
        InterfaceFormat "address" 
</Plugin>

在安装目录下将collectd执行文件拷贝到/ect/init.d/目录下然后启动collectd

service collectd start


visage

安装visage依赖包

apt-get install -y build-essential librrd-ruby ruby ruby-dev rubygems
安装visage软件

apt-get install gem
gem install visage-app
启动visage

visage-app start
启动后访问visage-app的web界面

http://visage-app-server:9292

错误解答:


启动visage-app报错:

root@PS-8:/# visage-app start
/var/lib/gems/1.8/gems/visage-app-2.1.0/lib/visage-app/types.rb:19:in `initialize': No such file or directory - /usr/share/collectd/types.db (Errno::ENOENT)
    from /var/lib/gems/1.8/gems/visage-app-2.1.0/lib/visage-app/types.rb:19:in `new'
    from /var/lib/gems/1.8/gems/visage-app-2.1.0/lib/visage-app/types.rb:19:in `build'
    from /var/lib/gems/1.8/gems/visage-app-2.1.0/lib/visage-app/types.rb:10:in `initialize'
    from /var/lib/gems/1.8/gems/visage-app-2.1.0/lib/visage-app.rb:34:in `new'
    from /var/lib/gems/1.8/gems/visage-app-2.1.0/lib/visage-app.rb:34
    from /var/lib/gems/1.8/gems/visage-app-2.1.0/lib/visage-app/config.rb:6:in `use'
    from /var/lib/gems/1.8/gems/visage-app-2.1.0/lib/visage-app.rb:31
    from /var/lib/gems/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:1273:in `configure'
    from /var/lib/gems/1.8/gems/visage-app-2.1.0/lib/visage-app.rb:30
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from /var/lib/gems/1.8/gems/visage-app-2.1.0/bin/visage-app:17
    from /usr/local/bin/visage-app:19:in `load'
    from /usr/local/bin/visage-app:19
ollectd编译安转types.rb默认在目录/share/collectd/目录下,将types.rb文件拷贝到/usr/share/collectd目录下,并将collectd.conf配置文件中设置参数:
TypesDB "/usr/share/collectd/types.db" 
然后再启动collectd和visage-app


visage-app收集不到数据

在visage-app界面上查看不到服务器?
visage-app启动默认是在目录/var/lib/collectd/rrd目录下去收集服务器,但是collectd编译安装数据默认在/var/lib/collectd/目录下。在collectd.conf配置文件中设置参数:
BaseDir     "/var/lib/collectd/rrd" 




相关内容