#!/usr/bin/perl -w # # Copyright (C) 2006 Rodolphe Quiedeville # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; version 2 dated June, # 1991. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # $Log$ # Revision 1.0 2006/04/30 18:17:19 rodo # Created by Rodolphe Quiedeville # # Warning this plugin need to patch munin-html, you'll find patch at : # http://rodolphe.quiedeville.org/hack/munin/patches/ # # Need to be run as root, add the following lines ... # # [munstat] # user root # # to /etc/munin/plugin-conf.d/munin-node # # # Magic markers (optinal - used by munin-config and some installation # scripts): # #%# family=auto #%# capabilities=autoconf use strict; my $log; my @logs = ("update","graph","html","limits"); foreach $log (@logs) { my $update = "/var/log/munin/munin-$log.log"; (-r $update) || die "Can't read $update\n"; } if ($ARGV[0] and $ARGV[0] eq "config" ){ print "graph_title Munin time spent\n"; print "graph_args --base 1000 -l 0\n"; print "graph_scale yes\n"; print "graph_vlabel seconds\n"; print "graph_category munin\n"; print 'graph_info Plugin available at http://rodolphe.quiedeville.org/hack/munin/munin/'."\n"; my $num =0; foreach $log (@logs) { print("$log.label munin-$log\n"); ($num > 0) ? print("$log.draw STACK\n") : print("$log.draw AREA\n"); $num++; } exit 0; } foreach $log (@logs) { my $update = "/var/log/munin/munin-$log.log"; open(STA, "grep finished $update | tail -1 |") or exit 4; while () { my ($time) = (/.*\((\d+\.\d+)\ssec\)$/); ($time) ? print "$log.value $time\n" : print "$log.value 0\n"; } close(STA); }