Sfoglia il codice sorgente

[Minor] rspamd_stats: try to guess the last year timestamps for syslog

tags/1.7.0
Alexander Moisseev 6 anni fa
parent
commit
aa4fe8256a
1 ha cambiato i file con 7 aggiunte e 3 eliminazioni
  1. 7
    3
      utils/rspamd_stats.pl

+ 7
- 3
utils/rspamd_stats.pl Vedi File

@@ -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;
}


Loading…
Annulla
Salva