#!/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. # # If you improve this script please send your version to my email address # with the copyright notice upgrade with your name. # # Plugin to monitor size amount of backups with bacckuppc tool # ###### # Downloaded by Peter Palfrader, 2006-05-15 # from http://rodolphe.quiedeville.org/hack/munin/backuppc/backuppc # # $Log$ # Revision 1.2 2006/04/27 11:33:19 rodo # Bugfix in variable definition # # Revision 1.1 2006/03/09 14:12:19 rodo # Created by Rodolphe Quiedeville # # Parameters: # # autoconf (optional - used by munin-config) # # Magic markers (optinal - used by munin-config and some installation # scripts): # #%# family=backuppc #%# capabilities=autoconf use strict; my $pcdir = "/var/lib/backuppc/pc"; if($ARGV[0] and $ARGV[0] eq "autoconf" ) { if(-d $pcdir) { if(-r $pcdir) { print "yes\n"; exit 0; } else { print "no (logfile not readable)\n"; } } else { print "no (logfile not found)\n"; } exit 1; } if ($ARGV[0] and $ARGV[0] eq "config" ){ print "graph_title Backuppc\n"; print "graph_args --base 1024 -l 0\n"; print "graph_scale yes\n"; print "graph_category Backuppc\n"; print 'graph_info Plugin available at http://rodolphe.quiedeville.org/hack/munin/'."\n"; opendir(PCD, $pcdir) || die "Can't open $pcdir: $!"; while (my $file = readdir(PCD)) { if ($file ne '..' && $file ne '.') { my @o = (split '\.', $file); print $o[0].".label ".$o[0]."\n"; print $o[0].".info $file\n"; } } closedir(PCD); exit 0; } opendir(PCD, $pcdir) || die "Can't open $pcdir: $!"; my ($file,$size,@o) = (0,0,0); while (defined ($file = readdir(PCD))) { $size=0; if ($file ne '..' && $file ne '.') { @o = (split '\.', $file); open(FLOG, $pcdir.'/'.$file.'/LOG') or exit 4; while () { $size = $1 if (/.*full backup [0-9]+ complete, [0-9]+ files, ([0-9]+) bytes,.*/); } close(FLOG); print $o[0].".value ".$size."\n"; } } closedir(PCD);