OpenStack collectd的從零安裝服務端

CL.TANG發表於2016-10-18

安裝collectd包操作同客戶端相同,不在贅述

配置檔案

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
40
41
#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 df
LoadPlugin disk
LoadPlugin interface
LoadPlugin load
LoadPlugin memory
LoadPlugin network
LoadPlugin rrdtool
#<Plugin disk>
#   Disk "/^[hs]d[a-f][0-9]?$/"
#   IgnoreSelected false
#</Plugin>
 
Include "/etc/collectd.d"
<Plugin "ping">
    Host "baidu.com"
    Host "sohu.com"
    Host "163.com"
</Plugin>
<Plugin rrdtool>
    DataDir "/data/openstack/rrd_store"
#   CacheTimeout 120
#   CacheFlush   900
</Plugin>
 
<Plugin network>
    Listen "172.17.46.4" "25826"
#   CacheTimeout 120
#   CacheFlush   900
</Plugin>

修改network元件為本機監聽地址

安裝collectd-web外掛

該外掛是一個perl的CGIweb程式.在我們的http://172.17.47.160/download目錄有下載(注意該專案是修改了的,如果網路上下載的原始碼是不能解析libvirt的虛擬機器的cpu使用率的) 修改的地方:

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
collectd-web-master/cgi-bin/collection.modified.cgi
       virt_vcpu => [
            '-v', 'CPU load (%)',
            '-X', '0',
            'DEF:avg_1={file}:value:AVERAGE',           ->:ns:AVERAGE
            'DEF:min_1={file}:value:MIN',               ->:ns:MIN
            'DEF:max_1={file}:value:MAX',               ->:ns:MAX
            'CDEF:avg=avg_1,10000000,/',
            'CDEF:min=min_1,10000000,/',
            'CDEF:max=max_1,10000000,/',
            "AREA:max#$HalfBlue",
            "AREA:min#$Canvas",
            "LINE1:avg#$FullBlue:Percent",
            'GPRINT:min:MIN:%6.2lf%% Min,',
            'GPRINT:avg:AVERAGE:%6.2lf%% Avg,',
            'GPRINT:max:MAX:%6.2lf%% Max,',
            'GPRINT:avg:LAST:%6.2lf%% Last\l'
        ],  
        virt_cpu_total => [
            '-v', 'CPU load (%)',
            '-X', '0',
            'DEF:avg_1={file}:value:AVERAGE',        ->:ns:AVERAGE
            'DEF:min_1={file}:value:MIN',            ->:ns:MIN
            'DEF:max_1={file}:value:MAX',            ->:ns:MAX
            'CDEF:avg=avg_1,10000000,/',
            'CDEF:min=min_1,10000000,/',
            'CDEF:max=max_1,10000000,/',
            "AREA:max#$HalfBlue",

修改的原因是同rrd檔案的檔案結構有關係,使用

1
rrdtool info virt-vcpu-1.rrd

rrd檔案儲存配置

1
2
3
4
mkdir /etc/collectd/
vi /etc/collectd/collection.conf
新增下列資料:
datadir:"/data/openstack/rrd_store"

此配置是給collect-web使用的。 進入到collect-web目錄,啟動服務:

1
python runserver.py 172.17.46.4 8084

相關文章