summaryrefslogtreecommitdiffstats
path: root/utils/rspamd_stats.pl
diff options
context:
space:
mode:
authorAlexander Moisseev <moiseev@mezonplus.ru>2017-08-08 18:22:20 +0300
committerAlexander Moisseev <moiseev@mezonplus.ru>2017-08-08 18:22:20 +0300
commitaa4fe8256ae2f7f70724be99b210c2e7c42c525c (patch)
treeae85640cb66a4a56f68b82ccc6981884179de364 /utils/rspamd_stats.pl
parent48a53386ca210f3eb0d6b6921e16d2eb8fd8a59b (diff)
downloadrspamd-aa4fe8256ae2f7f70724be99b210c2e7c42c525c.tar.gz
rspamd-aa4fe8256ae2f7f70724be99b210c2e7c42c525c.zip
[Minor] rspamd_stats: try to guess the last year timestamps for syslog
Diffstat (limited to 'utils/rspamd_stats.pl')
-rwxr-xr-xutils/rspamd_stats.pl10
1 files changed, 7 insertions, 3 deletions
diff --git a/utils/rspamd_stats.pl b/utils/rspamd_stats.pl
index af5b4ec6f..fcd2ea503 100755
--- a/utils/rspamd_stats.pl
+++ b/utils/rspamd_stats.pl
@@ -448,15 +448,19 @@ sub numeric {
$a_num <=> $b_num;
}
-# Convert syslog timestamp to "ISO 8601 like" format.
-# Using current year, as syslog does not record the year (nor the timezone)
+# Convert syslog timestamp to "ISO 8601 like" format
+# using current year as syslog does not record the year (nor the timezone)
+# or the last year if the guessed time is in the future.
sub syslog2iso {
my %month_map;
@month_map{qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)} = 0 .. 11;
my ( $month, @t ) =
$_[0] =~ m/^(\w{3}) \s\s? (\d\d?) \s (\d\d):(\d\d):(\d\d)/x;
- sprintf '%04d-%02d-%02d %02d:%02d:%02d', 1900 + (localtime)[5],
+ my $epoch =
+ timelocal( ( reverse @t ), $month_map{$month}, 1900 + (localtime)[5] );
+ sprintf '%04d-%02d-%02d %02d:%02d:%02d',
+ 1900 + (localtime)[5] - ( $epoch > time ),
$month_map{$month} + 1, @t;
}