aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-27 19:26:57 +0100
committerGitHub <noreply@github.com>2018-05-27 19:26:57 +0100
commit765758c28384ddbeb58d5954f888ef5b2f918a3b (patch)
treee104088251d9acea03887eefd32a7e04e6c00c45 /utils
parent4734176fe1719865d3222aebd6bf3c294349226e (diff)
parentc399a5b76cc8969a2bf12556110462092117194a (diff)
downloadrspamd-765758c28384ddbeb58d5954f888ef5b2f918a3b.tar.gz
rspamd-765758c28384ddbeb58d5954f888ef5b2f918a3b.zip
Merge pull request #2267 from azielke/master
rspamd_stats.pl: Parse RFC5424 style timestamps
Diffstat (limited to 'utils')
-rwxr-xr-xutils/rspamd_stats.pl20
1 files changed, 15 insertions, 5 deletions
diff --git a/utils/rspamd_stats.pl b/utils/rspamd_stats.pl
index f4f01dd85..b997ff525 100755
--- a/utils/rspamd_stats.pl
+++ b/utils/rspamd_stats.pl
@@ -460,7 +460,6 @@ sub ProcessRelated {
sub ProcessLog {
my ( $ts_format, @line ) = &log_time_format($rspamd_log);
- my $is_syslog = defined $ts_format && $ts_format eq 'syslog';
while() {
last if eof $rspamd_log;
@@ -474,10 +473,15 @@ sub ProcessLog {
if (/^.*rspamd_task_write_log.*$/) {
&spinner;
- my $ts =
- ($is_syslog)
- ? syslog2iso( join ' ', ( split /\s+/ )[ 0 .. 2 ] )
- : join ' ', ( split /\s+/ )[ 0 .. 1 ];
+ my $ts;
+ if ( $ts_format eq 'syslog' ) {
+ $ts = syslog2iso( join ' ', ( split /\s+/ )[ 0 .. 2 ] );
+ } elsif ( $ts_format eq 'syslog5424' ) {
+ /^([0-9-]+)T([0-9:]+)/;
+ $ts = "$1 $2";
+ } else {
+ $ts = join ' ', ( split /\s+/ )[ 0 .. 1 ];
+ }
next if ( $ts lt $startTime );
next if ( defined $endTime && $ts gt $endTime );
@@ -718,6 +722,12 @@ sub log_time_format {
last;
}
+ # 2018-04-16T06:25:46.012590+02:00 rspamd rspamd[12968]
+ elsif(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,6})?(Z|[-+]\d{2}:\d{2}) \S+ rspamd\[\d+\]/) {
+ $format = 'syslog5424';
+ last;
+ }
+
# Skip newsyslog messages
# Aug 8 00:00:00 hostname newsyslog[63284]: logfile turned over
elsif ( /^\w{3} (?:\s?\d|\d\d) \d\d:\d\d:\d\d\ \S+ newsyslog\[\d+\]: logfile turned over$/ ) {