There are a variety of ways to extract system resource information from a Linux server. Some of these utilities are triggered by cron, such as sysstat, while others are based on a predefined check interval, such as Nagios. Others are meant to be used interactively, such as htop or vmstat.
collectd is another utility that gathers system metrics on a given system. It is written in C, giving it great performance. Its versatility, however, comes from the almost 100 plugins that is bundled with the daemon. These plugins include various read and write plugins. Some of the read plugins collect the standard Linux subsystem metrics, such as CPU, Disk, Memory and Network, while other read plugins are more specialized, such as reading Apache httpd or DNS metrics.
collectd gathers these metrics, but where are they stored? collectd has a handful of write plugins that allow you either store the metrics in local round-robin databases (RRDs) or externally to another collector, such as Graphite.
The collectd package in the EPEL 6 repository package is out of date. Often, users opt to compile collectd from source to obtain a newer, more recent version. The process of compiling collectd can be somewhat daunting at times because the more plugins that are available, the more dependencies are necessary.
The goal of this guide is to list the necessary packages for building collectd from source with most of the plugins enabled. These dependencies can all be found in the CentOS Base and EPEL repositories.
Compiling any package from source requires a compiler. If you don't already have one installed, go ahead and install the GNU GCC compiler:
sudo yum install gcc
For this exercise, you will also need kernel and the C library header files:
sudo yum install kernel-headers glibc-headers
A link to the collectd source is hosted on the main page of the collectd website. Download and untar the the latest source tarball. At the time of this writing, version 5.5.0 is the latest stable version.
curl --progress https://collectd.org/files/collectd-5.5.0.tar.gz | tar xz
After downloading and extracting the source files, change to that directory:
This package can be configured, built and installed with the typical configure && make && make install sequence of commands.
Start by running the configure step so that we can have a look at the available plugins:
This command will output quite a bit to the screen, checking your system for the presence of various libraries, header files and binaries in the process. Have a look at the summary at the end, for example:
Configuration: Libraries: intel mic . . . . . . no (MicAccessApi not found) libaquaero5 . . . . . no (libaquaero5.h not found) libatasmart . . . . . no (atasmart.h not found) libcurl . . . . . . . no (curl-config failed) libdbi . . . . . . . no (dbi/dbi.h not found) libesmtp . . . . . . no (libesmtp not found) libganglia . . . . . no (gm_protocol.h not found) [...output truncated...] Modules: aggregation . . . . . yes amqp . . . . . . . no apache . . . . . . . no apcups . . . . . . . yes apple_sensors . . . . no aquaero . . . . . . . no ascent . . . . . . . no barometer . . . . . . no [...output truncated...]
The summary at the end shows the various plugins and whether or not the configure step was able to locate the necessary prerequisites to build each plugin.
Even though the configure step was not able to find many libraries or modules, collectd will still compile successfully, albeit without these plugins. Often, you would like to enable several plugins at compile time, for example:
./configure --enable-java --enable-python
Without the appropriate package dependencies installed, the configure step will output the following line at the very end:
configure: error: "Some plugins are missing dependencies - see the summary above for details"
Use the two tables below to install the appropriate RPM packages for the plugins you would like to enable.
The following table shows the collectd libraries and their corresponding RPM package dependencies:
The following table shows the collectd modules and their corresponding RPM package dependencies:
Not all plugin dependencies were available from the CentOS Base and EPEL repositories. For these particular plugins, you would either have to:
- configure another YUM repository that has the necessary RPMs
- download and install the individual RPM from a third-party site
- build your own RPM
- compile the dependency from source
With regards to the java plugin, the 1.6.0 and 1.7.0 openjdk versions, in addition to the 1.8.0 version listed above, are able to satisfy the java dependency.
Once the plugin dependencies are sorted out, the make and make install steps typically go without a hitch. In a future post, I will outline how to build the collectd RPMs using the latest available version.