Skip to content

Commit e53e704

Browse files
committed
[directory-size.sh] support spaces in paths
Signed-off-by: Andrew Roberts <adroberts@gmail.com>
1 parent b323e37 commit e53e704

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

directory-size.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
#
77
# */5 * * * * prometheus directory-size.sh /var/lib/prometheus | sponge /var/lib/node_exporter/directory_size.prom
88
#
9+
# awk logic from by https://stackoverflow.com/a/10221507
10+
#
911
# Author: Antoine Beaupré <anarcat@debian.org>
1012

1113
echo "# HELP node_directory_size_bytes Disk space used by some directories"
1214
echo "# TYPE node_directory_size_bytes gauge"
1315
du --block-size=1 --summarize "$@" \
14-
| awk '{ print "node_directory_size_bytes{directory=\"" $2 "\"} " $1 }'
16+
| awk '{ sz = $1; $1 = ""; print "node_directory_size_bytes{directory=\"" substr($0, 2) "\"} " sz }'

0 commit comments

Comments
 (0)