Table of Contents
- Introduction
- Requirements
- Installing collectd
- Installing collectd-web
- Download the collectd-web Git Repository and Modify the Standalone Python Server
- Run the Python CGI Server and Browse the collectd-web Interface
Introduction
Collectd is a Unix daemon that collects system performance statistics and provides ways to store the values in a variety of formats, for example in RRD files. This will help system administrators to maintain available resources and detect existing bottlenecks.
Collectd gathers statistics from the system and stores this information. Those statistics can then be used to find current performance bottlenecks and predict future system load.
Collectd-web is a web-based front-end for RRD data collected by collectd. It is based on contrib/collection.cgi
, a demo CGI script included in collectd.
The main objective of collectd-web is to develop an easy-to-use and customizable web interface for collectd.
This tutorial will cover the installation process for both the collectd service and collectd-web interface on CentOS 7.
Requirements
- A server running Centos v.7 with Apache installed
Installing collectd
The main function of collectd is to gather and store data statistics on the system. The collectd package is not available by default in the CentOS 7 repository. You will need to enable the EPEL repository on your system. Then you can install the collectd package from the EPEL repository.
You can install and enable EPEL repository from the default yum repository by running the following command:
sudo yum install epel-release
Once the EPEL repository has been installed, you can install collectd by running the following command:
sudo yum --enablerepo=epel install collectd
Now, start the collectd service and enable the service to start at boot time:
sudo systemctl start collectd
sudo systemctl enable collectd
Installing collectd-web
Before installing collectd-web, you need to install the Git package and required dependencies on your system:
sudo yum install git
sudo yum install rrdtool rrdtool-devel rrdtool-perl perl-HTML-Parser perl-JSON
Download the collectd-web Git Repository and Modify the Standalone Python Server
Next, download the collectd-web source using the git
command in /opt
directory with the following commands:
cd /opt/
sudo git clone https://github.com/httpdss/collectd-web.git
Once the collectd-web source is downloaded on your system, go to the collectd-web directory. Here you will find the Python server script runserver.py
.
cd collectd-web/
ls
Finally, give execute permission to the cgi-bin/graphdefs.cgi
CGI script:
sudo chmod +x cgi-bin/graphdefs.cgi
You can see the following output:
By default, collectd-web is configured to run on the loopback address 127.0.0.1
.
You will need to edit the runserver.py
script and change 127.0.0.1
to 0.0.0.0
, in order to bind on all network interface IP Adresses and access the collectd-web interface from a remote machine.
You can do this by editing runserver.py
as below:
sudo nano runserver.py
Change 127.0.0.1
to 0.0.0.0
:
#!/usr/bin/env python
import CGIHTTPServer
import BaseHTTPServer
from optparse import OptionParser
class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
cgi_directories = ["/cgi-bin"]
PORT = 8888
def main():
parser = OptionParser()
opts, args = parser.parse_args()
if args:
httpd = BaseHTTPServer.HTTPServer((args[0], int(args[1])), Handler)
print "Collectd-web server running at http://%s:%s/" % (args[0], args[1])
else:
httpd = BaseHTTPServer.HTTPServer(("0.0.0.0", PORT), Handler)
print "Collectd-web server running at http://%s:%s/" % ("0.0.0.0", PORT)
httpd.serve_forever()
if __name__ == "__main__":
main()</code></pre>
Save and exit the file.
Run the Python CGI Server and Browse the Collectd-Web Interface
After modifying the Python server script, you can start the server by running the following command:
sudo ./runserver.py &
You can see the following output:
Next, you will need to add a firewall rule to allow you to access collectd-web from a remote machine:
sudo firewall-cmd --zone=public --permanent --add-port=8888/tcp
sudo firewall-cmd --reload
Finaly, you can access the collectd-web interface at the URL http://your.server.ip:8888 in your web browser.
By default you will see a number of graphics about CPU, disk usage, network traffic, RAM, processes and other system resources by clicking on the hostname displayed on Hosts form.
Its not loading, ERROR : taking too long to respond i applied the firewall policy as well, still showing the same message, whenever i try to open the webpage
hi ,
I have followed the the installation steps but still i was unable to see the graph in collectd web . kindly help me to solve the issue .