summaryrefslogtreecommitdiff
path: root/munin/backuppc
blob: c7e7e9dd74735fc3287891e02a546644d666ecd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/perl -w
#
# Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
#
# 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 <a href="http://rodolphe.quiedeville.org/hack/munin/">http://rodolphe.quiedeville.org/hack/munin/</a>'."\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 (<FLOG>)
	{
	    $size = $1 if (/.*full backup [0-9]+ complete, [0-9]+ files, ([0-9]+) bytes,.*/);
	}
	close(FLOG);

	print $o[0].".value ".$size."\n";
    }
}
closedir(PCD);