Introduction
@H_
404_4@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.
@H_
404_4@
collectdis 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 var
IoUs 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.
@H_
404_4@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.
@H_
404_4@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.
@H_
404_4@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.
Prerequisites
@H_
404_4@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
@H_
404_4@For this exercise,you will also need kernel and the C library header files:
sudo yum install kernel-headers glibc-headers
Downloading collectd
@H_
404_4@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
Configuring collectd
@H_
404_4@After downloading and extracting the source files,change to that directory:
cd collectd-5.5.0
@H_
404_4@This package can be configured,built and installed with the typical
configure && make && make installsequence of commands.
@H_
404_4@Start by running the configure step so that we can have a look at the available plugins:
./configure
@H_
404_4@This command will output quite a bit to the screen,checking your system for the presence of var
IoUs 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...]
@H_
404_4@The summary at the end shows the var
IoUs plugins and whether or not the configure step was able to locate the necessary prerequisites to build each plugin.
@H_
404_4@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
@H_
404_4@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"
@H_
404_4@Use the two tables below to install the appropriate RPM packages for the plugins you would like to enable.
Libaries
@H_
404_4@The following table shows the collectd libraries and their corresponding RPM package dependencies:
Library |
RPM Package(s) |
libatasmart |
libatasmart-devel |
libcurl |
libcurl-devel |
libdbi |
libdbi-devel |
libesmtp |
libesmtp-devel |
libganglia |
ganglia-devel |
libgcrypt |
libgcrypt-devel |
libhal |
hal-devel |
libhiredis |
hiredis-devel |
libiptc |
iptables-devel |
libjvm |
java-1.8.0-openjdk-devel |
libldap |
openldap-devel |
liblvm2app |
lvm2-devel |
libmemcached |
libmemcached-devel |
libmnl |
libmnl-devel |
libmodbus |
libmodbus-devel |
libMysqL |
MysqL-devel |
libnetsnmp |
net-snmp-devel |
libnotify |
libnotify-devel |
libopenipmi |
OpenIPMI-devel |
liboping |
liboping-devel |
libpcap |
libpcap-devel |
libperl |
perl-devel,perl-ExtUtils-Embed |
libpq |
postgresql-devel |
librabbitmq |
librabbitmq-devel |
librrd |
rrdtool-devel |
libsensors |
lm_sensors-devel |
libstatgrab |
libstatgrab-devel |
libudev |
libudev-devel |
libupsclient |
nut-devel |
libvarnish |
varnish-libs-devel |
libvirt |
libvirt-devel |
libxml2 |
libxml2-devel |
libyajl |
yajl-devel |
protobuf-c |
protobuf-c-devel |
python |
python-devel |
Modules
@H_
404_4@The following table shows the collectd modules and their corresponding RPM package dependencies:
Module |
RPM Package(s) |
amqp |
librabbitmq-devel |
apache |
libcurl-devel |
bind |
libcurl-devel,libxml2-devel |
ceph |
yajl-devel |
curl |
libcurl-devel |
curl_json |
libcurl-devel,yajl-devel |
curl_xml |
libcurl-devel,libxml2-devel |
dbi |
libdbi-devel |
dns |
libpcap-devel |
gmond |
ganglia-devel |
ipmi |
OpenIPMI-devel |
iptables |
iptables-devel |
java |
java-1.8.0-openjdk-devel |
log_logstash |
yajl-devel |
lvm |
lvm2-devel |
memcachec |
libmemcached-devel |
MysqL |
MysqL-devel |
netlink |
libmnl-devel |
Nginx |
libcurl-devel |
notify_desktop |
libnotify-devel |
notify_email |
libesmtp-devel |
nut |
nut-devel |
openldap |
openldap-devel |
perl |
perl-devel,perl-ExtUtils-Embed |
ping |
liboping-devel |
postgresql |
postgresql-devel |
python |
python-devel |
redis |
hiredis-devel |
rrdtool |
rrdtool-devel |
smart |
libatasmart-devel,libudev-devel |
snmp |
net-snmp-devel |
varnish |
varnish-libs-devel |
virt |
libvirt-devel,libxml2-devel |
write_http |
libcurl-devel |
write_redis |
hiredis-devel |
Notes
@H_
404_4@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
@H_
404_4@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.
Conclusion
@H_
404_4@Once the plugin dependencies are sorted out,the
makeand
make installsteps typically go without a hitch. In a future post,I will outline how to build the collectd RPMs using the latest available version.
原文链接:https://www.f2er.com/centos/380489.html