Skip to content

Updating Collectd

Cnaik edited this page Aug 27, 2019 · 6 revisions

Building collectd exporter

The instructions provided below specify the steps to build collectd exporter version 0.4.0 on Linux on IBM Z for the following distributions:

  • RHEL (7.4, 7.5, 7.6)
  • SLES (15)
  • Ubuntu (16.04, 18.04)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Step 1: Install dependencies

1.1) Install dependencies

export SOURCE_ROOT=/<source_root>/
  • RHEL (7.4, 7.5, 7.6)

      sudo yum install -y make cmake gcc wget tar git bzip2 patch
    
  • SLES (15)

      sudo zypper install -y make cmake gcc gcc-c++ wget tar git bzip2 patch
    
  • Ubuntu (16.04, 18.04)

      sudo apt-get install -y make cmake gcc g++ wget tar git patch 
    

1.2) Other dependencies

  • Go - Refer go recipe

1.3) Set environment variables

   export GOPATH=$SOURCE_ROOT

Step 2: Download, build and configure

2.1) Download collectd exporter code and build

   mkdir -p $GOPATH/src/github.com/prometheus
   cd $GOPATH/src/github.com/prometheus
   git config --global url."git://github.com/".insteadOf "https://github.com/"
   git clone https://github.com/prometheus/collectd_exporter  
   cd collectd_exporter  
   git checkout v0.4.0
   make build   

2.2) Run tests (Optional)

    make test  

2.3) Run collectd exporter

    ./collectd_exporter --collectd.listen-address=":25826"

2.4) Integrate collectd exporter with Prometheus and collectd

  • Open http://<ip_address>:9103/metrics in your browser to access metrics exposed by collectd exporter.

  • Follow below steps to view metrics via Prometheus:

    • Click here to refer to build instructions for Prometheus.
    • Edit prometheus.yml as below before starting Prometheus.
      --- prometheus.yml_orig	2019-08-26 08:11:14.725767043 +0000
      +++ prometheus.yml	2019-08-26 08:12:04.168400025 +0000
      @@ -27,3 +27,7 @@
      
           static_configs:
           - targets: ['localhost:9090']
      +  - job_name: 'collectd'  
      +    scrape_interval: 15s  
      +    static_configs:  
      +    - targets: ['localhost:9103']    
    • Access the Prometheus UI and click on the Graph tab to view the data scraped by Prometheus.
  • Follow below steps to setup collectd to start sending metrics to collectd exporter

    • Install collectd

      • RHEL :
      sudo yum install -y perl-devel libcurl-devel      
      cd $SOURCE_ROOT
      wget http://collectd.org/files/collectd-5.8.1.tar.bz2  
      tar -xvf collectd-5.8.1.tar.bz2 
      cd collectd-5.8.1  
      ./configure
      make  
      sudo make install  
      • SLES :
      sudo zypper install -y perl libcurl-devel                
      cd $SOURCE_ROOT
      wget http://collectd.org/files/collectd-5.8.1.tar.bz2  
      tar -xvf collectd-5.8.1.tar.bz2
      cd collectd-5.8.1  
      ./configure
      make  
      sudo make install  
      • Ubuntu :
      sudo apt-get install -y collectd
      
    • Configure collectd.conf

      • Edit /opt/collectd/etc/collectd.conf to enable network and write_http plugins (For RHEL and SLES)
        --- /opt/collectd/etc/collectd.conf_orig	2019-08-26 08:33:56.053856419 +0000
        +++ /opt/collectd/etc/collectd.conf	2019-08-26 08:35:24.676521877 +0000
        @@ -949,16 +949,16 @@
         #	IgnoreSelected false
         #</Plugin>
         
        -<Plugin network>
        +#<Plugin network>
         #	# client setup:
        -	Server "ff18::efc0:4a42" "25826"
        -	<Server "239.192.74.66" "25826">
        +#	Server "ff18::efc0:4a42" "25826"
        +#	<Server "239.192.74.66" "25826">
         #		SecurityLevel Encrypt
         #		Username "user"
         #		Password "secret"
         #		Interface "eth0"
         #		ResolveInterval 14400
        -	</Server>
        +#	</Server>
         #	TimeToLive 128
         #
         #	# server setup:
        @@ -978,7 +978,7 @@
         #
         #	# "garbage collection"
         #	CacheFlush 1800
        -</Plugin>
        +#</Plugin>
         
         #<Plugin nfs>
         #	ReportV2 false
        @@ -1817,4 +1817,17 @@
         #    	Hysteresis 3
         #    </Type>
         #  </Host>
        -#</Plugin>
        +#</Plugin> 
        +LoadPlugin network
        +<Plugin network>
        +  Server "localhost" "25826"
        +</Plugin>
        +
        +LoadPlugin write_http
        +<Plugin write_http>
        +  <Node "collectd_exporter">
        +    URL "http://localhost:9103/collectd-post"
        +    Format "JSON"
        +    StoreRates false
        +  </Node>
        +</Plugin>
      • Edit /etc/collectd/collectd.conf to enable network and write_http plugins (For Ubuntu)
        --- /etc/collectd/collectd.conf_old	2019-08-22 09:52:08.219292319 +0000
        +++ /etc/collectd/collectd.conf	2019-08-26 11:36:56.964723192 +0000
        @@ -91,7 +91,7 @@
         #LoadPlugin apcups
         #LoadPlugin ascent
         #LoadPlugin barometer
        -LoadPlugin battery
        +#LoadPlugin battery
         #LoadPlugin bind
         #LoadPlugin ceph
         #LoadPlugin cgroups
        @@ -1312,4 +1312,16 @@
         <Include "/etc/collectd/collectd.conf.d">
        	Filter "*.conf"
         </Include>
        +LoadPlugin network
        +<Plugin network>
        +  Server "localhost" "25826"
        +</Plugin>
         
        +LoadPlugin write_http
        +<Plugin write_http>
        +  <Node "collectd_exporter">
        +    URL "http://localhost:9103/collectd-post"
        +    Format "JSON"
        +    StoreRates false
        +  </Node>
        +</Plugin>
    • Start collectd service

      • RHEL and SLES :
      sudo /opt/collectd/sbin/collectd &  
      
      • Ubuntu :
      sudo service collectd start
      
    • Open http://<ip_address>:9090 in your browser to access Web UI.

References