Skip to content

[directory-size.sh] Support spaces in paths#239

Merged
dswarbrick merged 3 commits into
prometheus-community:masterfrom
aroberts:dirsize-spaces
Apr 13, 2026
Merged

[directory-size.sh] Support spaces in paths#239
dswarbrick merged 3 commits into
prometheus-community:masterfrom
aroberts:dirsize-spaces

Conversation

@aroberts

Copy link
Copy Markdown
Contributor

The current code emits directory label only up to the first space, due to the default behavior of awk. This change pulls in the rest of the line output from du into the label, so directories containing spaces are properly captured

@dswarbrick

Copy link
Copy Markdown
Member

I was about to suggest using sed instead, e.g.

sed -E 's/^([0-9]+)[[:blank:]](.+)$/node_directory_size_bytes{directory="\2"} \1/'
  • however we also should handle directories with double-quotes in their names. Currently, these would cause malformed metrics to be printed, since the double-quotes need to be escaped.

@aroberts

aroberts commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

@dswarbrick fair enough, implemented both

Comment thread directory-size.sh Outdated
@dswarbrick

Copy link
Copy Markdown
Member

Please sign off your commits to satisfy the DCO.

aroberts added 3 commits April 9, 2026 17:26
Signed-off-by: Andrew Roberts <adroberts@gmail.com>
Signed-off-by: Andrew Roberts <adroberts@gmail.com>
Signed-off-by: Andrew Roberts <adroberts@gmail.com>
@aroberts

aroberts commented Apr 9, 2026

Copy link
Copy Markdown
Contributor Author

removed comment; rebased with signoffs

@dswarbrick dswarbrick merged commit c02b15e into prometheus-community:master Apr 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants