NAME
Monitoring::Sneck::Checks::mailq - checks the mail queue of Postfix or Exim
VERSION
Version 0.0.1
SYNOPSIS
mailq|perl:mailq
mailq_busy|perl:mailq -w 500 -c 2000 -W 86400
mailq_exim|perl:mailq -m exim
DESCRIPTION
Checks how many messages are queued and how old the oldest is, through postqueue -j for Postfix, 3.1 or newer, or exim -bp for Exim. Without --mta, Postfix is used if postqueue is there, else Exim.
- CRITICAL :: The count or oldest over its critical.
- WARNING :: The count or oldest over its warning.
- UNKNOWN :: Neither being there, or the command failing, such as Postfix not running or Exim not run as root or a admin user.
- OK :: Everything else.
The status line says how many are in each Postfix queue, such as deferred and hold, or how many are frozen for Exim. The oldest messages follow it, with the reason they are delayed for Postfix.
Exim only gives ages to the minute, hour, or day, depending on how old.
OPTIONS
- -m, --mta :: postfix or exim, instead of looking for them.
- -w, --warning :: Range for the count. Default :: 50
- -c, --critical :: Range for the count. Default :: 200
- -W, --age-warning :: Range for the age of the oldest, in seconds. Default :: 14400
- -C, --age-critical :: Range for the age of the oldest, in seconds.
- -l, --list :: How many of the oldest to list after the status line. Default :: 5
METHODS
check
Does the check.
postfix_queue
Reads the Postfix queue through postqueue -j. Dies if it fails.
- postqueue :: The path to postqueue.
Returns a array ref of hash refs of id, age, in seconds, state, the queue it is in, such as deferred or hold, sender, <> for a bounce, recipients, a array ref, and reason, why the first recipient with one is delayed, or undef.
my $messages = $check->postfix_queue('/usr/sbin/postqueue');
# [ { id => '4B7F9A1234', age => 7200, state => 'deferred', sender => 'alice@example.org',
# recipients => ['bob@example.net'], reason => 'connect to mx.example.net[192.0.2.25]:25: Connection refused' } ]
exim_queue
Reads the Exim queue through exim -bp. Dies if it fails.
- exim :: The path to exim.
Returns the same as "postfix_queue", with a state of frozen or queued and no reason. Recipients already delivered to are left out.
my $messages = $check->exim_queue('/usr/sbin/exim4');
# [ { id => '1i7k9a-0003Zs-Qe', age => 14400, state => 'frozen', sender => '<>',
# recipients => ['carol@example.com'], reason => undef } ]