Skip to content
Snippets Groups Projects

6784 detect multiple systemd instances

Merged Hahn Axel (hahn) requested to merge 6784-detect-multiple-systemd-instances into master
1 file
+ 4
4
Compare changes
  • Side-by-side
  • Inline
+ 4
4
@@ -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"
Loading