Perl Script to restart MailScanner if emails in the que are too high

Posted by sgj700 on May 25, 2008 in Uncategorized |

#!/usr/bin/perl
use strict;
use warnings;

my $high = 200;

my $string = `postqueue -p|grep ” Requests.”`;
my $length_string = length $string;
my $start_string = index($string, ‘ in ‘)+4;
my $end_string = index($string, ‘ Requests.’);
my $fragment = substr $string, $start_string, ($end_string-$start_string);

if ($fragment > $high) {
print “que of $fragment above threshold of $high.\n”;
system(‘postqueue -p’);
system(’service MailScanner restart’);
} else {
print “que of $fragment is fine.\n”;
}

#exec(‘postqueue -p|grep ” Requests.”‘);
#system(‘postqueue -p’);

Tags:

Comments are closed.

Copyright © 2010 Sandon Jurowski All rights reserved.
Desk Mess Mirrored v1.2 theme from BuyNowShop.com.