2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

fhemdebug: add sizeInFile (Forum #130511)

git-svn-id: https://svn.fhem.de/fhem/trunk@26743 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2022-11-24 19:48:13 +00:00
parent 097fe1830d
commit 837fdae79c

View File

@ -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.
</li>
<li>sizeInFile [&lt;num&gt;]<br>
returns the name of the devices requiring the most space in storage.
If [&lt;num&gt;] is omitted, the top 20 is returned.<br>
Note: the total wont include the comment lines.
</li>
<li>utf8check<br>
returns the list of strings with the internal utf8-bit set.
Such strings may cause various problems.