Skip to content

Commit 8f40e76

Browse files
committed
Available space in %
1 parent ba18edf commit 8f40e76

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2022-08-31 Matteo Corti <[email protected]>
2+
3+
* tmstatus.sh: Available space in %
4+
15
2022-08-18 Matteo Corti <[email protected]>
26

37
* tmstatus.sh (status): Parse LazyThinning

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* 2022-08-31, Version 1.7.0
2+
* Available space in %
13
* 2022-08-17, Version 1.6.0
24
* Corrected the backup size computation
35
* 2021-11-15, Version 1.5.0

RELEASE_NOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Corrected the backup size computation
1+
Available space in %

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.6.0
1+
1.7.0

tmstatus.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#
1313

1414
# shellcheck disable=SC2034
15-
VERSION=1.6.0
15+
VERSION=1.7.0
1616

1717
export LC_ALL=C
1818

@@ -125,10 +125,16 @@ elif tmutil listbackups 2>&1 | grep -q 'No backups found for host.'; then
125125
else
126126

127127
tm_mount_point=$(tmutil destinationinfo | grep '^Mount\ Point' | sed 's/.*:\ //')
128+
128129
tm_total=$(df -H "${tm_mount_point}" | tail -n 1 | awk '{ print $2 "\t" }' | sed 's/[[:blank:]]//g')
129130
tm_available=$(df -H "${tm_mount_point}" | tail -n 1 | awk '{ print $4 "\t" }' | sed 's/[[:blank:]]//g')
130-
printf '%s: %s (%s available)\n' "${tm_mount_point}" "${tm_total}" "${tm_available}"
131131

132+
tm_total_raw=$(df "${tm_mount_point}" | tail -n 1 | awk '{ print $2 "\t" }' | sed 's/[[:blank:]]//g')
133+
tm_available_raw=$(df "${tm_mount_point}" | tail -n 1 | awk '{ print $4 "\t" }' | sed 's/[[:blank:]]//g')
134+
tm_percent_available=$(echo "${tm_available_raw} * 100 / ${tm_total_raw}" | bc)
135+
136+
printf '%s: %s (%s available, %s%%)\n' "${tm_mount_point}" "${tm_total}" "${tm_available}" "${tm_percent_available}"
137+
132138
DATE="$(tmutil listbackups | head -n 1 | sed 's/.*\///' | sed 's/[.].*//')"
133139
days="$(days_since "${DATE}")"
134140
backup_date=$(tmutil listbackups | head -n 1 | sed 's/.*\///' | sed 's/[.].*//' | sed 's/-\([^\-]*\)$/\ \1/' | sed 's/\([0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)/\1:\2:\3/')
@@ -161,7 +167,12 @@ if tmutil listlocalsnapshotdates / 2>&1 | grep -q '[0-9]'; then
161167

162168
tm_total=$(df -H / | tail -n 1 | awk '{ print $2 "\t" }' | sed 's/[[:blank:]]//g')
163169
tm_available=$(df -H / | tail -n 1 | awk '{ print $4 "\t" }' | sed 's/[[:blank:]]//g')
164-
printf 'Local: %s (%s available)\n' "${tm_total}" "${tm_available}"
170+
171+
tm_total_raw=$(df / | tail -n 1 | awk '{ print $2 "\t" }' | sed 's/[[:blank:]]//g')
172+
tm_available_raw=$(df / | tail -n 1 | awk '{ print $4 "\t" }' | sed 's/[[:blank:]]//g')
173+
tm_percent_available=$(echo "${tm_available_raw} * 100 / ${tm_total_raw}" | bc)
174+
175+
printf 'Local: %s (%s available, %s%%)\n' "${tm_total}" "${tm_available}" "${tm_percent_available}"
165176
printf 'Local oldest:\t'
166177
tmutil listlocalsnapshotdates / | sed -n 2p | sed 's/-\([^\-]*\)$/\ \1/' | sed 's/\([0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)/\1:\2:\3/'
167178

0 commit comments

Comments
 (0)