Munin graphing by CGI
According to Jimmy who wrote this:
This is more a proof of concept than a recommended - it's slow. Also we do not test it before every release. There is a fastcgi version too which is explained at the end of this page. But you must do everything on this first check-list before you try that.
- munin-cgi-graph must be installed. This is included in the munin package in Debian and available in FreeBSD, too. On Debian, libdate-manip-perl is also required to graph by CGI (it is only recommeded by the munin package).
- munin-html must generate references to the cgi: In munin.conf set
graph_strategy cgi
- The default relative URL for munin-cgi-graph is /cgi-bin/munin-cgi-graph this can be overridden in munin.conf with the cgiurl_graph keyword.
- Apache must be able to find and execute munin-cgi-graph at the given path - if it does not take a look at http://munin.projects.linpro.no/browser/trunk/resources/apache-cgi.conf.in
- Remove munin-graph from munin-cron (hum, this should be superflous, it should disable itself as needed)
- munin-cgi-graph should be able to write to the log file and graphics files. Assuming that your web server runs as the group 'www-data' and your file paths are the same as mine:
chgrp www-data /usr/share/munin/munin-graph chgrp www-data /var/log/munin /var/log/munin/munin-graph.log chmod g+w /var/log/munin /var/log/munin/munin-graph.log chgrp -R www-data /var/www/munin/yourdomain chmod -R g+w /var/www/munin/yourdomain
- Depending on how log rotation for munin-graph.log is set up on your system, you may also need to modify group ownership and access permissions that a new log is created with upon rotation. (Otherwise the changes you made in the previous step would be reverted during the next logrotate.) On e.g. a Debian system, in /etc/logrotate.d/munin:
# change this: /var/log/munin/munin-graph.log { daily missingok rotate 7 compress notifempty create 640 munin adm # !!! } # to this: /var/log/munin/munin-graph.log { # [...] create 660 munin www-data # !!! }
After all that and the next run of munin-html you've switched to cgi graphing. In case there are any problems you should watch your apache error log, and the munin-graph.log.
If you have munin 1.3.3 or later (r1217 is in 1.3.3, r1323 is in 1.3.4) you can tune how many concurent rrdgraph instances you allow. This can avoid I/O and memory thrashing effects and speed up the redraws when using cgi graphs. This is done in (/etc/munin/)munin.conf with the max_cgi_graph_jobs parameter.
FastCGI
The patches refered to below are (will be) in munin-fastcgi-graph in 1.4.0. The Apache configuration is still needed. And you need to do everything described above too.
- Install CGI::Fast, on Debian/Ubuntu it's in libcgi-fast-perl.
- If you do not have 1.4: Apply the patch from http://munin.projects.linpro.no/ticket/3.
- If you have 1.4: set cgiurl_graph so that the program name is "munin-fastcgi-graph"
- To make the Apache/mod_fastcgi handle the CGI program, add the SetHandler? directive to your "cgi-bin" directory, e.g.
<Location /cgi-bin/munin-cgi-graph> SetHandler fastcgi-script </Location>
- Make sure munin-html has run once to change the URLs to use CGI graphs.
- Enjoy the speed improvement! :)
Configure lighttpd for munin-cgi-graph (fastcgi)
# munin fastcgi (Needs patch from http://munin.projects.linpro.no/ticket/3)
server.modules += ( "mod_fastcgi" )
fastcgi.server = ("/cgi-bin/munin-cgi-graph" =>
("munin" =>
("socket" => "/tmp/munin-fastcgi.sock",
"bin-path" => "/usr/lib/cgi-bin/munin-cgi-graph",
"check-local" => "disable",
)
)
)
Notes
- After switching to "graph_strategy cgi" I had to manually create the directory "tld" in munins htdocs directory. I had moved it to another place, so the old structure was not there.
- It was "quite adventurous" to set this all up in my Apache chroot..
- You also want to apply the patch/fix from #480, if the image sizes are calculated incorrectly. This patch is in 1.4.0.
