Email Latency Graphing
"Is e-mail running slow?"
"I'm supposed to have an e-mail, but I haven't seen it yet?"
If you have ever had to answer any of these questions or related queries then these scripts may be for you. These two perl scripts monitor email latency in seconds and let you know time it takes for mail to process through your mail server and back to you.
You can then tie the output to create a MRTG, RRDTool or Zabbix graph such as the one below:
The script supports an unlimited number of mail servers along the mail path. For example, if you had an edge mail server that handled level one spam checks, a secondary mail server that handled further spam and antivirus checks, and a final mail server where users checked their mail then you could monitor all three servers to see which server was introducing the processing delay.
The script also reports absolute and relative latency. Absolute is the total amount of time that has elapsed from when the message was sent. Relative is the amount of time in seconds from the last non local mail server to your mail server. This lets you separate out issues from external mail servers that may be out of your control.
Requirements:
Instructions:
Modify the following lines to fit your enviroment:
Usage:
./checkEmail.pl mailserver.domain.com --measure=absolute
./checkEmail.pl spamfilter.domain.com --measure=relative
./checkEmail.pl mailserver --measure=absolute --debug=yes
Download
"I'm supposed to have an e-mail, but I haven't seen it yet?"
If you have ever had to answer any of these questions or related queries then these scripts may be for you. These two perl scripts monitor email latency in seconds and let you know time it takes for mail to process through your mail server and back to you.
You can then tie the output to create a MRTG, RRDTool or Zabbix graph such as the one below:
The script supports an unlimited number of mail servers along the mail path. For example, if you had an edge mail server that handled level one spam checks, a secondary mail server that handled further spam and antivirus checks, and a final mail server where users checked their mail then you could monitor all three servers to see which server was introducing the processing delay.The script also reports absolute and relative latency. Absolute is the total amount of time that has elapsed from when the message was sent. Relative is the amount of time in seconds from the last non local mail server to your mail server. This lets you separate out issues from external mail servers that may be out of your control.
Requirements:
- Perl installation with the following modules:
- Mail::POP3Client
- Net::SMTP
- Date::Parse
- Getopt::Long
- External mail host to send your messages from - OR -
- External account set to bounce messages back to your mailserver
- I use a free GMail account that is setup to bounce mail back to my local test account
Instructions:
Modify the following lines to fit your enviroment:
checkEmail.plSetup sendOutToTestEmail.pl to run from cron to periodically send your test messages. Configure checkEmail.pl to run on a slightly longer interval to retrieve the test messages and graph the time.
---
###############################################
## Configuration Variables
###############################################
$dnsDomain = "domain.com";
$mailServer = "mail.domain.com";
$mailPort = "995";
$mailUser = "username";
$mailPassword = "password";
$mailSubject = "MailLatency";
$mailSSL = "true";
sendOutToInTestEmail.pl
---
###############################################
## Configuration Variables
###############################################
@serverList = qw(mail spam-firewall);
$dnsDomain = "domain.com";
$mailTo = 'MailLatencyTest@gmail.com';
$mailServer = 'mail.domain.com';
$mailSubject = 'MailLatency';
$mailFrom = 'username';
$LOG = "/var/log/emailout.log";
Usage:
./checkEmail.pl mailserver.domain.com --measure=absolute
./checkEmail.pl spamfilter.domain.com --measure=relative
./checkEmail.pl mailserver --measure=absolute --debug=yes
Download