ALT Linux sysadmins discussion
 help / color / mirror / Atom feed
From: Yuriy VHe3anH0 Skv <skvlnx@gmail.com>
To: sysadmins@lists.altlinux.org
Subject: Re: [Sysadmins] imap mailbox size
Date: Fri, 2 Dec 2011 17:55:51 +0400
Message-ID: <20111202175551.71dbefca@skvity.raxxla.net.raxxla.net> (raw)
In-Reply-To: <20111202155725.6b96d513@skvity.raxxla.net.raxxla.net>

типа такого скрипта

#!/usr/bin/perl

use Mail::IMAPClient;

my $imap = Mail::IMAPClient->new(
	Server   => 'mail.mxes.net',
	User     => '**********',
	Password => '**********',
	Ssl      => 0,
	Uid      => 1,
);

my $folders = $imap->folders or die "Failed to get folders\n";
my $sizes = {};

foreach my $folder (@{$folders}){
	$imap->examine($folder) or next;

	$sizes->{$folder} = 0;

	my $hash = $imap->fetch_hash("RFC822.SIZE");
	foreach my $msg (keys %{$hash}){
		$sizes->{$folder} += $hash->{$msg}->{'RFC822.SIZE'};
	}
}

my @keys = sort { $sizes->{$b} <=> $sizes->{$a} } @{$folders};

print "Only showing folders over 1MB:\n";

for my $folder (@keys){

	my $size = $sizes->{$folder};
	if ($sizes->{$folder} > 1024){ $size = int($sizes->{$folder} /
	1024) . "KB"; } if ($sizes->{$folder} > 1024 * 1024){
		$size = int($sizes->{$folder} / (1024 * 1024)) . "MB";
	}

	next unless $size =~ /MB/;

	print "$size\t$folder\n";
}


On Fri, 2 Dec 2011 15:57:25 +0400
Yuriy VHe3anH0 Skv <skvlnx@gmail.com> wrote:

> Подскажите, плз, как проще мониторить размер почтовых ящиков имап.
> Инетересует доступность и объем почты.
> Zabbix, conky, скрипт написать?
> 


      parent reply	other threads:[~2011-12-02 13:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-02 11:57 Yuriy VHe3anH0 Skv
2011-12-02 12:10 ` Илья Меньших
2011-12-02 12:15   ` Yuriy VHe3anH0 Skv
2011-12-02 12:32 ` Michael Shigorin
2011-12-02 13:55 ` Yuriy VHe3anH0 Skv [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111202175551.71dbefca@skvity.raxxla.net.raxxla.net \
    --to=skvlnx@gmail.com \
    --cc=sysadmins@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux sysadmins discussion

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/sysadmins/0 sysadmins/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 sysadmins sysadmins/ http://lore.altlinux.org/sysadmins \
		sysadmins@lists.altlinux.org sysadmins@lists.altlinux.ru sysadmins@lists.altlinux.com
	public-inbox-index sysadmins

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.sysadmins


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git