Révision b5595716
systemd_mem: fix handling unlimited number on debian stretch
| plugins/systemd/systemd_mem | ||
|---|---|---|
| 58 | 58 |
|
| 59 | 59 |
. "$MUNIN_LIBDIR/plugins/plugin.sh" |
| 60 | 60 |
|
| 61 |
# at least on debian stretch services report this as unlimited / unknown value (2^64) |
|
| 62 |
# see https://lists.freedesktop.org/archives/systemd-devel/2018-July/041092.html |
|
| 63 |
SYSTEMD_UNLIMITED="18446744073709551615" |
|
| 64 |
|
|
| 65 |
all_services=${all_services:-}
|
|
| 66 |
services=${services:-"munin-node"}
|
|
| 67 |
|
|
| 61 | 68 |
for_services() {
|
| 62 | 69 |
if [ "$all_services" != "" ]; then |
| 63 | 70 |
systemctl --type=service --state=running --no-pager --no-legend --output=short-precise \ |
| 64 | 71 |
| awk '{sub(".service$", "", $1); print $1}'
|
| 65 | 72 |
else |
| 66 |
echo ${services:-"munin-node"}
|
|
| 73 |
echo "$services"
|
|
| 67 | 74 |
fi |
| 68 | 75 |
} |
| 69 | 76 |
|
| ... | ... | |
| 75 | 82 |
echo "graph_category memory" |
| 76 | 83 |
for service in $(for_services); do |
| 77 | 84 |
clean_name="$(clean_fieldname "$service")" |
| 78 |
description=$(systemctl show "$service" --property=Description | cut -d '=' -f 2) |
|
| 85 |
description=$(systemctl show "$service" --property=Description | cut -d '=' -f 2-)
|
|
| 79 | 86 |
warning=$(systemctl show "$service" --property=MemoryHigh | cut -d '=' -f 2) |
| 80 | 87 |
critical=$(systemctl show "$service" --property=MemoryMax | cut -d '=' -f 2) |
| 81 |
if [ "$critical" = "infinity" ] ; then |
|
| 88 |
if [ "$critical" = "infinity" ] || [ "$critical" = "$SYSTEMD_UNLIMITED" ] ; then
|
|
| 82 | 89 |
critical=$(systemctl show "$service" --property=MemoryLimit | cut -d '=' -f 2) |
| 83 | 90 |
fi |
| 84 | 91 |
printf "%s.label %s\n" "$clean_name" "$description" |
| 85 | 92 |
printf "%s.info memory usage\n" "$clean_name" |
| 86 |
if [ "$warning" != "infinity" ] ; then |
|
| 93 |
if [ "$warning" != "infinity" ] && [ "$warning" != "$SYSTEMD_UNLIMITED" ] ; then
|
|
| 87 | 94 |
printf "%s.warning %s\n" "$clean_name" "$warning" |
| 88 | 95 |
fi |
| 89 |
if [ "$critical" != "infinity" ] ; then |
|
| 96 |
if [ "$critical" != "infinity" ] && [ "$critical" != "$SYSTEMD_UNLIMITED" ] ; then
|
|
| 90 | 97 |
printf "%s.critical %s\n" "$clean_name" "$critical" |
| 91 | 98 |
fi |
| 92 | 99 |
done |
| ... | ... | |
| 96 | 103 |
for service in $(for_services); do |
| 97 | 104 |
clean_name="$(clean_fieldname "$service")" |
| 98 | 105 |
usage=$(systemctl show "$service" --property=MemoryCurrent | cut -d '=' -f 2) |
| 99 |
if [ "$usage" = "[not set]" ]; then |
|
| 100 |
usage=0
|
|
| 106 |
if [ "$usage" = "[not set]" ] || [ "$usage" = "$SYSTEMD_UNLIMITED" ]; then
|
|
| 107 |
usage="U"
|
|
| 101 | 108 |
fi |
| 102 |
printf "%s.value %d\n" "$clean_name" "$usage"
|
|
| 109 |
printf "%s.value %s\n" "$clean_name" "$usage"
|
|
| 103 | 110 |
done |
| 104 | 111 |
} |
| 105 | 112 |
|
Formats disponibles : Unified diff