From 6daba0637fbbc20cd46b95a01d436e1371787c0c Mon Sep 17 00:00:00 2001 From: DS_Starter Date: Mon, 6 Apr 2020 15:27:52 +0000 Subject: [PATCH] 93_Log2Syslog: contrib 5.10.1 git-svn-id: https://svn.fhem.de/fhem/trunk@21613 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/93_Log2Syslog.pm | 74 ++++++++++++------------ 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/fhem/contrib/DS_Starter/93_Log2Syslog.pm b/fhem/contrib/DS_Starter/93_Log2Syslog.pm index 132c5c29d..67639f602 100644 --- a/fhem/contrib/DS_Starter/93_Log2Syslog.pm +++ b/fhem/contrib/DS_Starter/93_Log2Syslog.pm @@ -1,5 +1,5 @@ ########################################################################################################################## -# $Id: 93_Log2Syslog.pm 21582 2020-04-02 20:59:26Z DS_Starter $ +# $Id: 93_Log2Syslog.pm 21611 2020-04-05 21:00:33Z DS_Starter $ ########################################################################################################################## # 93_Log2Syslog.pm # @@ -28,6 +28,7 @@ # RFC 3164 https://tools.ietf.org/html/rfc3164 and # TLS Transport according to RFC 5425 https://tools.ietf.org/pdf/rfc5425.pdf # Date and Time according to RFC 3339 https://tools.ietf.org/html/rfc3339 +# RFC 6587 Transmission of Syslog Messages over TCP # ########################################################################################################################## package main; @@ -43,6 +44,7 @@ eval "use FHEM::Meta;1" or my $mod # Versions History intern: my %Log2Syslog_vNotesIntern = ( + "5.10.1" => "06.04.2020 support time-secfrac of RFC 3339, minor fix ", "5.10.0" => "04.04.2020 new attribute 'timeSpec', send and parse messages according to UTC or Local time, some minor fixes (e.g. for Octet Count) ", "5.9.0" => "01.04.2020 Parser UniFi Controller Syslog (BSD Format) and Netconsole messages, more code review (e.g. remove prototypes) ", "5.8.3" => "31.03.2020 fix warning uninitialized value \$pp in pattern match (m//) at line 465, Forum: topic,75426.msg1036553.html#msg1036553, some code review ", @@ -444,7 +446,7 @@ sub Log2Syslog_initServer { $hash->{PROTOCOL} = $protocol; $hash->{SEQNO} = 1; # PROCID wird kontinuierlich pro empfangenen Datensatz hochgezählt $hash->{HELPER}{OLDSEQNO} = $hash->{SEQNO}; # Init Sequenznummer f. Ratenbestimmung - $hash->{INTERFACE} = $lh?$lh:"global"; + $hash->{INTERFACE} = $lh // "global"; Log2Syslog_Log3slog ($hash, 3, "Log2Syslog $name - port $hash->{PORT}/$protocol opened for Syslog Collector on interface \"$hash->{INTERFACE}\""); readingsSingleUpdate ($hash, "state", "initialized", 1); @@ -512,13 +514,13 @@ sub Log2Syslog_Read { my $i = 0; $ocount = $+{ocount}; $tail = $+{tail}; - if(length($tail) >= $ocount) { - $msg = substr($tail,0,$ocount); - } else { - $msg = $tail; - } + $msg = substr($tail,0,$ocount); push @load, $msg; - $tail = substr($tail,$ocount); + if(length($tail) >= $ocount) { + $tail = substr($tail,$ocount); + } else { + $tail = ""; + } Log2Syslog_Log3slog ($hash, 5, "Log2Syslog $name -> OCTETCOUNT$i: $ocount"); Log2Syslog_Log3slog ($hash, 5, "Log2Syslog $name -> MSG$i : $msg"); @@ -745,8 +747,8 @@ sub Log2Syslog_parsePayload { # Hash zur Umwandlung Felder in deren Variablen my ($prival,$ts,$host,$date,$time,$id,$pid,$mid,$sdfield,$cont); - my $fac = ""; - my $sev = ""; + my ($fac,$sev,$msec) = ("","",""); + my %fh = (PRIVAL => \$prival, FAC => \$fac, SEV => \$sev, @@ -873,11 +875,12 @@ sub Log2Syslog_parsePayload { if($prival && $ietf) { # Standard IETF-Syslog incl. VERSION if($ietf == 1) { - $data =~ /^<(?\d{1,3})>(?\d{0,2})\s?(?\d{4}-\d{2}-\d{2})T(?