munin-cgi-graph with fastcgi on debian etch

We use munin a lot. Consequently munin-graph takes up more than 5 minutes every time, breaking munin-cron, and loosing data. Since we graph a lot more data than we normally look at, because most of it only matters when we’re planning something or when something breaks, we don’t need new graphs every five minutes. So I switched munin-graph to use munin-cgi-graph. The basic instructions are in the munin CgiHowto. It’s pretty easy.

But each node page has a lot of graphs, so it’s annoying to wait for them all to get created. FastCGI helps, so I went about setting that up too.

First, package ‘libapache2-mod-fastcgi’ is in non-free, so you may not find it. I started using ‘libapache2-mod-fcgid’ for a bit, but since I was having trouble, downloaded the fastcgi package from non-free and added it to the local repository. munin-cgi-graph is in /usr/lib/cgi-bin on debian so I added this to my apache config:

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory /usr/lib/cgi-bin/>
AllowOverride None
SetHandler fastcgi-script
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
<Location /cgi-bin/munin-cgi-graph>
SetHandler  fastcgi-script
</Location>

I had munin-cgi-graph working if I removed the SetHandler line, but when I left it, I’d get a lot of errors and no graphs like:

FastCGI: incomplete headers (0 bytes) received from server

[error] [client 10.0.0.60] Premature end of script headers: munin-cgi-graph

Warning: Request for graph without specifying domain. Bailing out.

I had to apply a diff to mod-cgi-graph for fastcgi support. For whatever reason I skipped this, perhaps assuming it had gotten into the deb already. Download the diff to your home directory then apply it.

cd /usr/lib/cgi-bin/
cp munin-cgi-graph munin-cgi-graph.in
patch -p0 munin-cgi-graph.in ~/munin-cgi-graph_fastcgi.diff
mv munin-cgi-graph munin-cgi-graph.orig
cp munin-cgi-graph.in munin-cgi-graph

6 thoughts on “munin-cgi-graph with fastcgi on debian etch

  1. Reti

    Hi,

    thank you for your post. I am getting the following error on patching the munin-cgi-graph file:

    patch: **** Only garbage was found in the patch input

    This normally means that the diff file is corrupted or something else.

    Did somebody experience the same problem ?

    Thank You

  2. btm Post author

    @Reti,

    Take a look at the patch file. You’ll need to be sure you’re saving the raw output with no HTML from that page. It should start like this:

    --- /usr/lib/cgi-bin/munin-cgi-graph	2006-12-08 18:18:51.000000000 +0100
    +++ /usr/lib/cgi-bin/munin-cgi-graph-fastcgi	2007-06-14 01:02:15.000000000 +0200
    @@ -40,6 +40,7 @@
     use IO::Handle;
     use Date::Manip;
     use POSIX qw(strftime);
    +use CGI::Fast;
     
     my $GRAPHER = "/usr/share/munin/munin-graph";
     my $conffile = "/etc/munin/munin.conf";
    

    If it doesn’t, you’ll want to make sure you’re downloading the diff like:

    wget http://munin.projects.linpro.no/attachment/ticket/3/munin-cgi-graph_fastcgi.diff?format=raw -O munin-cgi-graph_fastcgi.diff
  3. Reti

    @btm

    Thank You that was the problem. The diff file was in a html format 🙂

    But now I get on my nagios “website” = Invalid parameters! when i try to open http://www.mydomain.com/cgi-bin/munin-cgi-graph and in the apache2 error logs I get:

    Use of uninitialized value in split at /usr/lib/cgi-bin/munin-cgi-graph line 77.
    Warning: Request for graph without specifying domain. Bailing out.

    I also tried to remove the “SetHandler” line but without success 🙁

    It is Debian 4.0 Etch System.

    Perhaps you also know how to handle that 😀

  4. btm Post author

    @Reti,

    Sorry, I just saw that error before I patched munin-cgi-graph. Perhaps ensure that the version of munin-cgi-graph in /usr/lib/cgi-bin is indeed the version that you’ve patched.

    /usr/lib/cgi-bin$ md5sum *
    89a05267a8dd74b74661a93160828bfd  munin-cgi-graph
    89a05267a8dd74b74661a93160828bfd  munin-cgi-graph.in
    40f739d746ecd0a06defa2d861058601  munin-cgi-graph.orig
    

    It looks like around line 80 of the patched munin-cgi-graph is where you would get that error if you’re not passing all the data.

    Are your image links something like:
    https://munin/cgi-bin/munin-cgi-graph/prod.example.org/server.prod.example.org/apache_processes-day.png ?

    More specifically, did you add ‘graph_strategy cgi’ to your munin.conf and has munin-html rerun to update all of the links as discussed in step #2 of the cgi howto?

  5. Pingback: Replacing munin with ganglia at btm.geek

  6. Pingback: munin-cgi-graph with fcgid on ubuntu lucid « btm.geek

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.