http://www.tecmint.com/monitor-linux-server-resources-with-collectd-web-and-apache-cgi/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+tecmint+%28Tecmint%3A+Linux+Howto%27s+Guide%29
This tutorial will discuss how you can install and run Collectd-web interface, which is a front-end web monitoring tool for Collectd daemon, in conjunction with Apache CGI interface in order to produce graphical html outputs in order to monitor Linux boxes.
At the end of the article we will, also, present how you can protect Collectd-web interface using .hpasswdApache Authentication mechanism.
Requirements
The requirement of this article is, you must have Collectd and Collectd-Web installed on your Linux system. To install these packages, you must follow Steps #1 and #2 from the previous article of this series at:
Only Follow following two steps from the above link:
Once these two required things completed successfully, you can continue further instructions in this article to configure Collectd-web with Apache CGI.
Step 1: Installing Apache Web Server
1. Assuming that you already have installed Apache web server on your system, if not you can install using following command according to your Linux distribution.
2. After Apache installed, change the directory to your default web server document root (which is located under/var/www/html/ or /var/www system path and clone the Collectd-web Github project by issuing the below commands:
Also, make the following Collectd-web script executable by issuing the following command:
Step 2: Enable Apache CGI (.cgi scripts) for Default Host
3. In order for Apache to run the CGI scripts located under the default host HTML Collectd-web cgi-bin directory, you need to explicitly enable Apache CGI interface for Bash scripts (with .cgi extension) by altering the sites-available default host and adding the below statements block.
On Debian Systems
First open Apache default host configuration file for editing with nano editor:
While the file is opened for editing add the following directive block below the Document Root directive as illustrated on the below image:
Enable CGI in Debian
After you’re done editing the file, close it with CTRL + o and exit nano editor (CTRL+x), then enable Apache CGI module and restart the server in order to apply all the changes made so far by issuing the below commands:
On RedHat Systems
4. To enable Apache CGI interface for CentOS/RHEL, open httpd.conf Apache configuration file and add the following lines at the bottom of the file:
Add following excerpt to httpd.conf file.
In order to apply changes, restart httpd daemon by issuing the following command:
Step 3: Browse Collectd-web Interface
5. In order to visit Collectd-web interface and visualize statistics about your machine collected so far, open a browser and navigate to your machine IP Address/collectd-web/ URI location using the HTTP protocol.
Step 4: Password Protect Collectd-web URL using Apache Authentication
6. In case you want to limit access to Collectd-web interface by protecting it using Apache Authentication mechanism (.htpasswd), which requires visitors to enter a username and a password in order to access a web resource.
To do so, you need to install apache2-utils package and create a set of credentials for local authentication. To achieve this goal, first issue the following command to install apache2-utils package:
7. Next, generate a username and a password which will be stored on a hidden local .htpass file located under Apache default host Collectd-web path by issuing the below command:
Try to protect this file by assigning the following permissions:
8. On the next step, after you have generated .htpass file, open Apache default host for editing and instruct the server to use htpasswd basic server-side authentication by adding the following directive block as illustrated on the below screenshot:
9. The last step in order to reflect changes is to restart Apache server by issuing the below command and visit the Coollectd-web URL page as described above.
A pop-up should appear on the web page requesting for your authentication credentials. Use the username and password created earlier to access Collectd web interface.