#!/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 13:51:19 rodo # Created by Rodolphe Quiedeville # # # Magic markers (optinal - used by munin-config and some installation # scripts): # #%# family=debian #%# capabilities=autoconf use strict; my $CCACHE = exists $ENV{'ccache'} ? $ENV{'ccache'} : "/var/lib/dpkg/status"; (-r $CCACHE) || die "Can't read $CCACHE\n"; my %WANTED = (); if ($ARGV[0] and $ARGV[0] eq "config" ){ print "graph_title Packages size\n"; print "graph_args --base 1024 -l 0\n"; print "graph_scale yes\n"; print "graph_vlabel bytes\n"; print "graph_category debian\n"; print "graph_total Total\n"; print 'graph_info Plugin available at http://rodolphe.quiedeville.org/hack/munin/'."\n"; print("installed.label installed\n"); print("installed.draw AREA\n"); print("other.label other\n"); print("other.draw STACK\n"); exit 0; } my ($inst,$other) = (0,0); my ($stat,$size, $oldstat) = ("null",-1,"null"); open(CCH, "<$CCACHE") or exit 4; while () { my ($xstat) = ( /Status:\s\w+/ ) ? ( /Status:\s(\w+)/ ) : "null"; $stat = $xstat if ($xstat ne "null" && $xstat ne $stat); if ($stat ne "null") { ($size) = ( /Installed-Size:\s\d+/ ) ? ( /Installed-Size:\s(\d+)/ ) : 0; if ($stat eq "install" && $size) { $inst += $size; $size = 0; $stat = "null"; } if ($stat ne "install" && $size) { $other += $size; $size=0; $stat = "null"; } } } close(CCH); $inst = $inst * 1024; $other = $other * 1024; print("installed.value $inst\n"); print("other.value $other\n");