2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

93_DbRep: fix warnings and minor changes

git-svn-id: https://svn.fhem.de/fhem/trunk@17773 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2018-11-18 07:48:35 +00:00
parent be38579338
commit fe5f348fd3
3 changed files with 47 additions and 14687 deletions

View File

@ -1,7 +1,8 @@
# 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.
- 93_DbLog: V3.13.0, addLog considers DbLogInclude (Forum:#92854), new - change: 93_DbRep: fix warnings and minor changes
attributes traceFlag, traceLevel (only for support !) - change: 93_DbLog: V3.13.0, addLog considers DbLogInclude (Forum:#92854),
new attributes traceFlag, traceLevel (only for support !)
- feature: attrTemplate set command added - feature: attrTemplate set command added
- bugfix: 73_AutoShuttersControl: fix logical bugs, - bugfix: 73_AutoShuttersControl: fix logical bugs,
change Antifreeze values change Antifreeze values

View File

@ -57,6 +57,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
# Versions History intern # Versions History intern
our %DbRep_vNotesIntern = ( our %DbRep_vNotesIntern = (
"8.9.6" => "15.11.2018 fix PERL WARNING: Use of uninitialized value \$fref in pattern match (m//), sub DbRep_sec2hms for hms transforming",
"8.9.5" => "09.11.2018 hash %dbrep_col substituted by get data from dblog device in func DbRep_firstconnect, fix importFromFile contains only SPACE ", "8.9.5" => "09.11.2018 hash %dbrep_col substituted by get data from dblog device in func DbRep_firstconnect, fix importFromFile contains only SPACE ",
"8.9.0" => "07.11.2018 command delDoublets added ", "8.9.0" => "07.11.2018 command delDoublets added ",
"8.8.0" => "06.11.2018 first connect routine switched to DbRep_Main, get COLSET from DBLOG-instance, attribute 'fastStart' added ", "8.8.0" => "06.11.2018 first connect routine switched to DbRep_Main, get COLSET from DBLOG-instance, attribute 'fastStart' added ",
@ -266,6 +267,11 @@ our %DbRep_vHintsExt_de = (
sub DbRep_Main($$;$); sub DbRep_Main($$;$);
sub DbLog_cutCol($$$$$$$); # DbLog-Funktion nutzen um Daten auf maximale Länge beschneiden sub DbLog_cutCol($$$$$$$); # DbLog-Funktion nutzen um Daten auf maximale Länge beschneiden
# Standard Feldbreiten falls noch nicht getInitData ausgeführt
my %dbrep_col = ("DEVICE" => 64,
"READING" => 64,
);
################################################################################### ###################################################################################
# DbRep_Initialize # DbRep_Initialize
################################################################################### ###################################################################################
@ -1218,7 +1224,8 @@ sub DbRep_Attr($$$$) {
} }
if ($aName eq "reading" || $aName eq "device") { if ($aName eq "reading" || $aName eq "device") {
if ($aVal !~ m/,/ && $dbmodel && $dbmodel ne 'SQLITE') { if ($aVal !~ m/,/ && $dbmodel && $dbmodel ne 'SQLITE') {
my $mlen = 64; my $attrname = uc($aName);
my $mlen = $hash->{HELPER}{DBREPCOL}{$attrname}?$hash->{HELPER}{DBREPCOL}{$attrname}:$dbrep_col{$attrname};
return "Length of \"$aName\" is too big. Maximum length for database type $dbmodel is $mlen" if(length($aVal) > $mlen); return "Length of \"$aName\" is too big. Maximum length for database type $dbmodel is $mlen" if(length($aVal) > $mlen);
} }
} }
@ -6172,7 +6179,7 @@ sub DbRep_optimizeTables($) {
$rt = $rt.",".$brt; $rt = $rt.",".$brt;
Log3 ($name, 3, "DbRep $name - Optimize tables of database $dbname finished, total time used: ".sprintf("%.0f",$brt)." sec."); Log3 ($name, 3, "DbRep $name - Optimize tables of database $dbname finished - total time used (hh:mm:ss): ".DbRep_sec2hms($brt));
return "$name|$rt|''|$db_MB_start|$db_MB_end"; return "$name|$rt|''|$db_MB_start|$db_MB_end";
} }
@ -6690,7 +6697,7 @@ sub mysql_DoDumpClientSide($) {
$fsize = encode_base64($fsize,""); $fsize = encode_base64($fsize,"");
} }
Log3 ($name, 3, "DbRep $name - Finished backup of database $dbname, total time used: ".sprintf("%.0f",$brt)." sec."); Log3 ($name, 3, "DbRep $name - Finished backup of database $dbname - total time used (hh:mm:ss): ".DbRep_sec2hms($brt));
return "$name|$rt|''|$dump_path$backupfile|$drc|$drh|$fsize|$ftp|$bfd|$ffd"; return "$name|$rt|''|$dump_path$backupfile|$drc|$drh|$fsize|$ftp|$bfd|$ffd";
} }
@ -6832,10 +6839,12 @@ sub mysql_DoDumpServerSide($) {
my $filesize; my $filesize;
my $fref = stat($dump_path_loc.$bfile); my $fref = stat($dump_path_loc.$bfile);
if ($fref =~ /ARRAY/) { if($fref) {
$filesize = (@{stat($dump_path_loc.$bfile)})[7]; if($fref =~ /ARRAY/) {
} else { $filesize = (@{stat($dump_path_loc.$bfile)})[7];
$filesize = (stat($dump_path_loc.$bfile))[7]; } else {
$filesize = (stat($dump_path_loc.$bfile))[7];
}
} }
Log3 ($name, 3, "DbRep $name - Number of exported datasets: $drh"); Log3 ($name, 3, "DbRep $name - Number of exported datasets: $drh");
@ -6863,7 +6872,7 @@ sub mysql_DoDumpServerSide($) {
$rt = $rt.",".$brt; $rt = $rt.",".$brt;
Log3 ($name, 3, "DbRep $name - Finished backup of database $dbname - total time used: ".sprintf("%.0f",$brt)." seconds"); Log3 ($name, 3, "DbRep $name - Finished backup of database $dbname - total time used (hh:mm:ss): ".DbRep_sec2hms($brt));
return "$name|$rt|''|$dump_path_rem$bfile|n.a.|$drh|$fsize|$ftp|$bfd|$ffd"; return "$name|$rt|''|$dump_path_rem$bfile|n.a.|$drh|$fsize|$ftp|$bfd|$ffd";
} }
@ -6987,7 +6996,7 @@ sub DbRep_sqliteDoDump($) {
$rt = $rt.",".$brt; $rt = $rt.",".$brt;
Log3 ($name, 3, "DbRep $name - Finished backup of database $dbname - total time used: ".sprintf("%.0f",$brt)." seconds"); Log3 ($name, 3, "DbRep $name - Finished backup of database $dbname - total time used (hh:mm:ss): ".DbRep_sec2hms($brt));
return "$name|$rt|''|$dump_path$bfile|n.a.|n.a.|$fsize|$ftp|$bfd|$ffd"; return "$name|$rt|''|$dump_path$bfile|n.a.|n.a.|$fsize|$ftp|$bfd|$ffd";
} }
@ -7155,7 +7164,7 @@ sub DbRep_RepairDone($) {
ReadingsBulkUpdateTimeState($hash,undef,undef,$state); ReadingsBulkUpdateTimeState($hash,undef,undef,$state);
readingsEndUpdate($hash, 1); readingsEndUpdate($hash, 1);
Log3 ($name, 3, "DbRep $name - Database repair $hash->{DATABASE} finished. - total time used: ".sprintf("%.0f",$brt)." seconds."); Log3 ($name, 3, "DbRep $name - Database repair $hash->{DATABASE} finished - total time used (hh:mm:ss): ".DbRep_sec2hms($brt));
return; return;
} }
@ -7233,7 +7242,7 @@ sub DbRep_sqliteRestore ($) {
$rt = $rt.",".$brt; $rt = $rt.",".$brt;
Log3 ($name, 3, "DbRep $name - Restore of $dump_path$bfile into '$dbname' finished - total time used: ".sprintf("%.0f",$brt)." seconds."); Log3 ($name, 3, "DbRep $name - Restore of $dump_path$bfile into '$dbname' finished - total time used (hh:mm:ss): ".DbRep_sec2hms($brt));
return "$name|$rt|''|$dump_path$bfile|n.a."; return "$name|$rt|''|$dump_path$bfile|n.a.";
} }
@ -7307,7 +7316,7 @@ sub mysql_RestoreServerSide($) {
$rt = $rt.",".$brt; $rt = $rt.",".$brt;
Log3 ($name, 3, "DbRep $name - Restore of $dump_path_rem$bfile into '$dbname', '$table' finished - total time used: ".sprintf("%.0f",$brt)." seconds."); Log3 ($name, 3, "DbRep $name - Restore of $dump_path_rem$bfile into '$dbname', '$table' finished - total time used (hh:mm:ss): ".DbRep_sec2hms($brt));
return "$name|$rt|''|$dump_path_rem$bfile|n.a."; return "$name|$rt|''|$dump_path_rem$bfile|n.a.";
} }
@ -8528,6 +8537,20 @@ sub DbRep_trim ($) {
return ($str); return ($str);
} }
####################################################################################################
# Sekunden in Format hh:mm:ss umwandeln
####################################################################################################
sub DbRep_sec2hms ($) {
my $s = shift;
my $hms;
my $hh = sprintf("%02d", int($s/3600));
my $mm = sprintf("%02d", int(($s-($hh*3600))/60));
my $ss = sprintf("%02d", $s-($mm*60)-($hh*3600));
return ("$hh:$mm:$ss");
}
#################################################################################################### ####################################################################################################
# Check ob Zeitgrenzen bzw. Aggregation gesetzt sind, evtl. übertseuern (je nach Funktion) # Check ob Zeitgrenzen bzw. Aggregation gesetzt sind, evtl. übertseuern (je nach Funktion)
# Return "1" wenn Bedingung erfüllt, sonst "0" # Return "1" wenn Bedingung erfüllt, sonst "0"
@ -9217,12 +9240,14 @@ sub DbRep_deldumpfiles ($$) {
my $fref = stat("$dump_path_loc/$bfile"); my $fref = stat("$dump_path_loc/$bfile");
if ($fref =~ /ARRAY/) { if($fref) {
@files = sort { (@{stat("$dump_path_loc/$a")})[9] cmp (@{stat("$dump_path_loc/$b")})[9] } @files if ($fref =~ /ARRAY/) {
if(AttrVal("global", "archivesort", "alphanum") eq "timestamp"); @files = sort { (@{stat("$dump_path_loc/$a")})[9] cmp (@{stat("$dump_path_loc/$b")})[9] } @files
} else { if(AttrVal("global", "archivesort", "alphanum") eq "timestamp");
@files = sort { (stat("$dump_path_loc/$a"))[9] cmp (stat("$dump_path_loc/$b"))[9] } @files } else {
if(AttrVal("global", "archivesort", "alphanum") eq "timestamp"); @files = sort { (stat("$dump_path_loc/$a"))[9] cmp (stat("$dump_path_loc/$b"))[9] } @files
if(AttrVal("global", "archivesort", "alphanum") eq "timestamp");
}
} }
closedir(DH); closedir(DH);

File diff suppressed because it is too large Load Diff