From 837fdae79c35a19955f742701617afccc7986237 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Thu, 24 Nov 2022 19:48:13 +0000 Subject: [PATCH] fhemdebug: add sizeInFile (Forum #130511) git-svn-id: https://svn.fhem.de/fhem/trunk@26743 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_fhemdebug.pm | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/fhem/FHEM/98_fhemdebug.pm b/fhem/FHEM/98_fhemdebug.pm index b6b5db559..4f0000346 100644 --- a/fhem/FHEM/98_fhemdebug.pm +++ b/fhem/FHEM/98_fhemdebug.pm @@ -15,7 +15,8 @@ sub fhemdebug_Initialize($){ $cmds{"fhemdebug"}{Fn} = "fhemdebug_Fn"; $cmds{"fhemdebug"}{Hlp} = - "{enable | disable | status | timerList | addTimerStacktrace | utf8check}"; + "{enable | disable | status | timerList | ". + "addTimerStacktrace | utf8check | sizeInFile}"; } sub fhemdebug_utf8check($$$$); @@ -82,10 +83,24 @@ fhemdebug_Fn($$) (int(@ret) ? "Strings with utf8-flag set:\n".join("\n", @ret) : "Found no strings with utf8-flag"); + } elsif($param =~ m/^sizeInFile *(\d*)$/) { + my $top = $1 ? $1 : 20; + my %s; + for my $d (keys %defs) { + next if($defs{$d}{TEMPORARY}); + $s{$d} = length(CommandList(undef, "-r $d")); + $s{$d} += length($d)+length($defs{$d}{FUUID})+10 if($defs{$d}{FUUID}); + } + + my $total = 26; + my @out = map { $total += $s{$_}; sprintf("%6d: %s", $s{$_}, $_) } + sort { $s{$b}<=>$s{$a} } keys %s; + return join("\n", @out[0..$top-1])."\nTotal: $total"; + } else { return "Usage: fhemdebug {enable | disable | status | ". "timerList | addTimerStacktrace {0|1} | forceEvents {0|1} | ". - " utf8check }"; + " utf8check | sizeInFile [num] }"; } return; } @@ -233,6 +248,12 @@ fhemdebug_timerList($) call. This stacktrace will be shown in the timerList command. +
  • sizeInFile [<num>]
    + returns the name of the devices requiring the most space in storage. + If [<num>] is omitted, the top 20 is returned.
    + Note: the total wont include the comment lines. +
  • +
  • utf8check
    returns the list of strings with the internal utf8-bit set. Such strings may cause various problems.