From 161f2bb534a69be6be336c30d88c1aa0bcccad26 Mon Sep 17 00:00:00 2001 From: Kael Shipman Date: Wed, 17 Oct 2018 17:10:21 -0500 Subject: [PATCH] Added print_{warning,critical} for greater flexibility Updated to allow admin to set custom values for warning and critical levels for all `$state` fields. --- plugins/systemd/systemd_units | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/systemd/systemd_units b/plugins/systemd/systemd_units index 33e59115..a8bd3409 100755 --- a/plugins/systemd/systemd_units +++ b/plugins/systemd/systemd_units @@ -13,7 +13,14 @@ Linux systems with systemd installed. =head1 CONFIGURATION -None needed. +None needed. You may optionally pass warning and critical values for any of the possible states (active, +reloading, inactive, failed, activating, deactivating) like so: + + [systemd_units] + env.failed_warning 0 + env.failed_critical 5 + env.inactive_warning 10 + env.inactive_critical 20 =head1 AUTHOR @@ -30,6 +37,8 @@ GPLv2 =cut +. $MUNIN_LIBDIR/plugins/plugin.sh + states="active \ reloading \ inactive \ @@ -52,9 +61,13 @@ EOF for state in $states; do echo "$state.label $state" echo "$state.draw AREASTACK" + # Set default alert levels for failed units if [ "$state" = "failed" ]; then - echo "$state.warning 0" - echo "$state.critical 10" + failed_warning="${failed_warning:-0}" print_warning $state + failed_critical="${failed_critical:-10}" print_critical $state + else + print_warning $state + print_critical $state fi done }