mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +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:
parent
097fe1830d
commit
837fdae79c
@ -15,7 +15,8 @@ sub
|
|||||||
fhemdebug_Initialize($){
|
fhemdebug_Initialize($){
|
||||||
$cmds{"fhemdebug"}{Fn} = "fhemdebug_Fn";
|
$cmds{"fhemdebug"}{Fn} = "fhemdebug_Fn";
|
||||||
$cmds{"fhemdebug"}{Hlp} =
|
$cmds{"fhemdebug"}{Hlp} =
|
||||||
"{enable | disable | status | timerList | addTimerStacktrace | utf8check}";
|
"{enable | disable | status | timerList | ".
|
||||||
|
"addTimerStacktrace | utf8check | sizeInFile}";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub fhemdebug_utf8check($$$$);
|
sub fhemdebug_utf8check($$$$);
|
||||||
@ -82,10 +83,24 @@ fhemdebug_Fn($$)
|
|||||||
(int(@ret) ? "Strings with utf8-flag set:\n".join("\n", @ret) :
|
(int(@ret) ? "Strings with utf8-flag set:\n".join("\n", @ret) :
|
||||||
"Found no strings with utf8-flag");
|
"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 {
|
} else {
|
||||||
return "Usage: fhemdebug {enable | disable | status | ".
|
return "Usage: fhemdebug {enable | disable | status | ".
|
||||||
"timerList | addTimerStacktrace {0|1} | forceEvents {0|1} | ".
|
"timerList | addTimerStacktrace {0|1} | forceEvents {0|1} | ".
|
||||||
" utf8check }";
|
" utf8check | sizeInFile [num] }";
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -233,6 +248,12 @@ fhemdebug_timerList($)
|
|||||||
call. This stacktrace will be shown in the timerList command.
|
call. This stacktrace will be shown in the timerList command.
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<li>sizeInFile [<num>]<br>
|
||||||
|
returns the name of the devices requiring the most space in storage.
|
||||||
|
If [<num>] is omitted, the top 20 is returned.<br>
|
||||||
|
Note: the total wont include the comment lines.
|
||||||
|
</li>
|
||||||
|
|
||||||
<li>utf8check<br>
|
<li>utf8check<br>
|
||||||
returns the list of strings with the internal utf8-bit set.
|
returns the list of strings with the internal utf8-bit set.
|
||||||
Such strings may cause various problems.
|
Such strings may cause various problems.
|
||||||
|
Loading…
Reference in New Issue
Block a user