Mail traffic update - handle different syslog timestamps when parsing logs
We've noticed on our ISPC instance that the mail traffic stats had not been updated for a few months now.
The thing is, we've enabled rsyslog's high precision timestamps on our severs in order to get actually useful logs. And it turns out that ISPC can't update the mail traffic stats because it doesn't find what it needs from the log files anymore.
The culprit is the regexp used in the parse_mail_log_line private function in 100-mailbox_stats.inc.php The regexp looks for the (shameful) traditional rsyslog timestamp when parsing lines from /var/log/mail.log, timestamp which is then turned into a php timestamp using the strtotime function.
The code can be easily changed to take at least three timestamp formats : traditional rsyslog, rsyslog "detailed" (schematically: yyyy-MM-ddThh:mm:ssZ), and rsyslog "high precision" (which is like the detailed but with milliseconds on top).
See attached patch for the changes.mail_traffic_improve_log_timestamp_parse.diff