i try to use this script to get received messages stat in the last 5 minutes from my mail.log (mail.info) log file
Code: Select all
[root@server]:[/usr/share/cacti/site/scripts/sendmail]#cat recu.sh
#!/bin/sh
echo .1.3.6.1.4.100.5
echo gauge
tail -n 5000 /var/log/mail.info|awk '
BEGIN {
search_time = "^" strftime("%b %e %H:%M:%S", systime() - 5 * 60);
search_sent = "stat=Sent";
search_domain_1 = "@atreillou.com";
recv_count = 0;
}
{
if ($0 ~ search_time && $0 ~ search_sent) time_trigger = 1;
if ($0 ~ search_sent) is_sent_trigger = 1;
if ($0 ~ search_domain_1) is_domain_trigger = 1;
if ($0 ~ search_domain_2) is_domain_trigger = 1;
if (time_trigger && is_sent_trigger && is_domain_trigger) recv_count++;
is_sent_trigger = 0;
is_domain_trigger = 0;
}
END { print recv_count; }'
exit
Code: Select all
[root@server]:[/usr/share/cacti/site/scripts/sendmail]#diff recu.sh recunodate.sh
6c6
< search_time = "^" strftime("%b %e %H:%M:%S", systime() - 5 * 60);
---
> # search_time = "^" strftime("%b %e %H:%M:%S", systime() - 5 * 60);
Code: Select all
[root@server]:[/usr/share/cacti/site/scripts/sendmail]#sh recu.sh
.1.3.6.1.4.100.5
gauge
0
[root@server]:[/usr/share/cacti/site/scripts/sendmail]#sh recunodate.sh
.1.3.6.1.4.100.5
gauge
48
it's the same problem with differents script that use stfrtime like mailstats.sh, sent.sh etc
Any idea ?
I sent/receive 10 mail in last 5 minutes for the test
one log line:
Code: Select all
[root@server]:[/usr/share/cacti/site/scripts/sendmail]#tail -n 1 /var/log/mail.info
May 2 11:08:36 server sendmail[26267]: k422ejU9019740: to=<nicholas@paramed.biz>, delay=06:27:51, xdelay=00:03:09, mailer=esmtp, pri=3118721, relay=paramed.biz. [204.251.15.174], dsn=4.0.0, stat=Deferred: Connection timed out with paramed.biz.