Thursday, October 23, 2014

Using rrdcached with Observium

rrdcached is a daemon that receives updates to existing RRD files, accumulates them and, if enough have been received or a defined time has passed, writes the updates to the RRD file.
This can be very useful in a bigger Observium-instance as the number of polled interfaces grow and the number of RRD-files that will be updated each polling is increasing, soon each polling will be generating a lot of random writes to your storage.
rrdcached gives us the possibility to trade some of that IO for memory. This is can be very good deal for virtual machines or any server with a slower storage but a fair amount of memory.

This small guide is written and tested on Ubuntu Linux and I cant guarantee that it will work on any other distro.

1. Start by installing rrdcached using your favorite packet manager
#  sudo apt-get update && sudo apt-get install rrdcached

2. The rrdcached daemon will be started automatically so we need to stop it.
# sudo service rrdcached stop
Stopping RRDtool data caching daemon: rrdcached.

3. Edit the start up options for the rrdcached daemon
# sudo nano /etc/default/rrdcached

Find the row in the configfile with #OPTS= and replace them with these options:
OPTS="-w 1800 -z 1800 -f 3600 -s www-data -l unix:/var/run/rrdcached.sock -j /var/lib/rrdcached/journal/ -F -b /opt/observium/rrd/ -B"
Dont forget to remove the bracket!

The values used here defines the following:

  • -w 1800 Wait 1800s (30min) before writing data
  • -z 1800 Delay writes by a random factor of up to 30 minutes (this should be equal to, or lower than, “-w”)
  • -f 3600 Flush all data every 3600s (1 hour)
  • -s set the group owner of the socket to www-data (this needs to be set before -l)
  • -l path to our socket that observium will talk to
  • -j path to journaling files
  • -F ALWAYS flush all updates to the RRD data files when the daemon is shut down
  • -b path to observium RRD-files
  • -B Only permit writes into the base directory specified in -b (and any sub-directories).
4. Now start rrdcached daemon again
# sudo service rrdcached start
5.  Now here comes the big problem, as rrdached is started as root it will create the socket-file (/var/run/rrdcached.sock) with root permissions. But the webserver user need to be able to both read and write to this socket so we will need to change the owner to the webserver user (www-data in this case)
# sudo chown www-data:www-data /var/run/rrdcached.sock
This needs to be redone every time rrdcached is restarted as it will then recreate this file.
This probably can be solved by manipulating the init-script or some other cleaver way, suggestions are highly appreciated! There are also flags in rrdcached for this (-m and -s) but I never got it to work, file owner was always root.
*NOTE* Step 5 no longer needed when using -s flag properly!

6. Last step, edit the observium config.php to use our rrdcached socket instead of writing RRDs directly.
# sudo nano /opt/observium/config.php
Then add this line to the config
 $config['rrdcached']    = "unix:/var/run/rrdcached.sock";
Save and exit! Now log in to Observium, your graphs should look as they use to. If you have a pretty big instance you should soon notice that the storage IO has decreased by a lot.

If all your graphs show "draw error" then you webserver user probably dont have read and write-access to /var/run/rrdcached.sock

This is the IO of my observium-machine after installing rrdcached:


if you are using the php-weathermap with Observium then you will also need to edit the weathermap file to inclued:
putenv ("RRDCACHED_ADDRESS=/var/run/rrdcached.sock");

Tuesday, July 15, 2014

Using PHP Weathermap with Observium

The PHP Weathermap plugin is a very popular tool for mapping the link load of a network environment. It is usually used as a plugin to Cacti or MRTG but as Observium is gaining popularity I decided to make a quick guide for how you get the weathermap nicely integrated with Observium in a way that does not break when updating to newer versions of Observium.

This guide assumes that you have a working installation of Observium already, preferably a installation that was done using the Debian/Ubuntu-guide.

1. Download the modified version of PHP Weathermap done by Neil Lathwood ( from his github: and put it in your observium/html-directory.
The easiest way to do this is using git:
cd /opt/observium/html/
git clone weathermap
2. If you have used different paths for observium or the weathermap-plugin you will need to edit the variables in data-pick.php and map-poller.php, if you are following the installation guide then the default variables will work.

3. open the file editor.php and change the value in the beginning to:
As long as this value is true everyone who knows the right URL will be able to access the weathermap editor, its therefore recommended to change this value back to false as soon as you are done editing.

4. Make sure the directory configs/ is writable by your webserver, one way is to change to owner of the directory to the webserver-user: (in Ubuntu the webserver user is usually called www-data)
cd weathermap/
chown www-data:www-data configs/
5. Create a new directory called maps/ and make the webserver-user the owner
mkdir maps/
chown www-data:www-data maps/
6. Now use your webbrowser and access the editor in weathermap/editor.php (i.e. surf to

7. Create a new map by writing a name and click create map. Note that the map name *must* end with .conf (i.e. networkmap.conf)
Edit your map, create nodes and draw links and then pick graphs from Observium to use with the links.
*NOTE* Under Map Properties, make sure to define Output HTML Filename to maps/<mapname>.html and Output Image Filename to <mapname>.png

8. Make the file map-poller.php executable for your system by doing:
chmod +x map-poller.php
9. Add a new line in the cronjob at /etc/cron.d/observium after the Observium polling and discovery:
*/5 * * * * root /opt/observium/html/weathermap/map-poller.php >> /dev/null 2>&1
10. Move the file in the observium/html/includes/-directory. This file does not exist by default in Observium but Observium looks for this file and include the code from it if it exists, this makes it possible to add custom menus that does not break when you upgrade you Observium installation.
mv /opt/observium/html/includes/
 If you are using the current community edition (based on revision 5229) or any revision older than 5670 you should instead use the file and rename it.

Now that's it!
All .html-files in the maps/-directory will be linked in a sub menu in the Observium GUI like this:

Clicking on one of them will take you to the rendered weathermap where you will get a nice overview of your networks load.
Hovering the mouse over a link will show the Observium graph for that link like this:

And clicking on a link will take you to the Observium-page for that link.

Hope this guide has been helpful for you and thank you for reading!