📜 ⬆️ ⬇️

collectd + front-end



As practice shows, most of the clients do not monitor the resources used by them, the services they rent (this is especially noticeable on cheap VPS services from $ 3). That is, after installing the system and setting up the software required for the project, the server’s further fate is given occasion. And, when there are problems with server performance, there is not too much information to analyze.

In addition to the installed and configured logging in atop (which is also not often found), the logs of the system, I would like to have more information with which to work.
')
This article will describe how to install and configure collectd and collectd-web using the example of a Debian family OS.

Some general information.


Collectd is a lightweight daemon that collects statistics on resource usage (and not only), and adds information in rrd format. In fact, collectd itself only collects statistics, to view and analyze the collected information you need to install a web interface. A complete list of front-ends for collectd can be found here .

The big plus is that for collectd there are a large number of plug-ins for various tasks.

It is worth considering that collectd is able to set up “master server and nodes” - data from monitored servers is sent to the master, which stores them and draws graphics.

It is worth considering that different web-interfaces are implemented on different frameworks. Depending on your preferences and software installed for the project, you can choose the most optimal option for yourself.


The installation process itself


Update the list of packages available in the repositories.
# apt-get update 


We install collectd.

 # apt-get install collectd 


Run collectd after installation.
 # service collectd start 


Collectd is installed and running, now proceed to install the web interface.

First, install git .
 # apt-get install git 


Install the necessary modules.
 # apt-get install librrds-perl libjson-perl libhtml-parser-perl 


We put a web server.
 # apt-get install apache2 


After installing apache, go to the default directory of its virtualhost.
 # cd /var/www/html 


Begin to install the web interface itself.
 # git clone https://github.com/httpdss/collectd-web.git # chmod +x /var/www/html/collectd-web/cgi-bin/graphdefs.cgi 


To run cgi scripts collect-web, located on the default path (in this case - / var / www / html / collectd-web /), you must explicitly specify in the config. We edit the default virtualhost config.
 # nano /etc/apache2/sites-available/000-default.conf 


Add this block after the line with the directive DocumentRoot.

 <Directory /var/www/html/collectd-web/cgi-bin> Options Indexes ExecCGI AllowOverride All AddHandler cgi-script .cgi Require all granted </Directory> 





We include apache CGI module.
 # a2enmod cgi cgid 


We are overloading the web server for the changes to take effect.
 # service apache2 restart 


Now collectd is accessible from the outside by web.
http: // xxx.xxx.xxx.xxx / collectd-web /




Exposing it in this form to the world is a bad idea, you need to restrict access to it.
You can use the standard apache utilities - htpasswd .

To get started, install them if they do not pull up when installing a web server.
 # apt-get install apache2-utils 


We generate a file with passwords.
 # htpasswd -c /var/www/html/collectd-web/.htpasswd username New password: Re-type new password: Adding password for user username 

Now we need to teach the Apache to let the password collect. To do this, edit the desired virtualhost.
 # nano /etc/apache2/sites-enabled/000-default.conf 

Add another block.
 <Directory /var/www/html/collectd-web > AuthType Basic AuthName "Collectd Restricted Page" AuthBasicProvider file AuthUserFile /var/www/html/collectd-web/.htpasswd Require valid-user </Directory> 





We leave ctrl + x, to the question whether to save the changes, we answer yes + enter.

We pull apache in order for the changes to take effect.
 # service apache2 restart 


We check that we were not mistaken anywhere, and now our collectd does not allow anyone to get caught.



Done, now in case of problems with the server or an excess of free time and lack of plans, you can open collectd-web, analyze server resources used, possible bottlenecks and assess the growth trend.

Well, or you can simply admire the beautiful graphs.

Source: https://habr.com/ru/post/272447/


All Articles