Monitoring apt-proxy mit munin

apt-proxy ist klasse wenn man eine Internetanbindung hat, die sich nicht unbedingt breitbandig nennen kann und wenn man mehrere Rechner mit Debian/Ubuntu betreibt. Nun will man auch wissen was das Ding so treibt. Ein erster Blick geht dann nach munin-exchange um dort das Plugin apt-proxy zu finden. Um auch Statistiken von Ubuntu zu haben, habe ich das Plugin erweitert.

#!/usr/bin/perl 
#
# 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 number of files in apt-proxy cache
#
# $Log$
# Revision 1.1  2006/03/28 21:04:01  rodo
# Created by Rodolphe Quiedeville
#
# Must run on aptproxy user or root
#
#%# family=apt-proxy
#%# capabilities=autoconf

use strict;

if ($ARGV[0] and $ARGV[0] eq "config")
{
    print "graph_title Files in apt-proxy cache\n";
    print "graph_args --base 1000 -l 0\n";
    print "graph_category apt-proxy\n";
    print "graph_vlabel files\n";
    print "debmain.label Debian main\n";
    print "debmain.info Packages in debian main\n";
    print "debmain.draw LINE\n";
    print "debcontrib.label Debian contrib\n";
    print "debcontrib.info Packages in debian contrib\n";
    print "debcontrib.draw LINE\n";
    print "debnonfree.label Debian nonfree\n";
    print "debnonfree.info Packages in debian nonfree\n";
    print "debnonfree.draw LINE\n";
    print "debsecuritymain.label Debian security main\n";
    print "debsecuritymain.info Packages in security main\n";
    print "debsecuritymain.draw LINE\n";
    print "debsecuritycontrib.label Debian security contrib\n";
    print "debsecuritycontrib.info Packages in security contrib\n";
    print "debsecuritycontrib.draw LINE\n";
    print "debsecuritynonfree.label Debian security Non Free\n";
    print "debsecuritynonfree.info Packages in Debian security Non Free\n";
    print "debsecuritynonfree.draw LINE\n";
    print "debmultimedia.label Debian multimedia\n";
    print "debmultimedia.info Packages in Debian multimedia\n";
    print "debmultimedia.draw LINE\n";
    print "ubuntumain.label Ubuntu main\n";
    print "ubuntumain.info Packages in Ubuntu main\n";
    print "ubuntumain.draw LINE\n";
    print "ubuntumultiverse.label Ubuntu multiverse\n";
    print "ubuntumultiverse.info Packages in Ubuntu multiverse\n";
    print "ubuntumultiverse.draw LINE\n";
    print "ubuntuuniverse.label Ubuntu universe\n";
    print "ubuntuuniverse.info Packages in Ubuntu universe\n";
    print "ubuntuuniverse.draw LINE\n";
    print "ubuntusecuritymain.label Ubuntu security main\n";
    print "ubuntusecuritymain.info Packages in Ubuntu security main\n";
    print "ubuntusecuritymain.draw LINE\n";
    print "ubuntusecuritymultiverse.label Ubuntu security multiverse\n";
    print "ubuntusecuritymultiverse.info Packages in Ubuntu security multiverse\n";
    print "ubuntusecuritymultiverse.draw LINE\n";
    print "ubuntusecurityuniverse.label Ubuntu security universe\n";
    print "ubuntusecurityuniverse.info Packages in Ubuntu security universe\n";
    print "ubuntusecurityuniverse.draw LINE\n";

    exit 0;
}

my $debianmain = "/var/cache/apt-proxy/debian/pool/main ";
my $debiancontrib = "/var/cache/apt-proxy/debian/pool/contrib ";
my $debiannonfree = "/var/cache/apt-proxy/debian/pool/non-free ";
my $debiansecurity = "/var/cache/apt-proxy/security/pool/updates/main ";
my $debcontrib = "/var/cache/apt-proxy/debian/pool/contrib ";
my $debnonfree = "/var/cache/apt-proxy/debian/pool/non-free ";
my $debmultimedia = "/var/cache/apt-proxy/debian-multimedia/pool/main ";
my $ubuntumain = "/var/cache/apt-proxy/ubuntu/pool/main ";
my $ubuntumultiverse = "/var/cache/apt-proxy/ubuntu/pool/multiverse ";
my $ubunturestricted = "/var/cache/apt-proxy/ubuntu/pool/restricted ";
my $ubuntuuniverse = "/var/cache/apt-proxy/ubuntu/pool/universe ";
my $ubuntusecuritymain = "/var/cache/apt-proxy/ubuntu-security/pool/main ";
my $ubuntusecuritymultiverse = "/var/cache/apt-proxy/ubuntu-security/pool/multiverse ";
my $ubuntusecurityuniverse = "/var/cache/apt-proxy/ubuntu-security/pool/universe ";

open (HOME,"find $debianmain -type f | wc -l |");
my $debmainfiles = ;
close(HOME);

open (HOME,"find $debiancontrib -type f | wc -l |");
my $debcontribfiles = ;
close(HOME);

open (HOME,"find $debiannonfree -type f | wc -l |");
my $debnonfreefiles = ;
close(HOME);

open (HOME,"find $debiansecurity -type f | wc -l |");
my $debfiles_secu_main = ;
close(HOME);

open (HOME,"find $debcontrib -type f | wc -l |");
my $debfiles_secu_contrib = ;
close(HOME);

open (HOME,"find $debnonfree  -type f | wc -l |");
my $debfiles_secu_nonfree = ;
close(HOME);

open (HOME,"find $debmultimedia -type f | wc -l |");
my $debfilesmultimedia = ;
close(HOME);

open (HOME,"find $ubuntumain -type f | wc -l |");
my $ubuntumainfiles = ;
close(HOME);

open (HOME,"find $ubuntumultiverse -type f | wc -l |");
my $ubuntumultiversefiles = ;
close(HOME);

open (HOME,"find $ubunturestricted -type f | wc -l |");
my $ubunturestrictedfiles = ;
close(HOME);
open (HOME,"find $ubuntuuniverse -type f | wc -l |");
my $ubuntuuniversefiles = ;
close(HOME);

open (HOME,"find $ubuntusecuritymain -type f | wc -l |");
my $ubuntufiles_secu_main = ;
close(HOME);

open (HOME,"find $ubuntusecuritymultiverse -type f | wc -l |");
my $ubuntufiles_secu_multiverse = ;
close(HOME);

open (HOME,"find $ubuntusecurityuniverse -type f | wc -l |");
my $ubuntufiles_secu_universe = ;
close(HOME);

chomp($debmainfiles);
chomp($debcontribfiles);
chomp($debnonfreefiles);
chomp($debfiles_secu_main);
chomp($debfiles_secu_contrib);
chomp($debfiles_secu_nonfree);
chomp($debfilesmultimedia);
chomp($ubuntumainfiles);
chomp($ubuntumultiversefiles);
chomp($ubunturestrictedfiles);
chomp($ubuntuuniversefiles);
chomp($ubuntufiles_secu_main);
chomp($ubuntufiles_secu_multiverse);
chomp($ubuntufiles_secu_universe);

print "debmain.value ".$debmainfiles."\n";
print "debcontrib.value ".$debcontribfiles."\n";
print "debnonfree.value ".$debnonfreefiles."\n";
print "debsecuritymain.value ".$debfiles_secu_main."\n";
print "debsecuritycontrib.value ".$debfiles_secu_contrib."\n";
print "debsecuritynonfree.value ".$debfiles_secu_nonfree."\n";
print "debmultimedia.value ".$debfilesmultimedia."\n";
print "ubuntumain.value ".$ubuntumainfiles."\n";
print "ubuntumultiverse.value ".$ubuntumultiversefiles."\n";
print "ubunturestricted.value ".$ubunturestrictedfiles."\n";
print "ubuntuuniverse.value ".$ubuntuuniversefiles."\n";
print "ubuntusecuritymain.value ".$ubuntufiles_secu_main."\n";
print "ubuntusecuritymultiverse.value ".$ubuntufiles_secu_multiverse."\n";
print "ubuntusecurityuniverse.value ".$ubuntufiles_secu_universe."\n";
Dieser Beitrag wurde unter Debian, Linux abgelegt und mit , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.