OpenStack collectd的从零安装客户端

1.查看是否需要增加yum 源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@node-12 ~]# yum search collectd
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirrors.skyshe.cn
 * extras: mirrors.skyshe.cn
 * updates: mirrors.btte.net
base                                                                                                                                                                               | 3.7 kB     00:00    
extras                                                                                                                                                                             | 3.4 kB     00:00    
nailgun                                                                                                                                                                            | 1.3 kB     00:00    
updates                                                                                                                                                                            | 3.4 kB     00:00    
updates/primary_db                                                                                                                                                                 | 888 kB     00:00    
Warning: No matches found for: collectd
No Matches found
[root@node-12 ~]#

发现没有我们需要的collectd软件包。需要增加软件源epel.

1
2
3
4
5
Retrieving http://mirrors.hustunique.com/epel//6/x86_64/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.IHCvEN: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[root@node-12 ~]# yum search collectd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/metalink                                                                                                                                                                      | 5.7 kB     00:00    
 * base: mirrors.skyshe.cn
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.skyshe.cn
 * updates: mirrors.btte.net
epel                                                                                                                                                                               | 4.1 kB     00:00    
epel/primary_db                                                                                                                                                                    | 6.4 MB     00:06    
========================================================================================= N/S Matched: collectd ==========================================================================================
collectd-apache.x86_64 : Apache plugin for collectd
collectd-dns.x86_64 : DNS traffic analysis module for collectd
collectd-email.x86_64 : Email plugin for collectd
collectd-ipmi.x86_64 : IPMI module for collectd
collectd-mysql.x86_64 : MySQL module for collectd
collectd-nginx.x86_64 : Nginx plugin for collectd
collectd-nut.x86_64 : Network UPS Tools module for collectd
collectd-ping.x86_64 : ping module for collectd
collectd-postgresql.x86_64 : PostgreSQL module for collectd
collectd-rrdtool.x86_64 : RRDTool module for collectd
collectd-sensors.x86_64 : Libsensors module for collectd
collectd-snmp.x86_64 : SNMP module for collectd
collectd-virt.x86_64 : Libvirt plugin for collectd
fedmsg-collectd.noarch : A fedmsg plugin for collectd
perl-Collectd.x86_64 : Perl bindings for collectd
collectd.i686 : Statistics collection daemon for filling RRD files
collectd.x86_64 : Statistics collection daemon for filling RRD files
collectd-web.x86_64 : Contrib web interface to viewing rrd files
python-bucky.noarch : CollectD and StatsD adapter for Graphite
 
  Name and summary matches only, use "search all" for everything.
[root@node-12 ~]#

可以知道已经有了我们需要的软件包。

安装collectd软件包

1
yum install collectd collect-*

这里可能会有下面的错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
--> Finished Dependency Resolution
Error: Package: collectd-web-4.10.9-1.el6.x86_64 (epel)
           Requires: perl-HTML-Parser
Error: Package: collectd-web-4.10.9-1.el6.x86_64 (epel)
           Requires: perl(HTML::Entities)
Error: Package: collectd-rrdtool-4.10.9-1.el6.x86_64 (epel)
           Requires: rrdtool
Error: Package: collectd-ipmi-4.10.9-1.el6.x86_64 (epel)
           Requires: libOpenIPMIutils.so.0()(64bit)
Error: Package: perl-Collectd-4.10.9-1.el6.x86_64 (epel)
           Requires: perl(RRDs)
Error: Package: collectd-email-4.10.9-1.el6.x86_64 (epel)
           Requires: spamassassin
Error: Package: collectd-snmp-4.10.9-1.el6.x86_64 (epel)
           Requires: net-snmp
Error: Package: collectd-ipmi-4.10.9-1.el6.x86_64 (epel)
           Requires: libOpenIPMIpthread.so.0()(64bit)
Error: Package: collectd-web-4.10.9-1.el6.x86_64 (epel)
           Requires: perl(URI::Escape)
Error: Package: collectd-ipmi-4.10.9-1.el6.x86_64 (epel)
           Requires: libOpenIPMI.so.0()(64bit)
Error: Package: collectd-web-4.10.9-1.el6.x86_64 (epel)
           Requires: perl(RRDs)
Error: Package: collectd-web-4.10.9-1.el6.x86_64 (epel)
           Requires: rrdtool-perl
Error: Package: collectd-web-4.10.9-1.el6.x86_64 (epel)
           Requires: perl(JSON)
Error: Package: collectd-rrdtool-4.10.9-1.el6.x86_64 (epel)
           Requires: librrd_th.so.4()(64bit)
Error: Package: perl-Collectd-4.10.9-1.el6.x86_64 (epel)
           Requires: perl(URI::Escape)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

表示缺少这方面的包,如果没有该错误,请跳过下面的解决办法。

1
Requires: perl(URI::Escape)

表示perl程序没有URI::Escape包。 将其他标准版本的Centos的镜像里的/etc/yum.repo.d/Centos-Base.repo到这台新的计算节点。因为新的计算节点是使用的fuel-web的源,并且国内的163.sohu等源都不好用。 重新执行安装collectd-*程序正常。

验证collectd可用

编辑/etc/collectd.conf配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#Hostname    "localhost"
FQDNLookup   true
#BaseDir     "/usr/var/lib/collectd"
#PIDFile     "/usr/var/run/collectd.pid"
#PluginDir   "/usr/lib/collectd"
#TypesDB     "/usr/share/collectd/types.db"
#Interval     10
#Timeout      2
#ReadThreads  5
 
LoadPlugin syslog
LoadPlugin cpu
LoadPlugin disk
LoadPlugin interface
LoadPlugin load
LoadPlugin memory
LoadPlugin libvirt
LoadPlugin network
<Plugin libvirt>
        Connection "qemu:///system"
        RefreshInterval 60
        #Domain "name"
  #BlockDevice "name:device"
  #InterfaceDevice "name:interface"
  #IgnoreSelected false
  HostnameFormat "name"
</Plugin>
<Plugin disk>
#       Disk "/^[hs]d[a-f][0-9]?$/"
#       IgnoreSelected false
</Plugin>
 
#Include "/etc/collectd.d"
 
<Plugin network>
        Server "172.17.46.3" "25826"
#       CacheTimeout 120
#       CacheFlush   900
</Plugin>

启动服务

1
service collectd start

刷新:http://172.17.46.3:8084/的服务,可以看到服务可libvirt监控的虚拟机增加了。

原文地址:https://www.cnblogs.com/CLTANG/p/4332635.html