Wednesday, July 21, 2010

Aggregate Munin Data on a Single Graph

It is sometimes useful to compare data coming from several nodes; if you have a cluster of 5 load balanced HTTP servers, it can be interesting to have the curves for the load of all 5 servers on a single graph, to check if the load balancer is properly configured. You could also put on the same graph the load of your fileserver, and the CPU time spent on "i/o wait" on a server accessing it, to study the correlation between both values.

Let's take the example with the 5 HTTP servers. First, we create a new virtual node:

[domain;Comparisons]
  update no # Turn off data-fetching for this "host".

Then we create our new graph:

apaches_load.graph_title Loads of our HTTP servers
# Use domain;server1 or server1.domain, depending on the notation you use
apaches_load.graph_order server1=domain;server1:load.load server2=domain;server2:load.load server3=domain;server3:load.load server4=domain;server4:load.load server5=domain;server5:load.load
apaches_load.category Apache

After the next run of munin-cron, your new graph should be available.

A little more complex example now. I have 3 plugins collecting the number of users on a forum; the first plugin collects the number of guests, hidden users and online registered users on a forum . The second plugin collects the number of guests and registered users on a second forum, and the third the number of guests, hidden users and online registered users on a third forum.

The idea is to aggregate all these users on a single graph; I want one stack for each forum, so for each plugin we will have to sum guests, hidden users and registered users. Drops in the following graph are due to timeouts of one of the plugins due to heavy load on the host:



This is made with the following configuration, in munin.conf, in the node you want to put the graph in:

forum_sum.graph_title Active users on the forums we host

forum_sum.users_fr.sum Misc;Forums:forum_users_fr.members Misc;Forums:forum_users_fr.guests
forum_sum.users_fr.draw STACK
forum_sum.users_fr.label Users on Forum1

forum_sum.users_de.sum Misc;Forums:forum_users_de.members Misc;Forums:forum_users_de.hidden Misc;Forums:forum_users_de.guests
forum_sum.users_de.draw STACK
forum_sum.users_de.label Users on Forum2

forum_sum.users_ru.sum Misc;Forums:forum_users_ru.members Misc;Forums:forum_users_ru.hidden Misc;Forums:forum_users_ru.guests
forum_sum.users_ru.draw STACK
forum_sum.users_ru.label Users on Forum3

Misc is the domain, Forums the name of the node. forum_sum is the name of the virtual plugin we create; users_fr, users_de and users_ru the name of the different fields for that plugin. forum_users_* are the names of the plugins fetching data from the forums.

No comments:

Post a Comment