diff --git a/check_systemdunit b/check_systemdunit index c54b275cb87e07b297935aa24ec8b9a9b1e826c7..aeb35b1b79e65487bb433a88e4a6be1bc881bfd8 100755 --- a/check_systemdunit +++ b/check_systemdunit @@ -11,11 +11,12 @@ # 2020-09-18 v1.4 <axel.hahn@unibe.ch> replace pipes in systemctl status output # 2020-10-20 v1.5 <axel.hahn@unibe.ch> remove special chars from systemd status # 2020-10-23 v1.6 <axel.hahn@unibe.ch> handle units with multiple instrances +# 2020-11-03 v1.7 <axel.hahn@unibe.ch> autodetect multiple instances without @ char in unit name # ================================================================================ . $( dirname $0 )/inc_pluginfunctions -export self_APPVERSION=1.6 +export self_APPVERSION=1.7 # ---------------------------------------------------------------------- # FUNCTIONS @@ -151,9 +152,8 @@ typeset -i _iActive; _iActive=$( grep -c "Active: active (running) " <<< "${_ if [ $_iActive -eq 0 ]; then ph.setStatus critical else - # when unit contains a @ char and * then check multiple instances of a service - if grep "@\*" <<< "$_unit" >/dev/null; then - typeset -i _iInstances; _iInstances=$( grep -c "Loaded: .*@" <<< "${_data}" ) + typeset -i _iInstances; _iInstances=$( grep -c "Loaded: " <<< "${_data}" ) + if [ $_iInstances -gt 0 ]; then _status="$_iActive of $_iInstances ${_unit} units are active" _out="$_data"