fix: enforce output of df to be single-lined per file system

This change forces `df(1)` to output each file system on a single
line by setting the `-P` flag (POSIX output format). Without it,
some versions of `df(1)` split the output into multiple lines if the
length of some fields like "Filesystem" exceeds a certain limit. As a
consequence, the `awk(1)` expression might fail to catch the correct
fields.

Please note that this fixes a file which is also wrongly named, which is
being addressed in PR #151.

Relates to PR #151.
Fixes issue #137.
This commit is contained in:
Christoph Schug 2024-02-23 00:05:50 +01:00
parent ca1b5cf74e
commit 65b172436f

View File

@ -6,7 +6,7 @@
command: df -h
register: disk_usage
- name: check disk space available
shell: df -h / | awk 'NR==2 {print $5}'
shell: df -Ph / | awk 'NR==2 {print $5}'
register: disk_usage
# - name: send discord message when disk space is over 80%
# uri: