#!/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. # # Monitor the number of trashed emails in each mailbox for a # determined domain # # $Log$ # Revision 1.2 2006/05/18 10:22:01 rodo # Replace dot in email by underscore # # Revision 1.1 2006/04/25 16:17:01 rodo # Created by Rodolphe Quiedeville # # Must run under user postfix or root # #%# family=courier #%# capabilities=autoconf use strict; $0 =~ /courier_trashed_(.+)*$/; my $domain = $1; exit 2 unless defined $domain; my @mbox; my $store = "/home/virtual/$domain/"; open (STR,"find $store* -type d -maxdepth 0 |"); my @virtuals = ; close(STR); foreach my $dir (@virtuals){ my @names = (split '/', $dir); push (@mbox,pop(@names)); } chomp(@mbox); my $servsn = ''; if ($ARGV[0] and $ARGV[0] eq "config") { print "graph_title Trashed mails in $domain mailboxes\n"; print "graph_args --base 1000 -l 0\n"; print "graph_category courier\n"; print "graph_vlabel files\n"; print "graph_total Total\n"; foreach my $server (@mbox){ $servsn = (split '@',$server)[0]; $servsn =~ s/\./\_/; print "$servsn.label $servsn\n"; print "$servsn.info $server\n"; } exit 0; } foreach my $server (@mbox){ open (STR,"find $store$server/cur/ -name *T -type f | wc -l |"); my $curs = ; close(STR); chomp($curs); my $trash = 0; if (-d "$store$server/.Trash/cur/") { open (STR,"find $store$server/.Trash/cur/ -type f | wc -l |"); $trash = ; close(STR); chomp($trash); } $servsn = (split '@',$server)[0]; $servsn =~ s/\./\_/; print "$servsn.value ".($curs+$trash)."\n"; } # vim:syntax=perl