Correct bytes measurements

This commit is contained in:
GRMrGecko 2023-12-29 16:00:40 -06:00
parent 879f02f857
commit be6f63048b
2 changed files with 12 additions and 12 deletions

View File

@ -97,8 +97,8 @@ How did the sync occur, cron job or manually via ssh? This is auto detected and
### dusum_human_readable_total_file ### dusum_human_readable_total_file
Path to save a grand total of each disk usage sum in human readable form. Path to save a grand total of each disk usage sum in human readable form.
### dusum_byte_total_file ### dusum_kbytes_total_file
Path to save a grand total of each disk usage sum in bytes. Path to save a grand total of each disk usage sum in killo bytes.
## Module specific configurations ## Module specific configurations
Each module is configured via configurations prefixed by the module name. The one configuration used by all modules is the `_sync_method` configuration which defines what sync method to use. Each sync method has different configurations available. The default sync method is rsync. Each module is configured via configurations prefixed by the module name. The one configuration used by all modules is the `_sync_method` configuration which defines what sync method to use. Each sync method has different configurations available. The default sync method is rsync.

View File

@ -286,43 +286,43 @@ log_end_header() {
# Build dsum totals files if defined. # Build dsum totals files if defined.
rebuild_dusum_totals() { rebuild_dusum_totals() {
# Rebuild byte total. # Rebuild killo byte total.
if [[ $dusum_byte_total_file ]]; then if [[ $dusum_kbytes_total_file ]]; then
{ {
date date
totalBytes=0 totalKBytes=0
for MODULE in ${MODULES:?}; do for MODULE in ${MODULES:?}; do
eval dusum="\${${MODULE}_dusum:-}" eval dusum="\${${MODULE}_dusum:-}"
if [[ -n $dusum ]]; then if [[ -n $dusum ]]; then
while read -r size path; do while read -r size path; do
if [[ -n $size ]]; then if [[ -n $size ]]; then
totalBytes=$((totalBytes+size)) totalKBytes=$((totalKBytes+size))
printf "%-12s %s\n" "$size" "$path" printf "%-12s %s\n" "$size" "$path"
fi fi
done < "$dusum" done < "$dusum"
fi fi
done done
printf "%-12s %s\n" "$totalBytes" "total" printf "%-12s %s\n" "$totalKBytes" "total"
} > "$dusum_byte_total_file" } > "$dusum_kbytes_total_file"
fi fi
# Rebuild human readable total. # Rebuild human readable total.
if [[ $dusum_human_readable_total_file ]]; then if [[ $dusum_human_readable_total_file ]]; then
{ {
date date
totalBytes=0 totalKBytes=0
for MODULE in ${MODULES:?}; do for MODULE in ${MODULES:?}; do
eval dusum="\${${MODULE}_dusum:-}" eval dusum="\${${MODULE}_dusum:-}"
if [[ -n $dusum ]]; then if [[ -n $dusum ]]; then
while read -r size path; do while read -r size path; do
if [[ -n $size ]]; then if [[ -n $size ]]; then
totalBytes=$((totalBytes+size)) totalKBytes=$((totalKBytes+size))
printf "%-5s %s\n" "$(numfmt --to=iec <<<"$size")" "$path" printf "%-5s %s\n" "$(echo "$size*1024" | bc | numfmt --to=iec)" "$path"
fi fi
done < "$dusum" done < "$dusum"
fi fi
done done
printf "%-5s %s\n" "$(numfmt --to=iec <<<"$totalBytes")" "total" printf "%-5s %s\n" "$(echo "$totalKBytes*1024" | bc | numfmt --to=iec)" "total"
} > "$dusum_human_readable_total_file" } > "$dusum_human_readable_total_file"
fi fi
} }