兩台ubuntu虛擬機器,一台為server,一台client。server IP:192.168.91.130,擬接收資料連接埠25827.
server安裝,版本為4.10
apt-get install collectd
/etc/collectd/collectd.conf配置(主要加入network plugin和rrdtool plugin):
LoadPlugin syslog
<Plugin syslog>
LogLevel info
</Plugin>
LoadPlugin cpu
LoadPlugin df
LoadPlugin disk
LoadPlugin interface
LoadPlugin load
LoadPlugin memory
LoadPlugin network
LoadPlugin rrdtool
<Plugin network>
# # client setup:
# Server "ff18::efc0:4a42" "25826"
# <Server "239.192.74.66" "25826">
# SecurityLevel Encrypt
# Username "user"
# Password "secret"
# Interface "eth0"
# </Server>
# TimeToLive "128"
#
# server setup:
Listen "192.168.91.130" "25827"
#<Listen "192.168.91.130" "25827">
# SecurityLevel Sign
# AuthFile "/etc/collectd/passwd"
# Interface "eth0"
#</Listen>
# MaxPacketSize 1024
#
# # proxy setup (client and server as above):
# Forward true
#
# # statistics about the network plugin itself
# ReportStats false
#
# # "garbage collection"
# CacheFlush 1800
</Plugin>
<Plugin rrdtool>
DataDir "/var/lib/collectd/rrd"
# CacheTimeout 120
# CacheFlush 900
# WritesPerSecond 30
# RandomTimeout 0
#
# The following settings are rather advanced
# and should usually not be touched:
# StepSize 10
# HeartBeat 20
# RRARows 1200
# RRATimespan 158112000
# XFF 0.1
</Plugin>
配置好儲存啟動:/etc/init.d/collectd start
client端配置:
安裝:apt-get install collectd
同樣在/etc/collectd/collectd.conf下配置:
不同的是在network外掛程式裡,配置
# client setup:
Server "192.168.91.130" "25827"
#<Server "192.168.91.130" "25827">
# SecurityLevel Encrypt
# Username "user"
# Password "secret"
# Interface "eth0"
#</Server>
配置好後重啟,/etc/init.d/collectd start
在server端,用rrdtool查看資料。比如查看今天14:00——15:00的平均值,觀察得知,collectd每700s產生一個新資料。
目前不大明白shortterm等代表的含義。
第二次配置時犯了個小錯誤,plugin network在預設是被#屏蔽掉,當時配置好了network但是一直沒有起作用,就是忘記消除屏蔽了。消除後一切正常。