When you install CollectD, its default configuration already allows it to collect a lot of metrics from your system.
Today we will review this default configuration and change it to collect even more.
Requirements
First, collectd need to be installed on your server.
Here is how to install collectd on Debian / Ubuntu.
It’s also easy to install collectd on CentOS / Fedora.
Edit CollectD Configuration
By default, the collectd configuration is located in /opt/collectd/etc/collectd.conf
Make it look like this collectd configuration example:
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 | Interval 1 LoadPlugin conntrack LoadPlugin cpu LoadPlugin df LoadPlugin disk LoadPlugin filecount LoadPlugin interface LoadPlugin load LoadPlugin memory LoadPlugin processes LoadPlugin swap LoadPlugin tcpconns LoadPlugin uptime LoadPlugin users <Plugin filecount> <Directory "/var/"> Recursive true </Directory> </Plugin> <Plugin tcpconns> LocalPort "80" </Plugin> |
Let’s review this configuration.
Interval 1
Collectd will record server performance every second. The default is 10 seconds but 1 second enables quicker anomaly detection.
Running CollectD every second will require a bit more CPU, but on modern hardware this is negligible.
LoadPlugin cpu
Records CPU activity, such as user, nice, system, idle, wait, interrupt, softirq and steal.
LoadPlugin df
Collects information such as the free, reserved and used space of your filesystems (including hard drives)
LoadPlugin filecount
Collects the total size and number of files in a directory. In this configuration we track the directory /var.
LoadPlugin interface
Collect network trafic, download and upload. Records the number of octets, packets and errors for transmission and reception on all network interfaces.
LoadPlugin load
Similar to the load on a UNIX server. Records the CPU load for the last minute, last 15 minutes and last 30 minutes.
LoadPlugin memory
Collects information about the used, buffered, cached and free RAM memory.
LoadPlugin processes
Tracks the number of running, blocked, sleeping, paging, stopped and zombie processes.
LoadPlugin swap
Records the free, cached and used swap space.
LoadPlugin tcpconns
Counts the number of TCP connections on a specified port. With our configuration we record all activity on port 80 (HTTP).
LoadPlugin uptime
Tracks how long your server has been up. Convenient for detecting anomalies when your server crashes.
LoadPlugin users
Collects the number of users logged on the server
Send Metrics to Database
To use collectd you need to send its metrics frequently to a database for monitoring and visualization:
Monitor & detect anomalies with Anomaly.io
SIGN UP