mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
93_Log2Syslog: permit content of 'exclErrCond' to fhemLog strings Forum: 75426.msg1054362.html#msg1054362
git-svn-id: https://svn.fhem.de/fhem/trunk@21947 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
8806f938f0
commit
49590e5893
@ -1,5 +1,7 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- change: 93_Log2Syslog: permit content of 'exclErrCond' to fhemLog strings
|
||||||
|
Forum: 75426.msg1054362.html#msg1054362
|
||||||
- new: 48_BlinkCamera: now made official module for Blink Cameras
|
- new: 48_BlinkCamera: now made official module for Blink Cameras
|
||||||
- feature: module test framework (fhem.pl -t / FhemTestUtils)
|
- feature: module test framework (fhem.pl -t / FhemTestUtils)
|
||||||
- change: 00_MYSENSORS: apply some PBP recommendations,
|
- change: 00_MYSENSORS: apply some PBP recommendations,
|
||||||
|
@ -40,9 +40,9 @@ use POSIX;
|
|||||||
use Scalar::Util qw(looks_like_number);
|
use Scalar::Util qw(looks_like_number);
|
||||||
use Time::HiRes qw(gettimeofday);
|
use Time::HiRes qw(gettimeofday);
|
||||||
use Encode qw(encode_utf8 decode_utf8);
|
use Encode qw(encode_utf8 decode_utf8);
|
||||||
eval "use IO::Socket::INET;1" or my $MissModulSocket = "IO::Socket::INET"; ## no critic
|
eval "use IO::Socket::INET;1" or my $MissModulSocket = "IO::Socket::INET"; ## no critic 'eval'
|
||||||
eval "use Net::Domain qw(hostname hostfqdn hostdomain domainname);1" or my $MissModulNDom = "Net::Domain"; ## no critic
|
eval "use Net::Domain qw(hostname hostfqdn hostdomain domainname);1" or my $MissModulNDom = "Net::Domain"; ## no critic 'eval'
|
||||||
eval "use FHEM::Meta;1" or my $modMetaAbsent = 1; ## no critic
|
eval "use FHEM::Meta;1" or my $modMetaAbsent = 1; ## no critic 'eval'
|
||||||
use GPUtils qw(GP_Import GP_Export);
|
use GPUtils qw(GP_Import GP_Export);
|
||||||
|
|
||||||
# Run before module compilation
|
# Run before module compilation
|
||||||
@ -106,6 +106,7 @@ BEGIN {
|
|||||||
|
|
||||||
# Versions History intern:
|
# Versions History intern:
|
||||||
my %vNotesIntern = (
|
my %vNotesIntern = (
|
||||||
|
"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' ",
|
"5.12.1" => "12.05.2020 add dev to check regex of 'exclErrCond' ",
|
||||||
"5.12.0" => "16.04.2020 improve IETF octet count again, internal code changes for PBP ",
|
"5.12.0" => "16.04.2020 improve IETF octet count again, internal code changes for PBP ",
|
||||||
"5.11.0" => "14.04.2020 switch to packages, improve IETF octet count ",
|
"5.11.0" => "14.04.2020 switch to packages, improve IETF octet count ",
|
||||||
@ -526,7 +527,7 @@ return;
|
|||||||
#
|
#
|
||||||
########################################################################################################
|
########################################################################################################
|
||||||
# called from the global loop, when the select for hash->{FD} reports data
|
# called from the global loop, when the select for hash->{FD} reports data
|
||||||
sub Read {
|
sub Read { ## no critic 'complexity'
|
||||||
my ($hash,$reread) = @_;
|
my ($hash,$reread) = @_;
|
||||||
my $socket = $hash->{SERVERSOCKET};
|
my $socket = $hash->{SERVERSOCKET};
|
||||||
|
|
||||||
@ -569,7 +570,7 @@ sub Read {
|
|||||||
|
|
||||||
if($data) { # parse Payload
|
if($data) { # parse Payload
|
||||||
my (@load,$ocount,$msg,$tail);
|
my (@load,$ocount,$msg,$tail);
|
||||||
if($data =~ /^(?<ocount>(\d+))\s(?<tail>.*)/sx) { # Syslog Sätze mit Octet Count -> Transmission of Syslog Messages over TCP https://tools.ietf.org/html/rfc6587
|
if($data =~ /^(?<ocount>(\d+?))\s(?<tail>(.*))/sx) { # Syslog Sätze mit Octet Count -> Transmission of Syslog Messages over TCP https://tools.ietf.org/html/rfc6587
|
||||||
Log3slog ($hash, 4, "Log2Syslog $name - Datagramm with Octet Count detected - prepare message for Parsing ... \n");
|
Log3slog ($hash, 4, "Log2Syslog $name - Datagramm with Octet Count detected - prepare message for Parsing ... \n");
|
||||||
use bytes;
|
use bytes;
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
@ -588,7 +589,7 @@ sub Read {
|
|||||||
Log3slog ($hash, 5, "Log2Syslog $name -> LENGTH_MSG$i: ".length($msg));
|
Log3slog ($hash, 5, "Log2Syslog $name -> LENGTH_MSG$i: ".length($msg));
|
||||||
Log3slog ($hash, 5, "Log2Syslog $name -> TAIL$i : $tail");
|
Log3slog ($hash, 5, "Log2Syslog $name -> TAIL$i : $tail");
|
||||||
|
|
||||||
while($tail && $tail =~ /^(?<ocount>(\d+))\s(?<tail>.*)/sx) {
|
while($tail && $tail =~ /^(?<ocount>(\d+?))\s(?<tail>(.*))/sx) {
|
||||||
$i++;
|
$i++;
|
||||||
$ocount = $+{ocount};
|
$ocount = $+{ocount};
|
||||||
$tail = $+{tail};
|
$tail = $+{tail};
|
||||||
@ -662,7 +663,7 @@ return;
|
|||||||
# (sSiehe auch "list TYPE=FHEMWEB", bzw. "man -s2 accept")
|
# (sSiehe auch "list TYPE=FHEMWEB", bzw. "man -s2 accept")
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
sub getIfData {
|
sub getIfData { ## no critic 'complexity'
|
||||||
my ($hash,$len,$mlen,$reread) = @_;
|
my ($hash,$len,$mlen,$reread) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $socket = $hash->{SERVERSOCKET};
|
my $socket = $hash->{SERVERSOCKET};
|
||||||
@ -796,7 +797,7 @@ return ($st,undef,$hash);
|
|||||||
# Parsen Payload für Syslog-Server
|
# Parsen Payload für Syslog-Server
|
||||||
# (im Collector Model)
|
# (im Collector Model)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
sub parsePayload {
|
sub parsePayload { ## no critic 'complexity'
|
||||||
my ($hash,$data) = @_;
|
my ($hash,$data) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $pp = AttrVal($name, "parseProfile", $hash->{PROFILE});
|
my $pp = AttrVal($name, "parseProfile", $hash->{PROFILE});
|
||||||
@ -1154,7 +1155,7 @@ sub parsePayload {
|
|||||||
my $SDFIELD = "";
|
my $SDFIELD = "";
|
||||||
my $IGNORE = 0;
|
my $IGNORE = 0;
|
||||||
|
|
||||||
eval $parseFn; ##no critic
|
eval $parseFn; ## no critic 'eval'
|
||||||
if($@) {
|
if($@) {
|
||||||
Log3slog ($hash, 2, "Log2Syslog $name -> error parseFn: $@");
|
Log3slog ($hash, 2, "Log2Syslog $name -> error parseFn: $@");
|
||||||
$err = 1;
|
$err = 1;
|
||||||
@ -1419,7 +1420,7 @@ return;
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# Get
|
# Get
|
||||||
###############################################################################
|
###############################################################################
|
||||||
sub Get {
|
sub Get { ## no critic 'complexity'
|
||||||
my ($hash, @a) = @_;
|
my ($hash, @a) = @_;
|
||||||
return "\"get X\" needs at least an argument" if ( @a < 2 );
|
return "\"get X\" needs at least an argument" if ( @a < 2 );
|
||||||
my $name = $a[0];
|
my $name = $a[0];
|
||||||
@ -1533,7 +1534,9 @@ return;
|
|||||||
}
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
sub Attr {
|
# Attr
|
||||||
|
###############################################################################
|
||||||
|
sub Attr { ## no critic 'complexity'
|
||||||
my ($cmd,$name,$aName,$aVal) = @_;
|
my ($cmd,$name,$aName,$aVal) = @_;
|
||||||
my $hash = $defs{$name};
|
my $hash = $defs{$name};
|
||||||
my ($do,$st);
|
my ($do,$st);
|
||||||
@ -1709,7 +1712,7 @@ return ($reading, $value, $unit);
|
|||||||
#################################################################################
|
#################################################################################
|
||||||
# Eventlogging
|
# Eventlogging
|
||||||
#################################################################################
|
#################################################################################
|
||||||
sub eventLog {
|
sub eventLog { ## no critic 'complexity'
|
||||||
# $hash is my entry, $dev is the entry of the changed device
|
# $hash is my entry, $dev is the entry of the changed device
|
||||||
my ($hash,$dev) = @_;
|
my ($hash,$dev) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
@ -1923,7 +1926,7 @@ return($txt);
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# erstelle Socket
|
# erstelle Socket
|
||||||
###############################################################################
|
###############################################################################
|
||||||
sub openSocket {
|
sub openSocket { ## no critic 'complexity'
|
||||||
my ($hash,$supresslog) = @_;
|
my ($hash,$supresslog) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $protocol = lc(AttrVal($name, "protocol", "udp"));
|
my $protocol = lc(AttrVal($name, "protocol", "udp"));
|
||||||
@ -1955,7 +1958,7 @@ sub openSocket {
|
|||||||
$attr{$name}{protocol} = "TCP" if(AttrVal($name, "protocol", "UDP") ne "TCP");
|
$attr{$name}{protocol} = "TCP" if(AttrVal($name, "protocol", "UDP") ne "TCP");
|
||||||
$sslver = "n.a.";
|
$sslver = "n.a.";
|
||||||
$sslalgo = "n.a.";
|
$sslalgo = "n.a.";
|
||||||
eval "use IO::Socket::SSL"; ##no critic
|
eval "use IO::Socket::SSL"; ## no critic 'eval'
|
||||||
if($@) {
|
if($@) {
|
||||||
$st = "$@";
|
$st = "$@";
|
||||||
} else {
|
} else {
|
||||||
@ -2119,7 +2122,7 @@ sub setPrival {
|
|||||||
|
|
||||||
my $sv = 5; # notice (default)
|
my $sv = 5; # notice (default)
|
||||||
|
|
||||||
if ($vbose) {
|
if (defined $vbose) {
|
||||||
# map verbose to severity
|
# map verbose to severity
|
||||||
$sv = 2 if ($vbose == 0);
|
$sv = 2 if ($vbose == 0);
|
||||||
$sv = 3 if ($vbose == 1);
|
$sv = 3 if ($vbose == 1);
|
||||||
@ -2129,7 +2132,7 @@ sub setPrival {
|
|||||||
$sv = 7 if ($vbose == 5);
|
$sv = 7 if ($vbose == 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lc($txt) =~ m/error/) { # error condition und exludes anwenden
|
if ( lc($txt) =~ m/error/ || (defined $vbose && $vbose =~ /[01]/) ) { # error condition und exludes anwenden
|
||||||
$do = 1;
|
$do = 1;
|
||||||
my $ees = AttrVal($name, "exclErrCond", "");
|
my $ees = AttrVal($name, "exclErrCond", "");
|
||||||
if($ees) {
|
if($ees) {
|
||||||
@ -2144,7 +2147,8 @@ sub setPrival {
|
|||||||
$do = 0 if($txt =~ m/$e/);
|
$do = 0 if($txt =~ m/$e/);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sv = 3 if($do);
|
$sv = 3 if(!defined $vbose && $do);
|
||||||
|
$sv = 5 if(defined $vbose && !$do); # Severity bei fhemLog Einträgen verbose 1 zu 'Notice' ändern
|
||||||
}
|
}
|
||||||
|
|
||||||
$sv = 4 if (lc($txt) =~ m/warning/); # warning conditions
|
$sv = 4 if (lc($txt) =~ m/warning/); # warning conditions
|
||||||
@ -2180,7 +2184,7 @@ sub setPayload {
|
|||||||
$month = $Log2Syslog_BSDMonth{$month}; # Monatsmapping, z.B. 01 -> Jan
|
$month = $Log2Syslog_BSDMonth{$month}; # Monatsmapping, z.B. 01 -> Jan
|
||||||
$day =~ s/0/ / if($day =~ m/^0.*$/x); # in Tagen < 10 muss 0 durch Space ersetzt werden
|
$day =~ s/0/ / if($day =~ m/^0.*$/x); # in Tagen < 10 muss 0 durch Space ersetzt werden
|
||||||
my $tag = substr($ident,0, $RFC3164len{TAG}); # Länge TAG Feld begrenzen
|
my $tag = substr($ident,0, $RFC3164len{TAG}); # Länge TAG Feld begrenzen
|
||||||
no warnings 'uninitialized'; ##no critic
|
no warnings 'uninitialized'; ## no critic 'warnings'
|
||||||
$tag = $tag."[$pid]: ".$cdl; # TAG-Feld um PID und Content-Delimiter ergänzen
|
$tag = $tag."[$pid]: ".$cdl; # TAG-Feld um PID und Content-Delimiter ergänzen
|
||||||
$data = "<$prival>$month $day $time $myhost $tag$otp";
|
$data = "<$prival>$month $day $time $myhost $tag$otp";
|
||||||
use warnings;
|
use warnings;
|
||||||
@ -2202,7 +2206,7 @@ sub setPayload {
|
|||||||
$mid = substr($mid,0, ($RFC5425len{MID}-1));
|
$mid = substr($mid,0, ($RFC5425len{MID}-1));
|
||||||
$myfqdn = substr($myfqdn,0, ($RFC5425len{HST}-1));
|
$myfqdn = substr($myfqdn,0, ($RFC5425len{HST}-1));
|
||||||
|
|
||||||
no warnings 'uninitialized'; ##no critic
|
no warnings 'uninitialized'; ## no critic 'warnings'
|
||||||
if ($IETFver == 1) {
|
if ($IETFver == 1) {
|
||||||
$data = "<$prival>$IETFver $tim $myfqdn $ident $pid $mid $sdfield $cdl$otp";
|
$data = "<$prival>$IETFver $tim $myfqdn $ident $pid $mid $sdfield $cdl$otp";
|
||||||
}
|
}
|
||||||
@ -2346,7 +2350,7 @@ sub evalPeer {
|
|||||||
}
|
}
|
||||||
my ($phost,$paddr,$pport, $pipaddr);
|
my ($phost,$paddr,$pport, $pipaddr);
|
||||||
|
|
||||||
no warnings 'uninitialized'; ##no critic
|
no warnings 'uninitialized'; ## no critic 'warnings'
|
||||||
if($protocol =~ /tcp/) {
|
if($protocol =~ /tcp/) {
|
||||||
$pipaddr = $hash->{HELPER}{TCPPADDR}; # gespeicherte IP-Adresse
|
$pipaddr = $hash->{HELPER}{TCPPADDR}; # gespeicherte IP-Adresse
|
||||||
$phost = $hash->{HIPCACHE}{$pipaddr}; # zuerst IP/Host-Kombination aus Cache nehmen falls vorhanden
|
$phost = $hash->{HIPCACHE}{$pipaddr}; # zuerst IP/Host-Kombination aus Cache nehmen falls vorhanden
|
||||||
@ -2444,7 +2448,7 @@ sub setVersionInfo {
|
|||||||
if(__PACKAGE__ eq "FHEM::$type" || __PACKAGE__ eq $type) {
|
if(__PACKAGE__ eq "FHEM::$type" || __PACKAGE__ eq $type) {
|
||||||
# es wird mit Packages gearbeitet -> Perl übliche Modulversion setzen
|
# es wird mit Packages gearbeitet -> Perl übliche Modulversion setzen
|
||||||
# mit {<Modul>->VERSION()} im FHEMWEB kann Modulversion abgefragt werden
|
# mit {<Modul>->VERSION()} im FHEMWEB kann Modulversion abgefragt werden
|
||||||
use version 0.77; our $VERSION = FHEM::Meta::Get($hash, 'version'); ## no critic
|
use version 0.77; our $VERSION = FHEM::Meta::Get($hash, 'version'); ## no critic 'VERSION'
|
||||||
}
|
}
|
||||||
} else { # herkömmliche Modulstruktur
|
} else { # herkömmliche Modulstruktur
|
||||||
$hash->{VERSION} = $v;
|
$hash->{VERSION} = $v;
|
||||||
@ -2852,9 +2856,9 @@ Aug 18 21:26:54 fhemtest.myds.me 1 2017-08-18T21:26:54 fhemtest.myds.me Test_eve
|
|||||||
attr <name> exclErrCond Error: none,
|
attr <name> exclErrCond Error: none,
|
||||||
Errorcode: none,
|
Errorcode: none,
|
||||||
Dum.Energy PV: 2853.0,, Error: none,
|
Dum.Energy PV: 2853.0,, Error: none,
|
||||||
.*Seek_Error_Rate_.*,
|
Seek_Error_Rate_,
|
||||||
.*Raw_Read_Error_Rate_.*,
|
Raw_Read_Error_Rate_,
|
||||||
.*sabotageError:.*,
|
sabotageError:,
|
||||||
</pre>
|
</pre>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -3626,9 +3630,9 @@ Aug 18 21:26:54 fhemtest.myds.me 1 2017-08-18T21:26:54 fhemtest.myds.me Test_eve
|
|||||||
attr <name> exclErrCond Error: none,
|
attr <name> exclErrCond Error: none,
|
||||||
Errorcode: none,
|
Errorcode: none,
|
||||||
Dum.Energy PV: 2853.0,, Error: none,
|
Dum.Energy PV: 2853.0,, Error: none,
|
||||||
.*Seek_Error_Rate_.*,
|
Seek_Error_Rate_,
|
||||||
.*Raw_Read_Error_Rate_.*,
|
Raw_Read_Error_Rate_,
|
||||||
.*sabotageError:.*,
|
sabotageError:,
|
||||||
</pre>
|
</pre>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user