From 161f2bb534a69be6be336c30d88c1aa0bcccad26 Mon Sep 17 00:00:00 2001 From: Kael Shipman Date: Wed, 17 Oct 2018 17:10:21 -0500 Subject: [PATCH 1/3] 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 } From e4e5d3631c06801dcd0127e9e7e926906f9f5849 Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Wed, 17 Oct 2018 20:28:04 -0500 Subject: [PATCH 2/3] Accepted suggestion from maintainer --- plugins/systemd/systemd_units | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/systemd/systemd_units b/plugins/systemd/systemd_units index a8bd3409..5d5f15f4 100755 --- a/plugins/systemd/systemd_units +++ b/plugins/systemd/systemd_units @@ -37,7 +37,7 @@ GPLv2 =cut -. $MUNIN_LIBDIR/plugins/plugin.sh +. "$MUNIN_LIBDIR/plugins/plugin.sh" states="active \ reloading \ From eda5c9b4b4a83c47d83b3e66e6592ab809df6b96 Mon Sep 17 00:00:00 2001 From: Kael Shipman Date: Wed, 17 Oct 2018 20:32:44 -0500 Subject: [PATCH 3/3] Implemented minor changes as suggested by maintainer --- plugins/systemd/systemd_units | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/systemd/systemd_units b/plugins/systemd/systemd_units index 5d5f15f4..dc12d463 100755 --- a/plugins/systemd/systemd_units +++ b/plugins/systemd/systemd_units @@ -21,6 +21,9 @@ reloading, inactive, failed, activating, deactivating) like so: env.failed_critical 5 env.inactive_warning 10 env.inactive_critical 20 + +Note that for failed units, default warning and critical values are set to 0 and 10, respectively. No other +states have default levels set. =head1 AUTHOR @@ -39,6 +42,9 @@ GPLv2 . "$MUNIN_LIBDIR/plugins/plugin.sh" +failed_warning="${failed_warning:-0}" +failed_critical="${failed_critical:-10}" + states="active \ reloading \ inactive \ @@ -61,14 +67,8 @@ 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 - failed_warning="${failed_warning:-0}" print_warning $state - failed_critical="${failed_critical:-10}" print_critical $state - else - print_warning $state - print_critical $state - fi + print_warning $state + print_critical $state done }