How to Install and Configure ‘Collectd’ and ‘Collectd-Web’ to Monitor Server Resources in Linux

Collectd-web is a web front-end monitoring tool based on RRDtool (Round-Robin Database Tool), which interprets and graphical outputs the data collected by the Collectd service on Linux systems.

Collectd service comes by default with a huge collection of available plug-ins into its default configuration file, some of them being, by default, already activated once you have installed the software package.

Collectd-web CGI scripts which interprets and generates the graphical html page statistics can be simply executed by the Apache CGI gateway with minimal of configurations required on Apache web server side.

However, the graphical web interface with the generated statistics can, also, be executed by the standalone web server offered by Python CGIHTTPServer script that comes pre-installed with the main Git repository.

This tutorial will cover the installation process of Collectd service and Collectd-web interface on RHEL/CentOS/Fedora and Ubuntu/Debian based systems with the minimal configurations needed to be done in order to run the services and to enable a Collectd service plug-in.

Please go through the following articles of collectd series.

Part 1: Install and Configure ‘Collectd’ and ‘Collectd-Web’ to Monitor Linux Resources

Step 1: – Install Collectd Service

1. Basically, the Collectd daemon task is to gather and store data statistics on the system that it runs on. The Collectd package can be downloaded and installed from the default Debian based distribution repositories by issuing the following command:

On Ubuntu/Debian
# apt-get install collectd			[On Debian based Systems]
Install Collectd on Ubuntu
Install Collectd on Debian/Ubuntu
On RHEL/CentOS 6.x/5.x

On older RedHat based systems like CentOS/Fedora, you first need to enable epel repository under your system, then you can able to install collectd package from the epel repository.

# yum install collectd
On RHEL/CentOS 7.x

On latest version of RHEL/CentOS 7.x, you can install and enable epel repository from default yum repos as shown below.

# yum install epel-release
# yum install collectd
Install Collectd on CentOS
Install Collectd on CentOS/RHEL/Fedora

Note: For Fedora users, no need to enable any third party repositories, simple yum to get the collectd package from default yum repositories.

2. Once the package is installed on your system, run the below command in order to start the service.

# service collectd start			[On Debian based Systems]
# service collectd start                        [On RHEL/CentOS 6.x/5.x Systems]
# systemctl start collectd.service              [On RHEL/CentOS 7.x Systems]

Step 2: Install Collectd-Web and Dependencies

3. Before starting to import the Collectd-web Git repository, first you need to assure that Git software package and the following required dependencies are installed on your machine:

----------------- On Debian / Ubuntu systems -----------------
# apt-get install git
# apt-get install librrds-perl libjson-perl libhtml-parser-perl
Install Git on Ubuntu
Install Git on Debian/Ubuntu
----------------- On RedHat/CentOS/Fedora based systems -----------------
# yum install git
# yum install rrdtool rrdtool-devel rrdtool-perl perl-HTML-Parser perl-JSON
Install Git on CentOS
Install Git and Dependencies

Step 3: Import Collectd-Web Git Repository and Modify Standalone Python Server

4. On the next step choose and change the directory to a system path from the Linux tree hierarchy where you want to import the Git project (you can use /usr/local/ path), then run the following command to clone Collectd-web git repository:

# cd /usr/local/
# git clone https://github.com/httpdss/collectd-web.git
Git Clone Collectd-Web
Git Clone Collectd-Web

5. Once the Git repository is imported into your system, go ahead and enter the collectd-web directory and list its contents in order to identify the Python server script (runserver.py), which will be modified on the next step. Also, add execution permissions to the following CGI script: graphdefs.cgi.

# cd collectd-web/
# ls
# chmod +x cgi-bin/graphdefs.cgi
Set Execute Permission
Set Execute Permission

6. Collectd-web standalone Python server script is configured by default to run and bind only on loopback address (127.0.0.1).

In order to access Collectd-web interface from a remote browser, you need to edit the runserver.py script and change the 127.0.1.1 IP Address to 0.0.0.0, in order to bind on all network interfaces IP Addresses.

If you want to bind only on a specific interface, then use that interface IP Address (not advised to use this option in case your network interface Address is dynamically allocated by a DHCP server). Use the below screenshot as an excerpt on how the final runserver.py script should look like:

# nano runserver.py
Configure Collect-web
Configure Collect-web

If you want to use another network port than 8888, modify the PORT variable value.

Step 4: Run Python CGI Standalone Server and Browse Collectd-web Interface

7. After you have modified the standalone Python server script IP Address binding, go ahead and start the server in background by issuing the following command:

# ./runserver.py &

Optional, as an alternate method you can call the Python interpreter to start the server:

# python runserver.py &
Start Collect-Web Server
Start Collect-Web Server

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Matei Cezar
I'am a computer addicted guy, a fan of open source and linux based system software, have about 4 years experience with Linux distributions desktop, servers and bash scripting.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

17 Comments

Leave a Reply
  1. Hi

    I have installed collectd and the service is up and running. I have configured the ip address in the python script and the UI is accessible, but when i enable the plugin in /etc/collectd.conf i am not able to see anything in the web console.

    Kindly help to solve my issue.

    Reply
  2. Great article but I have a problem already at step 8. It produces a web-page without any graphics and the button “server.example.lan” is missing.

    Thank you so much

    Reply
  3. This post is bit out dated for CentOS 7.2 yum install collectd does not seem to create folder /etc/collectd/collectd.conf.d or /etc/collectd. collectd.conf file is installed in /etc/collectd.conf. How do i get collectd-web to work with collectd. the version it is installing is collectd.x86_64 0:5.5.2-1.el7

    Reply
    • @Kumar

      Thanks for pointing out those configuration files of Collectd, let me check the instructions on latest CentOS 7.2 and will update the article with new supported instructions..

      Reply
  4. I want to point out that this is by no means a complete instructional when dealing with Centos 6.7

    There were several steps required in order to make this work, such as:

    Un-commenting out the rrdtool plugin line in collectd.conf.
    Adding the rrdtool plugin definition in collectd.conf https://collectd.org/wiki/index.php/Plugin:RRDtool
    Creating a configuration file: collection.conf in /etc/collectd for collectd-web to get rrdfile location details from. https://www.sub-design.co.uk/wordpress/?p=755
    Installing the collectd-rrdtool package https://www.sub-design.co.uk/wordpress/?p=769

    After I had gone though and did all of these things, collectd started loading information in to my collectd-web interface, but not before. I hope this helps someone who is stuck.

    Reply
  5. Thank you. This is a great article and I now have everything set up. However, does anybody know how to protect the web interface with a password ? I just don’t like the idea that anybody can connect on the interface and see the data.

    Reply
    • htpasswd –c /path/to/collectd_directory/.htpasswd your_user

      Open Apache config file and add the following statements:

      AuthType basic
      AuthName “What ever message you want”
      AuthBasicProvider file
      AuthUserFile /path/to/collectd_directory/.htpasswd
      Require user your_user

      Then a2enmod auth_basic and restart apache daemon.

      Reply
      • Thank you for your answer. However, I don’t think this solution is appropriate here because we’re not using Apache for the web interface (we are using a python module).
        I found a solution by modifying the runserver.py file using the information on this page : https://gist.github.com/fxsjy/5465353

        I simply put the content of the class AuthHandler in the class Handler of the runserver.py file and added a few more lines here and there (to use the key and import the stuff needed) and it works !

        Reply
  6. Great post as usual. But i prefer Munin Server-Client. Can anyone is tecmint please make a tutorial on SAN. I know no one own SAN at home. But it will be helpful if someone make a demo on

    1: Discovering HBA and what is WWN and how to know
    2: Discovering LUN
    3: And multipathing

    Because this is one critical thing and Information on this subject is just scattered and there is no sequence like what thing should be done first and then and then and then ……

    Please please make a tut on it or if not possible then please give us theoretical tutorial with commands ……. Thanks and Bless you

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.