#!/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. # # Count the number of installed packages, with two other counters that count # wanted removed package and wanted purge packages. On a clean system you must # have the 2 last counters at 0. # # $Log$ # Revision 1.1 2006/03/28 21:04:01 rodo # Created by Rodolphe Quiedeville # #%# family=system #%# capabilities=autoconf use strict; if ($ARGV[0] and $ARGV[0] eq "config") { print "graph_title Debian packages\n"; print "graph_args --base 1000 -l 0\n"; print "graph_category system\n"; print "graph_vlabel packages\n"; print "graph_total Total\n"; print "graph_order installed removed purged\n"; print "installed.label installed\n"; print "installed.info Installed packages\n"; print "installed.draw AREA\n"; print "removed.label removed\n"; print "removed.info Removed packages\n"; print "removed.draw STACK\n"; print "purged.label purged\n"; print "purged.info Purged Installed packages\n"; print "purged.draw STACK\n"; exit 0; } open (HOME,"dpkg -l|"); my @packages = ; close(HOME); my (%stats); ($stats{"rc"}, $stats{"pi"}) = (0,0); foreach my $x (@packages) { $stats{$1}++ if $x =~ /(..).*$/; } print "installed.value ".$stats{"ii"}."\n"; print "removed.value ".$stats{"rc"}."\n"; print "purged.value ".$stats{"pi"}."\n"; # vim:syntax=perl