[exim] Patch for exiqgrep

Góra strony
Delete this message
Reply to this message
Autor: Dennis Skinner
Data:  
Dla: exim-users
Temat: [exim] Patch for exiqgrep
I needed to modify exiqgrep for something I am working on. Incase
anyone else finds it useful, I am including it below. It counts the
number of recipients yet to be delivered and displays those with more
than the number specified on the cmdline; e.g.

exiqgrep -n 25

would show those msgs with more than 25 recips yet to be delivered.

--
Dennis Skinner
Systems Administrator
BlueFrog Internet
http://www.bluefrog.com

"Winter is an etching, spring a watercolor, summer an oil painting and
autumn a mosaic of them all. - Stanley Horowitz"
*** exim/bin/exiqgrep 2004-11-09 13:41:06.000000000 -0500
--- exiqgrep    2004-11-10 12:27:19.000000000 -0500
***************
*** 43,49 ****
    $base = 62;
  };


! getopts('hf:r:y:o:s:zxlibRc',\%opt);
if ($opt{h}) { &help; exit;}

  # Read message queue output into hash
--- 43,49 ----
    $base = 62;
  };


! getopts('hf:r:y:o:s:n:zxlibRc',\%opt);
if ($opt{h}) { &help; exit;}

  # Read message queue output into hash
***************
*** 69,74 ****
--- 69,75 ----
        -o <seconds>    Message older than
        -z              Frozen messages only (exclude non-frozen)
        -x              Non-frozen messages only (exclude frozen)
+       -n <number>     Message with number of recipients yet to be delivered >= <number>


[ NB: for regexps, provided string sits in /<string>/ ]

***************
*** 89,94 ****
--- 90,96 ----
                #Should be 1st line of record, if not error.
                if ($line =~ /^\s*(\w+)\s+(\S+)\s+(\w{6}-\w{6}-\w{2})\s+(<.*?>)/) {
                        my $msg = $3;
+                       $id{$msg}{rcptcnt} = 0;
                        $id{$msg}{age} = $1;
                        $id{$msg}{size} = $2;
                        $id{$msg}{from} = $4;
***************
*** 101,106 ****
--- 103,109 ----
                        }
                        while(<QUEUE> =~ /\s+(.*?\@.*)$/) {
                                push(@{$id{$msg}{rcpt}},$1);
+                               $id{$msg}{rcptcnt}++;
                        }
                        # Increment message counter.
                        $count++;
***************
*** 145,150 ****
--- 148,157 ----
                        # Exclude frozen
                        next if ($id{$msg}{frozen});
                }
+               if ($opt{n}) {
+                       # Match more than n recipients
+                       next unless ($id{$msg}{rcptcnt} >= $opt{n});
+               }
                # Here's what we do to select the record.
                # Should only get this far if the message passed all of
                # the active tests.