Open macropin opened 5 years ago
The exit 0
overriedes the last exit code, which is call to the logging facility (systemd-cat, cat, logger), so I'm not sure this is what your monitoring is interested in. Catching the error code of the previous comand group (calling btrfs) can be extracted from PIPESTATUS though.
Adding set -e
makes sense, though not all errors are fatal. The balance tries to make the space more compact but may not succeed. But this is the message you posted as an example so I guess you want to see that anyway.
These scripts don't handle errors. Please consider
set -e
at the top of each script so that error conditions will be trapped. Theexit 0
at the bottom of each script can also be removed as it's redundant.Use case / justification:
We monitor
btrfs-balance.service
, however when an error condition is encountered the script returns with an exit code of0
even though the balance failed:ERROR: error during balancing '/backup': No space left on device There may be more info in syslog - try dmesg | tail