1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 14:16:00 +00:00

systemd_units: avoid use of temporary file

This commit is contained in:
Tomaz Solc 2016-10-27 17:49:03 +02:00
parent b31b861f1c
commit a2f1592fe5

View file

@ -60,14 +60,12 @@ EOF
} }
fetch () { fetch () {
tmp=$(mktemp -t munin-systemd_units.XXXXXX) tmp=$(systemctl --no-pager --no-legend --all | awk '{print $1, $3}')
trap "rm \"$tmp\"" EXIT
systemctl --no-pager --no-legend --all | awk '{print $1, $3}' > "$tmp"
for state in \ for state in \
$states ; do $states ; do
echo -n "$state.value " echo -n "$state.value "
grep -c "$state$" "$tmp" echo "$tmp" | grep -c "$state$"
extinfo=$(grep "$state$" "$tmp" | cut -d " " -f 1) extinfo=$(echo "$tmp" | grep "$state$" | cut -d " " -f 1)
if [ -n "$extinfo" ]; then if [ -n "$extinfo" ]; then
echo "$state.extinfo" $extinfo echo "$state.extinfo" $extinfo
fi fi