mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
93_Log2Syslog: don't use CRLF as end of data packet if EOF is used
git-svn-id: https://svn.fhem.de/fhem/trunk@23875 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1c7da75574
commit
46d39bbdca
@ -1,5 +1,6 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- feature: 93_Log2Syslog: don't use CRLF as end of data packet if EOF is used
|
||||
- feature: 49_IPCAM: added templates, improved logging
|
||||
- feature: 73_DoorBird: Maximum Size of files stored for Image, Video & Audio
|
||||
- bugfix: 49_SSCam: solve JS error, remove sscam_tooltip.js
|
||||
|
@ -3,7 +3,7 @@
|
||||
##########################################################################################################################
|
||||
# 93_Log2Syslog.pm
|
||||
#
|
||||
# (c) 2017-2020 by Heiko Maaz
|
||||
# (c) 2017-2021 by Heiko Maaz
|
||||
# e-mail: Heiko dot Maaz at t-online dot de
|
||||
#
|
||||
# This script is part of fhem.
|
||||
@ -106,6 +106,7 @@ BEGIN {
|
||||
|
||||
# Versions History intern:
|
||||
my %vNotesIntern = (
|
||||
"5.12.4" => "27.02.2021 don't split data by CRLF if EOF is used (in getIfData) ",
|
||||
"5.12.3" => "02.11.2020 avoid do Logfile archiving which was executed in seldom (unknown) cases ",
|
||||
"5.12.2" => "15.05.2020 permit content of 'exclErrCond' to fhemLog strings ",
|
||||
"5.12.1" => "12.05.2020 add dev to check regex of 'exclErrCond' ",
|
||||
@ -237,18 +238,18 @@ my %vNotesExtern = (
|
||||
|
||||
# Mappinghash BSD-Formatierung Monat
|
||||
my %Log2Syslog_BSDMonth = (
|
||||
"01" => "Jan",
|
||||
"02" => "Feb",
|
||||
"03" => "Mar",
|
||||
"04" => "Apr",
|
||||
"05" => "May",
|
||||
"06" => "Jun",
|
||||
"07" => "Jul",
|
||||
"08" => "Aug",
|
||||
"09" => "Sep",
|
||||
"10" => "Oct",
|
||||
"11" => "Nov",
|
||||
"12" => "Dec",
|
||||
"01" => "Jan",
|
||||
"02" => "Feb",
|
||||
"03" => "Mar",
|
||||
"04" => "Apr",
|
||||
"05" => "May",
|
||||
"06" => "Jun",
|
||||
"07" => "Jul",
|
||||
"08" => "Aug",
|
||||
"09" => "Sep",
|
||||
"10" => "Oct",
|
||||
"11" => "Nov",
|
||||
"12" => "Dec",
|
||||
"Jan" => "01",
|
||||
"Feb" => "02",
|
||||
"Mar" => "03",
|
||||
@ -545,14 +546,16 @@ sub Read { ## no critic 'comple
|
||||
if($hash->{TEMPORARY}) {
|
||||
my $sname = $hash->{SNAME};
|
||||
$rhash = $defs{$sname};
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$rhash = $hash;
|
||||
}
|
||||
|
||||
my $pp = $rhash->{PROFILE};
|
||||
if($pp =~ /BSD/) { # Framelänge BSD-Format
|
||||
$len = $RFC3164len{DL};
|
||||
} elsif ($pp =~ /IETF/) { # Framelänge IETF-Format
|
||||
}
|
||||
elsif ($pp =~ /IETF/) { # Framelänge IETF-Format
|
||||
$len = $RFC5425len{DL};
|
||||
}
|
||||
|
||||
@ -562,9 +565,11 @@ sub Read { ## no critic 'comple
|
||||
|
||||
my $name = $hash->{NAME};
|
||||
return if(IsDisabled($name) || isMemLock($hash));
|
||||
my $mevt = AttrVal($name, "makeEvent", "intern"); # wie soll Reading/Event erstellt werden
|
||||
my $sevevt = AttrVal($name, "respectSeverity", ""); # welcher Schweregrad soll berücksichtigt werden (default: alle)
|
||||
|
||||
|
||||
my $mevt = AttrVal($name, "makeEvent", "intern"); # wie soll Reading/Event erstellt werden
|
||||
my $sevevt = AttrVal($name, "respectSeverity", "" ); # welcher Schweregrad soll berücksichtigt werden (default: alle)
|
||||
my $uef = AttrVal($name, "useEOF", 0 ); # verwende EOF
|
||||
|
||||
if($socket) {
|
||||
($st,$data,$hash) = getIfData($hash,$len,$mlen,$reread);
|
||||
}
|
||||
@ -579,9 +584,11 @@ sub Read { ## no critic 'comple
|
||||
$tail = $+{tail};
|
||||
$msg = substr($tail,0,$ocount);
|
||||
push @load, $msg;
|
||||
|
||||
if(length($tail) >= $ocount) {
|
||||
$tail = substr($tail,$ocount);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$tail = substr($tail,length($msg));
|
||||
}
|
||||
|
||||
@ -597,9 +604,11 @@ sub Read { ## no critic 'comple
|
||||
next if(!$tail);
|
||||
$msg = substr($tail,0,$ocount);
|
||||
push @load, $msg;
|
||||
|
||||
if(length($tail) >= $ocount) {
|
||||
$tail = substr($tail,$ocount);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$tail = substr($tail,length($msg));
|
||||
}
|
||||
|
||||
@ -607,10 +616,15 @@ sub Read { ## no critic 'comple
|
||||
Log3slog ($hash, 5, "Log2Syslog $name -> MSG$i : $msg");
|
||||
Log3slog ($hash, 5, "Log2Syslog $name -> LENGTH_MSG$i: ".length($msg));
|
||||
Log3slog ($hash, 5, "Log2Syslog $name -> TAIL$i : $tail");
|
||||
}
|
||||
|
||||
} else {
|
||||
@load = split("[\r\n]",$data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if($uef) {
|
||||
push @load, $data;
|
||||
}
|
||||
else {
|
||||
@load = split("[\r\n]",$data);
|
||||
}
|
||||
}
|
||||
|
||||
for my $line (@load) {
|
||||
@ -622,17 +636,21 @@ sub Read { ## no critic 'comple
|
||||
$pen++;
|
||||
readingsSingleUpdate($hash, 'Parse_Err_No', $pen, 1);
|
||||
$st = "parse error - see logfile";
|
||||
} elsif ($ignore) {
|
||||
}
|
||||
elsif ($ignore) {
|
||||
Log3slog ($hash, 5, "Log2Syslog $name -> dataset was ignored by parseFn");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return if($sevevt && $sevevt !~ m/$sev/x); # Message nicht berücksichtigen
|
||||
$st = "active";
|
||||
if($mevt =~ /intern/) { # kein Reading, nur Event
|
||||
$pl = "$phost: $pl";
|
||||
Trigger($hash,$ts,$pl);
|
||||
} elsif ($mevt =~ /reading/x) { # Reading, Event abhängig von event-on-.*
|
||||
}
|
||||
elsif ($mevt =~ /reading/x) { # Reading, Event abhängig von event-on-.*
|
||||
readingsSingleUpdate($hash, "MSG_$phost", $pl, 1);
|
||||
} else { # Reading ohne Event
|
||||
}
|
||||
else { # Reading ohne Event
|
||||
readingsSingleUpdate($hash, "MSG_$phost", $pl, 0);
|
||||
}
|
||||
}
|
||||
@ -664,12 +682,15 @@ return;
|
||||
# (sSiehe auch "list TYPE=FHEMWEB", bzw. "man -s2 accept")
|
||||
#
|
||||
###############################################################################
|
||||
sub getIfData { ## no critic 'complexity'
|
||||
my ($hash,$len,$mlen,$reread) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $socket = $hash->{SERVERSOCKET};
|
||||
my $protocol = lc(AttrVal($name, "protocol", "udp"));
|
||||
my ($eof,$buforun) = (0,0);
|
||||
sub getIfData { ## no critic 'complexity'
|
||||
my $hash = shift;
|
||||
my $len = shift;
|
||||
my $mlen = shift;
|
||||
my $reread = shift;
|
||||
my $name = $hash->{NAME};
|
||||
my $socket = $hash->{SERVERSOCKET};
|
||||
my $protocol = lc(AttrVal($name, "protocol", "udp"));
|
||||
my ($eof,$buforun) = (0,0);
|
||||
|
||||
if($hash->{TEMPORARY}) {
|
||||
# temporäre Instanz abgelegt durch TcpServer_Accept
|
||||
@ -689,7 +710,8 @@ sub getIfData { ## no critic
|
||||
Log3slog ($hash, 3, "Log2Syslog $name - Seq \"$hash->{SEQNO}\" invalid data: $data");
|
||||
$data = '' if(length($data) == 0);
|
||||
$st = "receive error - see logfile";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
my $dl = length($data);
|
||||
Log3slog ($hash, 5, "Log2Syslog $name - Buffer ".$dl." chars ready to parse:\n$data");
|
||||
}
|
||||
@ -728,21 +750,22 @@ sub getIfData { ## no critic
|
||||
$shash->{HELPER}{TCPPADDR} = $hash->{PEER};
|
||||
my $buf;
|
||||
my $off = 0;
|
||||
$ret = sysread($c, $buf, $len); # returns undef on error, 0 at end of file and Integer, number of bytes read on success.
|
||||
$ret = sysread($c, $buf, $len); # returns undef on error, 0 at end of file and Integer, number of bytes read on success.
|
||||
|
||||
if(!defined($ret) && $! == EWOULDBLOCK()){ # error
|
||||
$hash->{wantWrite} = 1 if(TcpServer_WantWrite($hash));
|
||||
$hash = $shash;
|
||||
Log3slog ($hash, 2, "Log2Syslog $sname - ERROR - TCP stack error: $!");
|
||||
return ($st,undef,$hash);
|
||||
|
||||
} elsif (!$ret) { # EOF or error
|
||||
return ($st,undef,$hash);
|
||||
}
|
||||
elsif (!$ret) { # EOF or error
|
||||
Log3slog ($shash, 4, "Log2Syslog $sname - Connection closed for $cname: ".(defined($ret) ? 'EOF' : $!));
|
||||
if(!defined($ret)) { # error
|
||||
CommandDelete(undef, $cname);
|
||||
$hash = $shash;
|
||||
return ($st,undef,$hash);
|
||||
} else { # EOF
|
||||
}
|
||||
else { # EOF
|
||||
$eof = 1;
|
||||
$data = $hash->{BUF};
|
||||
CommandDelete(undef, $cname);
|
||||
@ -3231,7 +3254,8 @@ $CONT = (split(">",$CONT))[1] if($CONT =~ /^<.*>.*$/);
|
||||
After every transmission the TCP-connection will be terminated with signal EOF. <br><br>
|
||||
|
||||
<b>Model Collector: </b><br>
|
||||
No parsing until the sender has send an EOF signal. If TLS is used, this attribute has no effect.
|
||||
No parsing until the sender has send an EOF signal. CRLF is not considered as data separator.
|
||||
If not set, CRLF will be considered as a record separator.
|
||||
<br>
|
||||
<br>
|
||||
|
||||
@ -4005,8 +4029,8 @@ $CONT = (split(">",$CONT))[1] if($CONT =~ /^<.*>.*$/);
|
||||
Nach jedem Sendevorgang wird eine TCP-Verbindung mit EOF beendet. <br><br>
|
||||
|
||||
<b>Model Collector: </b><br>
|
||||
Es wird mit dem Parsing gewartet, bis der Sender ein EOF Signal gesendet hat. Wird TLS verwendet, hat dieses Attribut
|
||||
keine Auswirkung.
|
||||
Es wird mit dem Parsing gewartet, bis der Sender ein EOF Signal gesendet hat. CRLF wird nicht als Datentrenner
|
||||
berücksichtigt. Wenn nicht gesetzt, wird CRLF als Trennung von Datensätzen gewertet.
|
||||
<br>
|
||||
<br>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user