Révision a2f1592f
systemd_units: avoid use of temporary file
| plugins/system/systemd_units | ||
|---|---|---|
| 60 | 60 |
} |
| 61 | 61 |
|
| 62 | 62 |
fetch () {
|
| 63 |
tmp=$(mktemp -t munin-systemd_units.XXXXXX) |
|
| 64 |
trap "rm \"$tmp\"" EXIT |
|
| 65 |
systemctl --no-pager --no-legend --all | awk '{print $1, $3}' > "$tmp"
|
|
| 63 |
tmp=$(systemctl --no-pager --no-legend --all | awk '{print $1, $3}')
|
|
| 66 | 64 |
for state in \ |
| 67 | 65 |
$states ; do |
| 68 | 66 |
echo -n "$state.value " |
| 69 |
grep -c "$state$" "$tmp"
|
|
| 70 |
extinfo=$(grep "$state$" "$tmp" | cut -d " " -f 1)
|
|
| 67 |
echo "$tmp" | grep -c "$state$"
|
|
| 68 |
extinfo=$(echo "$tmp" | grep "$state$" | cut -d " " -f 1)
|
|
| 71 | 69 |
if [ -n "$extinfo" ]; then |
| 72 | 70 |
echo "$state.extinfo" $extinfo |
| 73 | 71 |
fi |
Formats disponibles : Unified diff