munin: draw thin lines in the graphs

Which is a bit more clear if the values are fluctuating a lot.
Refactor munin module to improve code readability

- get rid of the fancy function-dictionary
- extract get_stats function
- move all output to the actual print functions
More refactoring of munin module to improve code readability
munin: graph total amount of JVM threads

...because Jetty is not the only component that uses threads. This
information is interesting in combination with the JVM memory usage,
which is the next new plugin to build.
Use json instead of pprint for some raw output

It's a bit prettier and more readable.
Code cosmetics in munin module...

Use multiple print statements for readability.
Correctly show unused heap memory in JVM memory graph

Also see:
https://mxforum.mendix.com/questions/7030/Java-Memory-Monitor-Questions

Previous behaviour of this graph:
"The 'allocated memory' is simply the sum of all memory parts that are
in use right now. The 'max memory' is actually the sum of the max jvm
heap size and the max allowed permanent generation size. If you're
familiar with the startup parameters of the JVM: it's the -Xmx plus the
-XX:MaxPermSize. Those are two separate limits, which causes max memory
not to be reached in the graph when only one of the two reaches its
limit. So yes, the max memory limit, which is actually two different
limits added together may be a bit misleading here."

So, that max line does not really mean something useful. Let's remove it!

The unused amount of memory was also not being calculated correctly, or
at least misleading, because the committed but unused non-heap memory
was part of it. The graph shows the unused memory on top of the eden,
survivor and tenured parts of the heap, so the user will expect to see
the unused heap memory here.

By using max_heap instead of committed_heap to calculate the unused heap
space, the effect of setting -Xms to a lower value than -Xmx will not be
visible in the graph anymore, so no separate committed / max lines are
needed any more. It's best practice to set initial heap to max heap
anyway, and there's not much use in complicating this graph with that
information. The heap is supposed to be able to grow to the max in any
case.
Say hello to the smaps analyzer!

Based on the contents of /prod/<pid>/smaps, which is available on Linux,
we can make an educated guess about the contents of the process memory
of a JVM process, and tetris all little memory chunks into categories to
count the resident memory usage per category.

The m2ee munin plugin has been providing data to draw a graph about the
JVM memory usage for a long time. This graph gives insight in the
internals of the jvm heap generations, but it does not show memory usage
for the complete JVM process.

This code makes a few assumptions about how the world it's looking at is
organized:
 - Thread stack size is 1024kB, the default for 64bit linux. (or,
   actually 1016 kB and a 12 kB guard page).
 - The initial (-Xms) and maximum (-Xmx) JVM heap parameters have an
   identical value (so the heap memory block is directly fully
   allocated, as one big chunk). An committed_heap input parameter (in
   kB) is used to try to match a piece of memory that matches the
   committed_heap as best as possible.
 - No swap space is used (only resident memory is counted).

And a lot of reverse engineering-style educated guessing is going on
here!

Tested with Oracle JRE 6 and 7 on Linux 2.6.32, 3.2 and 3.16 so far...

This module is not integrated yet with the munin plugin. It can be
tested in a 'stand-alone' way by executing it and providing a pid and a
amount of kB for jvm committed heap memory that can be retrieved by
running statistics at the m2ee prompt.

E.g. python smaps.py 21429 251904
Merge branch 'develop' into jvmgraphs
Integrate smaps into munin plugin
munin: also plot total JVM process memory usage
Try to find the Java Heap first of all...

...before considering 'normal' X * 64MB blocks.

Also, increase fuzziness about the size of the memory chunk that holds
the Java Heap. 5% is not always enough, testing shows.
f9ad11f says... "By using max_heap instead of committed_heap"

So actually also do that! D'oh!
Remove permanent and code cache from heap graph

They're not part of the Java Heap and will be made visible again in the
total JVM memory usage graph.
Still too much false negatives here...

The memory block is 131584 kB
statistics shows committed 106496 kB and max 117248 kB

So, the max reported from inside the JVM is not really the max as set
with -Xmx.... It would be better to be able to access the Xmx setting in
this plugin. Sadly, this setting has always been used in the list of jvm
parameters, instead of a separate memory setting that could be used for
Xmx and Xms. Option 1: parse it back from the jvmopts list... Option 2:
change m2ee-tools to use a memory option instead. Creating option 2
would still not eliminate the need to have option 1 backwards compatible
for a long time......
Prevent graph from disappearing when app not running

When /proc/self/smaps can be read, then we can assume this funtionality
is present and that it's also possible to use it for the JVM process,
when it's running.
JVM memory graph: show Java Heap internals and PermGen

This makes the graph even more fun and educational!
Print upper limit value in Java Heap graph
Merge branch 'jvmgraphs' into develop