How to install and configure collectd?
This post helps to install collectd monitoring agent and explains it’s configuration. collectd as its name implies collects performance metrics from different sources like servers or applications and it will transfer that data to another system for analysis.
collectd only collects and transmits metrics, and any number of tools can be arranged to receive that data. The design of collectd is agent based, so you need to run collectd on hosts that you want to monitor.
There are 95+ input plugins and 15+ write plugins are available in collectd. The input plugins will help to collect the metrics from a system and the output plugins will send that metrics to a remote system for analysis.
Examples of Input (read) plugins
- CPU
- Memory
- MySQL
- SNMP
Examples of Output (write) plugins
- Graphite
- RRDtool
- MongoDB
- HTTP
Install collectd on CentOS 7
If you are installing collectd on CentOS 7, you need to enable epel repo first.
yum install epel-release yum install collectd
Install collectd on Ubuntu or Debian based distros
apt install collectd
Configure collectd
Once the package is installed, open /etc/collectd.conf and configure it.
vim /etc/collectd.conf
Then enable desired plugins and set the hostname. The hostname should be the local hostname. Also, if you would like to send the metrics to a graphite server, enable write_graphite plugin too:
Add the following into it:
Hostname "SERVER01" LoadPlugin syslog LoadPlugin cpu LoadPlugin load LoadPlugin memory LoadPlugin uptime LoadPlugin write_graphite <Plugin write_graphite> <Node "metrics"> # Your Graphite server name Host "mtrics.grepitout.com" # Your graphite server hostname Port "2003" # graphite server port Protocol "tcp" ReconnectInterval 0 LogSendErrors true Prefix "collectd." Postfix ".os" StoreRates true AlwaysAppendDS false EscapeCharacter "_" SeparateInstances false PreserveSeparator false DropDuplicateFields false </Node> </Plugin>
Sample configuration file:
[root@application01]# cat /etc/collectd.conf Interval 60 Hostname "application01" TypesDB "/opt/collectd/share/collectd/types.db" TypesDB "/opt/collectd/share/collectd/types.d.custom" LoadPlugin syslog LoadPlugin cpu LoadPlugin load LoadPlugin memory LoadPlugin uptime LoadPlugin vmem LoadPlugin entropy CollectInternalStats true Include "/etc/collectd.d/*.conf" [root@application01]
You can add seperate configuration files for your plugins in the directory /etc/collectd.d/ as I have added an Include option in the main configuration file.
Example: /etc/collectd.d/plugin-write_graphite.conf
[root@application01]# cat /etc/collectd.d/plugin-write_graphite.conf LoadPlugin write_graphite <Plugin write_graphite> <Node "metrics"> # Your Graphite server name Host "metrics.grepitout.com" # Your graphite server hostname Port "2003" # graphite server port Protocol "tcp" ReconnectInterval 0 LogSendErrors true Prefix "collectd." Postfix ".os" StoreRates true AlwaysAppendDS false EscapeCharacter "_" SeparateInstances false PreserveSeparator false DropDuplicateFields false </Node> </Plugin> [root@application01]#
CollectInternalStats
When we set CollectInternalStats to true, the collectd daemon statistics will be collected with “collectd” as the plugin name and send it to the tool that is arranged to receive that data.
TypesDB
The types.db file contains collectd’s metric type specifications. Each line describes one metric type, which is called “data set”.
Read more about types.db: GitHub: types.db
Also read more about Data source types (counter, gauge, derive or absolute): collectd.org: Data Source
The types.db and types.db.custom files will not be created upon collectd package installation. You can check sample types.db file in the follwoing link and place that in /opt/collectd/share/collectd/types.db
Sample types.db file: GitHub: types.db Sample
Enable and start collectd service
Once you made the desired changes enable and start the collectd service.
systemctl enable --now collectd.service systemctl status collectd.service
Do this on all nodes that you need to monitor.
Verify
Go to the graphite host and check the metrics are receiving on the port 2003
tcpdump -i any -A -vv port 2003
That’s it!
Also Read:
- How to change boot order in CentOS 7 or RHEL 7
- YumRepo Error: All mirror URLs are not using ftp, http[s] or file
- Install Htop on CentOS/RHEL and Ubuntu
- Install GitLab on CentOS 7 and Derivatives
- Install GitLab on CentOS 7 and Derivatives
- Install Zabbix on CentOS 8 and Derivatives
- How to Install Kdenlive Video Editor on Ubuntu
- Install youtube-dl in Ubuntu
- How to Install BleachBit on Ubuntu and Derivatives
If you like this post and wish to receive more articles from us, please like our FB page: Grepitout
Your suggestions and feedback will encourage us and help to improve further, please feel free to write your comments.
For more details on our services, please drop us an E-mail at info@grepitout.com
Add Comment