1. Overview
Configure Collectd to ping target servers periodically, monitor their latency, and store the results in InfluxDB.
2. Steps
- Configure Collectd
Collectd has prebuilt packages in most mainstream distributions, so on Ubuntu you can install it directly:
sudo apt-get install collectd
Make a few small changes to the Collectd configuration file /etc/collectd/collectd.conf
-#LoadPlugin network
+LoadPlugin network
+<Plugin network>
# 配置 InfluxDB 服务器地址和端口
+ Server "127.0.0.1" "25826"
+</Plugin>
+<Plugin "ping">
# 配置需要检测的服务器
+ Host "example.com"
+</Plugin>
With this configuration, Collectd sends its data over localhost:25826, and the ping plugin monitors server latency. To monitor multiple servers, just add multiple Host “domain” lines.
Finally, start Collectd
systemctl start collectd
- Configure InfluxDB
Installing InfluxDB is just as easy:
sudo apt-get install -y apt-transport-https
curl -sL https://repos.influxdata.com/influxdb.key | apt-key add -
source /etc/lsb-release
echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update && sudo apt-get install influxdb
After installation, enable InfluxDB's Collectd support:
[[collectd]]
enabled = true
bind-address = "127.0.0.1:25826"
database = "collectd"
retention-policy = ""
typesdb = "/usr/local/share/collectd/types.db"
batch-size = 5000
batch-pending = 10
batch-timeout = "10s"
read-buffer = 0
InfluxDB is still missing typesdb at this point, so download it directly with the following commands:
mkdir /usr/local/share/collectd
wget -P /usr/local/share/collectd https://raw.githubusercontent.com/collectd/collectd/master/src/types.db
Finally, start InfluxDB
systemctl start influxdb
Create a database:
curl -i -XPOST http://localhost:8086/query -u collectd:qazxcdawfw45 --data-urlencode "q=CREATE DATABASE collectd"
Finally, connect it to Grafana as needed.