Personal Workflow Blog

To content | To menu | To search

Sunday, 19 January 2014

How to try Munin 2.1.x easily in Debian-derivatives

In my previous post I explained how to setup a simple development environment, but I feel that's a little too much if you only want to try that new, shiny, munin version.

So, let's assume that you're on a debian-derivative distribution (Ubuntu, Raspbian, ... , and of course Debian).

The nicest news is that 2.1.x already hit the experimental part of Debian. That makes it very easy to use as everything is described there.

I'll just copy/paste some instructions tailored for munin, please refer to the original page if you'd like to learn more.

Add experimental to your sources.list

echo "deb http://ftp.debian.org/debian experimental main" >> /etc/apt/sources.list

Update the apt database

apt-update

Install the experimental version of munin

apt-get -t experimental install munin

Pin the munin as the experimental version

That works quite well, but the munin package won't be updated, as the automatic upgrades only comes from the non-experimental part. And obviously the version there is lower than the experimental one.

So, that is called package pinning, that is to pin a certain package in a certain repository. It is still very simple to do :

cat >> /etc/apt/preferences <<EOF
Package: munin
Pin: release a=experimental
Pin-Priority: 800
EOF

Conclusion

So, that's it. You have successfully upgraded to the unstable side of munin...

Wednesday, 15 January 2014

Tutorial - Setup a dev environment for Munin

I discovered some time ago the marvelous dev_scripts/ directory in the munin source code. So, as its usage is very easy, I'll just write a tutorial about how to use it

Prerequisites

To use it, one has to install all the packages needed for munin, and to grab a copy of the source code. Easiest is to use either a tarball, or to clone the git repository.

Note that the guidelines on contributing back are specified directly in the git repo.

Now, I just assume you want to contribute back, otherwise you would not care much about the said dev environment. That means using the git way of doing it.

Download the source code

First step is to clone the git repository. We will use $HOME/src/munin as the development directory.

mkdir -p $HOME/src
cd $HOME/src
git clone https://github.com/munin-monitoring/munin munin
cd munin

Compile munin

Now, we have to compile the source code. I know that it sounds strange as the code is mostly Perl, but there are some templates that need to be filled with the environment specifics, such as the Perl interpreter path, a POSIX compatible shell, ...

dev_scripts/install 1

Now all munin (and munin-node) should be compiled and installed in $HOME/src/munin/sandbox.

Note that the 1 at the end is explained below.

Using the dev tools

There are some different tools in dev_scripts/ :

install

This is the one you used already. You have to use it every time you want to recompile & deploy the package.

The 1 argument, does a full re-install (wipe & install), so you don't usually want to do that.

restart_munin-node

This is a tool to start the development node. Note that it listens on the port 4948, so you can use it alongside a normal munin-node.

run

The run command inside is used to launch all the executable parts of munin, such as munin-update, munin-html or munin-limits. It can also be used to launch munin-run and munin-node-configure.

The usage is very simple, just prefix the command to launch with dev_scripts/run, every environment variable and command line argument will be forwarded to the said command.

# launch munin-cron
dev_scripts/munin-cron

# launch manually some cron parts
dev_scripts/munin-update
dev_scripts/munin-limits
dev_scripts/munin-html
dev_scripts/munin-graph

# debug a plugin
dev_scripts/munin-run --debug cpu config

cgi

This is the same as run, only for CGI. It sets up the whole environment vars that emulates a CGI call. Usage is very easy :

dev_scripts/cgi munin-cgi-graph /localnet/localhost/cpu-day.png > out.dat

The out.dat will contain the whole HTTP output, with the HTTP headers and the PNG content. Everything that is sent to STDERR won't be catched, so you can liberally use it while debugging.

query_munin_node

The query_munin_node is used to send commands to the node in a very simple way. Node commands are just args of the tool.

dev_scripts/query_munin_node list
dev_scripts/query_munin_node config cpu
dev_scripts/query_munin_node fetch cpu

Real CGI usage with your web browser

That's the holy grail. You will have a development version that behaves the same as a real munin install.

First, let's assume you have a working user cgi configuration (ie ~user/cgi/whatever is working). If not you should refer yourself to the local documentation of your preferred webserver. Note that nginx will _not_ work, as it does not support CGI.

I wrote a very simple cgi wrapper script. The home dir is hard coded in the script.

#! /bin/sh

ROOT=/home/me/src/munin
eval "$(perl -V:version)"

PERL5LIB=$ROOT/sandbox/usr/local/share/perl/$version
#export DBI_TRACE=2=/tmp/dbitrace.log

exec perl -T -I $PERL5LIB $ROOT/sandbox/opt/munin/www/cgi/$CGI_NAME

Monday, 2 December 2013

Experimenting with a C munin node

Core plugins are designed for simplicity...

As I wrote about it earlier, Helmut rewrote some core plugins in C. It was maintly done with efficiency in mind.

As those plugins are only parsing one /proc file, there seemed no need to endure the many forks inherent with even trivial shell programming. It also acknowledges the fact that the measuring system shall be as light as possible

Munin plugin are highly driven towards simplicity. Therefore having shell plugins is quite logical. It conveys the educational sample purpose for users to write their own, while being quite easy to code/debug for the developpers. Since their impact on current systems is very small, there are not much incentive to change.

... but efficiency is coming !

Nonetheless, now monitored systems are becoming quite small.

It is mostly thanks to embedded systems like the RaspberryPi. This means that processing power available is much lower than on normal nodes[1].

Now the embedded C approach for plugins has a new rationale.

Notes

[1] Usually datacenter nodes are more in the high end of the spectrum than the low-end.

Saturday, 13 April 2013

Spinoffs in the munin ecosystem

KISS is the core design of Munin

Munin's greatest strength is its very KISS architecture. It therefore gets many things right, such as a huge modularity.

Each component (master/node/plugin) has a simple API to communicate with the others.

Spin-offs ...

I admit that the master, even the node, have convoluted code. In fact some rewrites already do exist.

... are welcomed ...

And they are a really good thing, as it enables rapid prototyping on things that the stock munin has (currently) trouble to do.

The stock munin is a piece of software that many depend upon, so it has to move at a much slower pace than one does want, even me. As much as I really want to add many many features to it, I still have to take extra care that it doesn't break stuff, even the least known features.

So I take munin off-springs very seriously and even offer as much help as I can in order for them to succeed.

... because they are very valuable in the long term

In my opinion competition is only short bad in the short term, and in the long term they usually add significant value to the whole ecosystem. That said, there's always a risk to become slowly irrelevant, but I think that's the real power of open-source's evolutionary paradigm : embrace them or become obsolete and get replaced.

Since, if someone takes the time to author a competitor that has a real threat potential, it mostly means that there's a real itch to scratch and that many things are to be learnt.

Different layers of spin-offs

The munin ecosystem is divided in 3 main categories, obviously related to the 3 main components of munin : master, node & plugin.

Plugins

That's the most obvious part as custom plugins are the real bread and butter of munin.

Stock plugins are mostly written in Perl or POSIX shell, as Perl is munin's own language and POSIX shell is ubiquitous. That fact is acknowledged by the fact that core munin provides 2 libraries (Perl & Shell) to help plugin authoring.

So, it's quite natural that each mainstream language has grown its own plugin library. Some language even have two of them.

C

Some plugins got even rewritten in plain C, as it was shown that shell plugins do have a significant impact on very under-powered nodes, such as embedded routers.

Node

This component is very simple. Yet, it has to be run on all the nodes that one wants to monitor. It is currently written in Perl, and while that's not an issue on UNIX-like systems, it can be quite problematic on embedded ones

Simple munin

The official package comes with a POSIX shell rewrite that has to be run from inetd. It is quite useful for embedded routers like OpenWRT, but still suffers from an hard dep on POSIX shell and inetd.

SNMP

SNMP is another way to monitor nodes. While it works really well, it mostly suffers the fact that its configuration is quite different of the usual way, so I guess some things will change on that side.

Win32 ports

Win32 has long been a very difficult OS to monitor, as it doesn't offer much of the UNIX-esque features. Yet the number of win32 nodes that one wants to monitor is quite high, as it makes munin one the few systems that can easily monitor heterogeneous systems.

Therefore, while you can install the stock munin-node, several projects emerged. We decided to adopt munin-node-win32.

Android

There's also a dedicated node for Android. It makes sense, given that the Android is yet Linux-derived, but lacks Perl, and is a Java mostly platform. This node also has some basic capabilities of pushing data to the master instead of the usual polling.

This is specially interesting given the fact that Android nodes are usually loosely connected, so the node spools values itself and pushes them when it recovers connectivity.

Note that this is specifically an aspect that is currently lacking in munin, and I'm planning to address it in the 2.1 series. So thanks to its author for showing a relevant use-case.

C

That's my last experiment. It started with a simple question : how difficult would it be to code a fairly portable version of the node ?

It turned out that it wasn't that difficult. I'm even asking myself about eventually replacing the win32 specific port with this one, as the code is much simpler. The win32 node has several plugin built-in mostly due to platform specifics. I still have to find a way to work my way around it, but it's in quite good shape.

This post was originally done to promote it, but while writing it I noticed that the ecosystem deserved a post on its own. So I'll write another one, specific to the C port of munin-node and plugins.

Master

The master is the most complex component. So rewrites of it won't happen as-is. They usually take the form of a bridge between the munin protocol and another graphing system, such as Graphite.

Clients

There are also client libraries that are able to directly query munin nodes, to be able to reuse the vast ecosystem. Languages are various, from the obvious Python to Ruby, along with a quite modern node.js one.

Thursday, 4 April 2013

Do not fear git rebase : make snapshots !

Git is a nice version system, but some commands are destructrive, such as rebase.

Here is a script to have a safety net, and free backups !

#! /bin/sh
# Script to snaphot a git repo
SNAP_VERSION=$(date +%s)
BUNDLE_NAME=$(basename $( pwd )).${SNAP_VERSION}.git.bundle
git bundle create ../${BUNDLE_NAME} --all
git remote add snap-${SNAP_VERSION} ../${BUNDLE_NAME}
git fetch -p snap-${SNAP_VERSION}

Usage is very easy. If you want to restore your current branch to the master one you made earlier.

git reset --hard snap-1365068411/master

- page 1 of 12