head     1.2;
access   ;
symbols  ;
locks    ; strict;
comment  @# @;


1.2
date     90.05.22.10.03.01;  author vixie;  state Exp;
branches ;
next     1.1;

1.1
date     89.12.04.20.47.42;  author reid;  state Exp;
branches ;
next     ;


desc
@@


1.2
log
@vixie
@
text
@#! /usr/local/bin/perl

push(@@INC, '/usr/local/lib');
do 'mailqutil.pl';

$now = time;
$secondsperhour = 3600;

format q_top =
Queue locked age<1    <2    <4    <8   <16   <32   <64  >=64 total (files)
--------------------------------------------------------------------------
.
format q_line =
@@<<<<< @@>>>> @@>>>> @@>>>> @@>>>> @@>>>> @@>>>> @@>>>> @@>>>> @@>>>> @@>>>> @@>>>>>>
$queue,$locked,$b[0],$b[1],$b[2],$b[3],$b[4],$b[5],$b[6],$b[7],$total,$files
.

$^ = "q_top";
$~ = "q_line";
$dirs = 0;
foreach $qdir (</usr/spool/{mqueue,mq[0-9],mq-*}>) {
	chdir $qdir || die "can't chdir to $qdir: $!\n";
	opendir(qdir, ".") || die "can't opendir $qdir: $!\n";
	$dirs++;
	@@_ = split(/\//, $qdir);
	$queue = $_[$#_];
	$locked = 0;
	@@b = ();
	$total = 0;
	$files = 0;
	while ($_ = readdir(qdir)) {
		next if ($_ eq "." || $_ eq "..");
		$files++;
		if (/^lf/) {
			$locked++;
		} elsif (/^qf/) {
			$total++;
			s/q/d/;
			$age = ($now - &mtime($_)) / $secondsperhour;
			$b[&bucket($age)]++;
		}
	}
	close(qdir);
	write() if ($files > 0);
	$t_locked += $locked;
	for ($i = 0;  $i <= $#b;  $i++) {
		$t_b[$i] += $b[$i];
	}
	$t_total += $total;
}

if ($dirs > 1) {
	$queue = ""; $locked = ""; @@b = (); $total = ""; $files = ""; write();
	$queue = "TOTAL";
	$locked = $t_locked;
	@@b = @@t_b;
	$total = $t_total;
	write();
}

exit 1;
@


1.1
log
@Initial revision
@
text
@d1 1
a1 2
#! /bin/csh -f
#
d3 2
a4 1
set path = (/usr/local/bin $path)
d6 2
a7 5
if ($#argv == 0) then
    set dirlist = (/usr/spool/{mqueue,mq{1,2,3,4,5,6,7,8}})
else
    set dirlist = ($*)
endif
d9 53
a61 19
set here = `pwd`
set sum = 0
echo "Undelivered mail by queue"
echo ""
echo "msgs	   queue	  age in hours"
echo "--------------------------------------"
set age=1
foreach dir ($dirlist)
	cd $dir
	set sss="`fls | ngrep ^qf | wc -l` $dir"
	echo $sss $age | awk '{if ($3 < 255) printf "%6d	%-20s  < %s\n",$1,$2,$3; else printf "%6d	%-20s\n",$1,$2}'
	set ttt=($sss)
	set age=`expr 2 \* $age`
	set sum=`expr $sum + $ttt[1]`
	cd $here
end
echo ""
echo $sum total
echo ""
@
