This is an old revision of the document!


Monitorix

Monitorix is a great tool to measure and graph your devices and services .

it works perfectly on your local device to monitor and archive performances and usages.

Custom Monitor

Although there are many builtin monitored items (system, cpu, net, sensors, applications …) and features, you may have to monitor a special device or application that is not yet integrated .

That's the purpose of this page to explain how I manage to monitor my personnal gateway to the Internet which doesn't have builtin graph capabilities .

install monitorix

First we need to install and configure monitorix, there are many tutorials to do that, as I am using centos 8 system I followed that one :

Custom device

In this page I will demonstrate how I manage to monitor In and Out bandwith usage of my FreeBox-Crystal which is a French ADSL router . The device does provide an http service to get the status of its services . it replies on the Lan interface at the address of the router itself

this page returns many information in text format like this :

______________________________________________________________________

                      Etat de la Freebox                           
______________________________________________________________________

Informations générales :
========================

  Modèle                         Freebox ADSL            
  Version du firmware            1.5.28                  
  Mode de connection             Dégroupé                
  Temps depuis la mise en route  33 jours, 20 heures, 34 minutes

....
Adsl :
======

  Etat                           Showtime                
  Protocole                      ADSL2+                  
  Mode                           Interleaved             

                         Descendant         Montant           
                         --                 --                
  Débit ATM              11074 kb/s         681 kb/s          
...
   Interfaces réseau :
 -------------------

                         Lien           Débit entrant  Débit sortant 
                         --             --             --            
  WAN                    Ok             63 ko/s        9 ko/s        
  Ethernet               100baseTX-FD   10 ko/s        54 ko/s       

From the differents information provided by this web interface, the ones I want to graph is on the WAN interface the In trafic (here 63 Ko/s) and Out (9 ko/s)

custom module

I am not a monitorix developer , but with great and smart indication from Monitorix developers , as there is no generic module nor snmp capailities (anyway my Freebox doesn't provide such) , I was advise to create my own module based on an existing one that already collect and graph values from an http request . The Nginx module was my starting point .

copy nginx

you can check location of all the monitorix components by requesting file location of tha monitorix package with :

# rpm -ql monitorix
/etc/logrotate.d/monitorix
/etc/monitorix
/etc/monitorix/conf.d
/etc/monitorix/monitorix.conf
/etc/sysconfig/monitorix
/usr/bin/monitorix
/usr/lib/monitorix
/usr/lib/monitorix/HTTPServer.pm
/usr/lib/monitorix/Monitorix.pm
...
/usr/lib/monitorix/nginx.pm
...
/var/lib/monitorix/www
/var/lib/monitorix/www/cgi
/var/lib/monitorix/www/cgi/monitorix.cgi
...

here we can see particularly /etc/monitorix/monitorix.conf which is the main configuration file and /usr/lib/monitorix/nginx.pm which is the module I will duplicate for my device .

# cp nginx.pm fbxcfr.pm
# pwd
/usr/lib/monitorix

dev environement

After you have check that monitorix work fine with native modules, to help debuging , I removed all modules from the main config file : monitorix.conf in order that logs shows only potential problem of my specific module here named fbxcfr (just after nginx) .

<graph_enable>
        system          = n
        kern            = n
        proc            = n
        ....
        nginx           = n
        fbxcfr          = y

duplicate all nginx parameters in the conf file to fbxcfr (or whatever name you give to your module) so that your module is taken into account by the monitorix daemon . this happens if different sections: graph_enable, graph_name, graph_title and graphs

add module to monitorix.conf

<graph_enable>

        fbxcfr          = y

...
# fbxcfr graph
# -----------------------------------------------------------------------------
<fbxcfr>
        url = http://192.168.3.254/pub/fbx_info.txt
        port = 80
        rule = 24100
        rigid = 0, 0, 0
        limit = 100, 100, 100
</fbxcfr>
...
graph_name = system, kern, proc, ... nginx, fbxcfr,

<graph_title>
...
  nginx           = Nginx statistics
  fbxcfr          = FreeboX-Crystal statistics
...
<graphs>
...
 _nginx1         = Nginx connections
        _nginx2         = Nginx requests
        _nginx3         = Nginx traffic
        _fbxcfr1                = FbxCFR connections
        _fbxcfr2                = FbxCFR requests
        _fbxcfr3                = FbxCFR traffic
...

monitorix daemon in debug

stop your traditional run of monitorix

# systemctl stop monitorix.service 

run it in debug mode

# /usr/bin/monitorix -c /etc/monitorix/monitorix.conf -p /run/monitorix.pid -d all