Friday, June 28, 2013

RPi-Monitor: Version 2.x advance usage and customization

Edit: RPi-Monitor version 2.7 introduce a change in configuration name and location:
  • /etc/rpimonitor d.conf becomes /etc/rpimonitor/daemon.conf
  • /etc/rpimonitord.conf.d becomes /etc/rpimonitor/data.conf
  • /etc/rpimonitord.conf.d/*.conf becomes /etc/rpimonitor/*.conf

In this article we will see how to do the things described in RPi-Monitor: Advance usage and customization and maybe, a little bit more...

We will then answer the same questions : How should I do if I want to...
  • Customize RPi-Monitor v2.x to fit a particular needs?
  • Use it with my own Web Server? 
  • Add "friends" linking RPi-Monitor v2.x running on different platform together?
  • Use it into another Linux distribution than Raspbian? 
  • Add other graphs from additional sources (other mount point or external temperature probe)?

Photo from Flickr AttributionNoncommercialShare Alike cc-by-nc-sa by blogjunkie
Note: A prerequisite is to install the latest version of RPi-Monitor v2.x
Customize RPi-Monitor v2.x to fit a particular needs

If you want to customize RPi-Monitor in a way not described bellow you just have to know 2 things:
  • The man pages rpimonitord and rpimonitord.conf explains how to use and configure RPi-Monitor.
  • The configuration file is documented to let you customize to your need.
You will find bellow some example of customization showing you the capababilities of RPi-Monitor v2.x

Use it with my own Web Server

In this example I will use nginx server. You could use the same tactic with your preferred web server.

Let's first update the configuration file to disable the embedded web server. Edit the file /etc/rpimonitord.conf and set daemon.noserver=1.

Then restart RPi-Monitor with the command:
    sudo service rpimonitor restart

The embedded server is no more running so, we will need to configure another server to access the data.

For nginx we will create the file /etc/nginx/sites-enabled/rpimonitor with the following content:

and restart the server with the command:
    sudo service nginx restart

Now you can reach RPi-Monitor with your favorite browser on your favorite web server.

To go further, you can read the article RPi-Monitor: Build a multi-sites SSL certificate to improve user experience.

Add "friends" linking RPi-Monitor running on different platform together

Friends is a notion that comes in version 1.2. A friend is simply another computer running RPi-Monitor. Configuring friends will add a drop down list on the right of the top menu with a links to RPi-Monitor sitting on the other computer.

Friends menu is visible on the top right

In /etc/rpimonitord.conf.d/default.conf, each friend is identified by its and is described by the 2 following parameters:

Here is an example of configuration for 3 friends:

Use it into another Linux distribution than Raspbian

RPi-Monitor has been designed to run into a Raspberry Pi but as it is using only standard Linux resources, it is not hardware dependent. A simple configuration update can make it run on UbuntuCentOS or any other distribution.

Ubuntu is a Debian based distribution as Raspbian. The installation can then be done using the deb package available for each releases. Download and install the package as described in this previous post.

With CentOS and withe any non Debian based distribution it will required to perform a manual installation.
First install the perl dependencies: HTTP::Daemon (perl-libwww-perl), RRD (rrdtool-perl) and JSON(perl-JSON)

Connect to github  and select the latest stable branch on the top left dropdown list.
Then download the code as zip file from the link "Download zip" visible at the bottom of the right menu.

Unpack it.

Finally install rpimonitor manually:
    su -
    mv Version-2.x/rpimonitor /usr/local

You can now start RPi-Monitor with the following commands:
    cd /usr/local/rpimonitor
    ./rpimonitird -c rpimonitor.conf -c default.conf

Note: I will not describe here how to configure the auto startup since each distribution has its own way to do so. An upstart script is available into RPi-Monitor github tools directory, it may help you in such an action.

Once the installation is done you can start RPi-Monitor and connect to it with your favorite browser.
You may notice that some values are undefined or displayed as NaN (Not a Number). To fix these issues, you will have to update the configuration file (rpimonitord.conf or default.conf in /etc/ + /etc/rpimonitord.conf.d or /usr/local/rpimonitor/ depending on your installation).

CentOS 6.3 before configuration file customisation

Add other graphs from additional sources: other mount point

For this section we will take the example of an additional disk on sda as described previous article  RPi-Monitor: Advance usage and customization.

The disk have a disk with two partition /dev/sda1 and /dev/sda3.
The command and regular expression will be the following:
  • sda1 disk size command : df -t ext2,  regular expression: sda1\s+(\d+)
  • sda1 used space command : df -t ext2,  regular expression: sda1\s+\d+\s+(\d+)
  • sda3 disk size command : df -t ext4,  regular expression: sda3\s+(\d+)
  • sda3 used space command : df -t ext4,  regular expression: sda3\s+\d+\s+(\d+)
First we need to configure the extraction of partitions sizes which are extracted once at RPi-Monitor startup. We will create a file /etc/rpimonitord.conf.d/custo.conf with the data configured as static data like this:

The id of the KPIs start at 10 since in my configuration files the previous KPI was 9. This comment is the same for next ids.
The post processing is configured to transform kB into MB by dividing the extracted result by 1024.

For dynamic values extracted every 10 seconds, the configuration will be:

Dynamic stat will be stored into a RRD File as GAUGE. Ref to RRDTool help for detail about Data Source Types.
Now we will add a status line for this disk whit the following icon:

Disk icon has been found here
This icons has to be installed into the img directory of RPi-Monitor which is by default /usr/share/rpimonitor/web/img/.

The configuration to add a new status strip will then be the following:

The configuration may need some explanation:
We do configure 4 lines. Each line is describing a javascript line using some predefined functions: KMG, Precent and ProgressBar. This function are called by the browser while rendering the page. Some variable coming from the extracted data are also used. These variables are starting by the keyword 'data.'. For deeper detail about this configuration execute the command man rpimonitord.conf

To see our modification we need to restart RPi-Monitor and refresh the statistics page into our browser.
    sudo  service rpimonitor restart

The result of the configuration is at the bottom of the following screenshot:

The status page is working, let's now add a graphic of the disk usage. This is done with the following configuration:

The configuration may also need some explanation
We do configure 2 graphs each having 2 curves. The first curve represent the total and is using static data extracted previously. This curve will be represented as a light red line.
The second curve is representing the usage of disk and is represented as a light blue line filled. The parameters defining the curve are define by the keyword ds_graph_options. Details of this parameter can be found in javascriptrrd help page. Restart rpimonitor to activate the new graph.

After waiting a little time to let the system extract data you will see this kind of graph.

Add other graphs from additional sources: external temperature probe

Let's build a little electronic device to measure the room temperature and add this in the temperature graph.
Do do that, you will need:
  • 1 x DS18B20
  • 1 x 4.7k resistor
Plug them as described in the following schema extracted from Adafruit Lesson 11:

Lets first load the kernel module required to get the information from this probe:
    sudo modprobe gpio
    sudo modprobe w1-gpio
    sudo modprobe w1-therm

First we have to identify the id of our probe:
    ls /sys/bus/w1/devices/
    28-000004fe1847  w1_bus_master1

the id is: 28-000004fe1847. Let's now check if we can get the temperature:
    cat /sys/bus/w1/devices/28-000004fe1847/w1_slave
    5a 01 4b 46 7f ff 06 10 a3 : crc=a3 YES
    5a 01 4b 46 7f ff 06 10 a3 t=21625

It looks to work. So now we need to extract the the numbers ending the second line (21625). The regular expression will then be t=(\d+)$. I'll not do a course about what a regexp is there are many site on the internet explaining it.

The following configuration have to be added at the end of /etc/rpi-monitord.conf.d/custo.conf. It will extract the temperature measured by the external probe:

We will then add the livingroom temperature as Ambient temperature into the existing Temperature status strip by adding the following line at the end of the file custo.conf:

After restarting RPi-Monitor, you will see the Ambient temperature into the status page as in the screenshot bellow:

We will then add the Ambiant temperature into the existing Temperature graph by adding the following line to custo.conf:

After restarting RPi-Monitor, you will see the Ambient temperature as an additional curve into the Temperature graph of the statistics page as in the screenshot bellow:


  1. You can also easily add WiFi network by adding the following to /etc/rpimonitord.conf.d/default.conf as indicated or just copy and paste into /etc/rpimonitord.conf.d/custo.conf

    # Additions to display WiFi stats

    #This goes on the end of the KPI's section around line 187

    # This goes on the end of the section that begins '' around line 352
    web.status.1.content.8.line.2="WiFi Sent: <b>"+KMG(data.wifi_send)+"<i class='icon-arrow-up'></i></b> Received: <b>"+KMG(Math.abs(data.wifi_received)) + "<i class='icon-arrow-down'></i></b>"

    #This goes in the web.statistics section at the end of the the section that begins '' around line 375
    web.statistics.1.content.2.ds_graph_options.wifi_send.label=WiFi Upload bandwidth (bits)
    web.statistics.1.content.2.ds_graph_options.wifi_send.lines={ fill: true }
    web.statistics.1.content.2.ds_graph_options.wifi_received.label=WiFi Download bandwidth (bits)
    web.statistics.1.content.2.ds_graph_options.wifi_received.lines={ fill: true }

  2. Hi Xavier!

    Nice work. I found it very usable! Thanks a lot!

    I was wondering if it is possible to use mysql as datasource in rpi-monitor somehow?
    For example I would make a python script to extract one particular data from mysql table. Could I use this script as a source?
    Or actually could I use environmental variables as source. (Maybe I could set env var from bash script)
    As I have experienced the SD card do not like that I write and read a txt file every 10 seconds just for data source purposes.

    1. OK! It's a blame!
      I have done it whith a simple bash script! Sorry for disturbing!
      For whom may want to use this clever software whith mysql source here is my solution for the problem:

      I have made a bash script with a MySQL SELECT, which gets $foo from database and an echo $foo at the end of script. (named e.g.:
      I've made a symlink in /usr/bin which is showing to my bash script (Note: the symlink has not got extension. So it is like: ~sample rather then
      In rpimonitord.conf.d/default.conf I've used the symlink as source, like this:


      That's it. And it works properly.

  3. How can I add the "lpstat -p"? This is a simple status message.
    It's not working:
    dynamic.10.source=lpstat -p
    web.status.1.content.9.line.1="Status: "+data.cups+""

    Thank you!

    1. To customize RPi-Monitor, I would advise to read the comment I made in DHT11/22 article (
      Before configuring RPi-Monitor, you should first try the regexp with perl and once it works, configure it.
      Once you will have find the perfect setup, I'll let you post you configuration and share it to everybody.
      (Note: sorry for this short response but I started a new job and will have less time for RPi-Monitor...)

    2. Check the status of CUPS printer server:
      static.10.source=lpstat -p
      web.status.1.content.9.line.1='Status: ' + data.printer_status + '.'

      The 64x64px icon:


      I have character coding problem, I can't repair it:

  4. Hi Xavier! Thank you for your work!

    Could you please help me to find what am I doing wrong? I want to add temperature sensor data from DS1822. Here it is:

    $ cat /sys/bus/w1/devices/22-000000342f03/w1_slave
    a6 01 4b 46 7f ff 0a 10 f6 : crc=f6 YES
    a6 01 4b 46 7f ff 0a 10 f6 t=26375

    So I created a /etc/rpimonitord.conf.d/ds1822.conf file wth following lines:

    web.status.1.content.4.line.2="DS1822 #000000342f03 temperature: <b>"+data.temp_ds1822_000000342f03+"°C</b>"

    web.statistics.1.content.8.ds_graph_options.temp_ds1822_000000342f03.label=DS1822 #000000342f03

    Here is rpimonitord -s output:

    But I don't see sensor data after restarting rpimonitord and there's no /usr/share/rpimonitor/web/stat/temp_ds1822_000000342f03.rrd file.

    Where is my mistake?

    1. Well, after I changed name to temp_ds1822 the /usr/share/rpimonitor/web/stat/temp_ds1822.rrd file appeared, but there's still no sensor data displayed in web interface. I also changed regexp like in your example t=(\d+)$, but it didn't help.

    2. OK, I've got it working (I don't understand how). But I found a bug.
      I created a /etc/rpimonitord.conf.d/bmp085.conf file with the following content:
      dynamic.17.rrd=GAUGE Pressure
      web.status.2.content.2.line.1="Pressure: "+data.pressure+" mm Hg"
      web.statistics.1.content.9.ds_graph_options.pressure.label=Barometric pressure (mm Hg)

      The commented line was a trace of my experiments. But until I deleted it completely I could not open statistics page using the link in top of the page (it points to statistics.html), but it worked if I entered statistics.html?activePage=0 manually in address line. The commented out string should not have any effect, but it has.

  5. This comment has been removed by the author.

  6. Hi ! Nice work.

    I'm reading the temperature sensor from another Pi on the network using the following command :
    ssh pi@ cat /sys/bus/w1/devices/28-000004f14128/w1_slave
    and it works fine.

    Now when I use (in custo.conf) :
    dynamic.18.source=ssh pi@ /sys/devices/w1_bus_master1/28-000004f14128/w1_slave

    I get an "undefined°C" temp in RPI-Monitor...

    I'm guessing I'm using the wrong command for the source... Could anyone help ?


    1. I have similar problem with other system variables.

    2. Hi Bjorn. Did you find a solution to your remote Pi data acquisition?

      Xavier suggested (in another post) creating a custom script that would poll for information (in your case, the temperature data) then save that information to a local file. You could then query this local file with RPi-Monitor.

      Anyhow - I'd like to accomplish the same task and was wondering if you have a solution.

  7. Hello,

    the string "/usr/share/rpimonitor/img/" above needs to be "/usr/share/rpimonitor/web/img/" on my RPi-Monitor installation (2.5.1).

  8. Is it possible to show CPU temp as F instead of c?

    1. Yes, it is even very easy.
      You just have to enter the formula converting from C to F as postprocess.
      $1 is the temp in C so formula should be: $1*9/5+32

  9. I found this also, which one is correct?
    To have the temperature in °F, you should change the post-processing formula from $1/1000 to ($1/1000)*1.8+32 into the same file.

  10. Is it possible to make the setup for "other mount point" basically a USB HDD setup but its NTFS i have NTFS setup on my PI and RPi-mon kinda see's it it shows the size but this is what is says "/storage1 Used: NaNkB (NaN%) Free: NaNkB Total: 293.29GB"

    1. Check the formula extracting the space used on disk. It looks that the total is ok. The "used" doesn't looks OK and as free is calculated with the formula "Total"-"Used" you also have the issue.
      Check also that the name of the variable are correct into the static javascript definition (web.status.X.content.Y.line.Z=)

  11. Im sorry, im not that familiar with coding...i have tried many diffrent things, changing this "dynamic.14.source=df -t ext2" to "dynamic.14.source=df -t ntfs" ect... also "dynamic.14.regexp=sda1\s+\d+\s+(\d+)" to "dynamic.14.regexp=*/dev/sda1*\s+\d+\s+(\d+)" */dev/sda1* is where the NTFS drive is mounted.

  12. This is my setup in custo.conf if it helps..
    static.10.source=df -t ntfs
    dynamic.19.source=df -t ntfs

    1. To customize RPi-Monitor, I would advise to read the comment I made in DHT11/22 article ( - September 10, 2013 at 11:34 AM ).
      Before configuring RPi-Monitor, you should first try the regexp with perl and once it works, configure it.

      Note: if the perl execution give you the good information, check if you correctly refer to "storage1_used" into the status lines.

  13. I'm really new to this, im basically taking the example that you show above,(which worked great with ext4 format) and when i changed the drive to ntfs i lost the info, and i have no idea what regexp with perl is, im sorry for the newness, i really really like your system and want to get it to work with my ntfs share drive but i'm just lost beyond the basic config in the given example above about storage drive. Any help would be greatly appreciated.

    1. Not sure if you got it working already but I had the same problem. I figured out how to solve this.

      Check your file system type by using the command "df -T" without the quotes.

      Look up the Type of the drive you want to use. Even though mine is formatted ntfs, it's Type is written as "fuseblk". Therefor I was now able to use the command "df -t fuseblk" and it received the information of the drive.

      Now just change this in your custo.conf or whatever configuration file you are using and it should work fine.

      Hope this helps for you.

  14. I can't get the webserver to work with apache on my Pi. When I try to create the file "rpimonitor" in /etc/apache2/sites-enabled/ with the tekst you provided, I get the message "Access Denied"

    How can I get RPi-Monitor to work with apache?

    1. "Access Denied" is a page given by apache and not related to RPi-Monitor.

      To fix you issue, I would advised to create a page named index.html with, as content, the sentence "It works". Then configure your apache to serve this page. Once it works, you will just have to do a similar configuration pointing to the directory /usr/share/rpimonitor/web/.
      I did my test with nginx so I can't help more...

    2. I know this is an old post, but here is the apache answer:
      sudo ln -s /var/lib/rpimonitor/stat /usr/share/rpimonitor/stat
      sudo nano /etc/apache2/sites-enabled/rpimonitor.conf
      ##### start copy here #######
      Alias /rpimonitor /usr/share/rpimonitor/web

      order deny,allow
      deny from all
      allow from
      #local net only example, change to all for everyone #everywhere
      Options FollowSymLinks
      Require all granted

      ##### end copy here ###########

      Ctrl-O to save
      Ctrl-X to exit

      sudo chmod 744 /etc/apache2/sites-enabled/rpimonitor.conf
      sudo service apache2 restart

      Should work as

  15. Hello,
    I installed the tool and like it very much. Everything works so far and I'm also monitoring my USB-disk, that is attached to the pi. I'm only worried about the additional access to the disk that will be generated by the monitoring. The disk is usually in sleep mode, when it is not actively used by the pi. Does the statistic for the monitor generate real disc access that will wake my disk? It this is the case, I have to disable it again to protect my disk and save energy.


    1. Hello Matthias,

      RPi-Monitor is gathering information on the system every 10 seconds (by default) and write these information into RRD files (generating disk access where RRD file are stored).
      Each time it probes the system RPi-Monitor execute commands (define into the configuration file). These commands may have impact on your system (and maybe wakeup your disk :-( ). This have to be tested...
      If your test show that RPi-Monitor have an impact on your disk, the workaround I would propose to avoid awaking your disk every 10sec is to create an external script gathering information in a frequency matching your needs and writing the result into a file which will be read by RPi-Monitor.


  16. Xavier, Great Monitor! Thank you.

    "Use it with my own Web Server" -

    I now have RPi-Monitor using nginx, but I have an existing site generated in the directory /var/www and my nginx root is /var/www/******, not /usr/share/rpimonitor/web. Below is what I have done, which may help others who can adapt as necessary:

    Assuming you have nginx running existing content at "" or "" locally, for example.
    You want RPi-Monitor to appear at "" or "", for example.

    As Xavier says, first update the configuration file to disable the embedded web server. Edit the file /etc/rpimonitord.conf and uncomment daemon.noserver=1. Then restart RPi-Monitor with the command:

    sudo service rpimonitor restart

    Your existing nginx root folder is held in a configuration file in /etc/nginx/sites-enabled (or in /etc/nginx/conf.d, depending on your setup). In my case I have the line:

    root /var/www/output;

    Do not change this, but instead, make a link in your nginx root folder to /usr/share/rpimonitor/web. But before you do this, permissions need to be set:

    (I had already done the following, since my website files are generated in /var/www)

    My server name is "www-data" which is nginx default.

    WARNING - Never leave a space after a "/" in these commands - you could change the entire file-system owner or permissions, requiring a reinstall of Raspbian!

    1. Add the www-data group to the existing user, pi (pi is the default, unless you changed it):

    sudo usermod -a -G www-data pi

    2. Make sure all files are owned by the www-data group and user:

    sudo chown -R www-data:www-data /var/www

    3. Enable all members of the www-data group to read and write files, and all future files created in this directory to keep the current setup:

    sudo chmod -R g+rws /var/www

    4. Now make the link:

    WARNING - The link folder "monitorweb" must not already exist

    sudo ln -s /usr/share/rpimonitor/web /var/www/output/monitorweb

    This will create the linkfolder "monitorweb" and its contents will be the same as /usr/share/rpimonitor/web.

    Check that it works by browsing to "" or "192.168.*.**/monitorweb". As a final touch, you could add a link to the monitor page on your site.

    1. Thanks for this comment.
      Personnaly, I would not advise to disable the internal web server of RPi-Monitor. Doing such a thing will create some side effects (graph timeline my be blocked).
      I would advise to use a reverse proxy for RPi-Monitor (as I explained into a dedicated article) and also configure nginx to serve other pages if you host another site.

    2. Thanks for your reply.
      I would like to use reverse proxy as you advise - "RPi-Monitor: Security and authentication with a reverse proxy" - is this the article? And can it be applied to Version 2.6/Version 2.7 ?

    3. That's it and it should work for every versions of RPi-Monitor

  17. For NaN issue for storage change dynamic.14 and dynamic.15 for higher numbers and this will solve an issue.

  18. Hallo Xavier,
    yesterday i installed you're great monitoring tool.
    Works like a charm. Thanks.

    I found a dallas temp sensor in my electronic box.
    i could connect it successfully to my PI.

    I attached my temperature.conf, maybe someone can use it.

    Sometimes i set some spikes in the temp graph,
    maybe i change the datasource and check this line inside w1_slave:
    c5 01 4b 46 7f ff 0b 10 16 : crc=16 YES

    maybe i can do this with regex, i have to google howto...


    # Extract CPU Temperature information
    # Page: 1
    # Information Status Statistics
    # - cpu temperature - yes - yes

    web.status.1.content.4.line.1=JustGageBar("CPU", "°C",0, data.soc_temp , 100,100,80,percentColors,50,60)+" "+JustGageBar("Schrank", "°C",0, data.serverschrank , 100,100,80,percentColors,35,45)
    web.statistics.1.content.8.ds_graph_options.soc_temp.label=Core temperature (°C)

    web.statistics.1.content.8.ds_graph_options.serverschrank.label=Serverschrank temperature (deg C)

  19. I could solve my "Spikes in Temp Graph" Problem.
    Instead of Parasitic Mode(2Wire) i connect all pins(3) of the Sensors.

    One Question:
    When i open rpi-monitor with my mobile Phone a Mobile Version is shown.
    In the top Line i seee:
    Raspberry Symbol, "RPI-Monitor", (hostname) and at the right side the Menu Button.

    So i have always to scroll from left to right.
    Can i place the Menu Button to the left Side?

    I the Configuration Files i did not find that Option.

    Thanks in advance,

  20. It there any work being done to allow plotting of local or external MQTT data??


  21. Anoyther Customized Service Monitor

    1. Nice Idea using a table to format the statistics.
      Thanks for sharing.

    2. Great work! I love the layout, it's super easy to edit!