Skip to content
Snippets Groups Projects
Commit 5da2f05e authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update detection of multiple systemd units

parent bb1213ae
No related branches found
No related tags found
1 merge request!2046784 detect multiple systemd instances
...@@ -11,11 +11,12 @@ ...@@ -11,11 +11,12 @@
# 2020-09-18 v1.4 <axel.hahn@unibe.ch> replace pipes in systemctl status output # 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-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-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 . $( dirname $0 )/inc_pluginfunctions
export self_APPVERSION=1.6 export self_APPVERSION=1.7
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# FUNCTIONS # FUNCTIONS
...@@ -151,9 +152,8 @@ typeset -i _iActive; _iActive=$( grep -c "Active: active (running) " <<< "${_ ...@@ -151,9 +152,8 @@ typeset -i _iActive; _iActive=$( grep -c "Active: active (running) " <<< "${_
if [ $_iActive -eq 0 ]; then if [ $_iActive -eq 0 ]; then
ph.setStatus critical ph.setStatus critical
else else
# when unit contains a @ char and * then check multiple instances of a service typeset -i _iInstances; _iInstances=$( grep -c "Loaded: " <<< "${_data}" )
if grep "@\*" <<< "$_unit" >/dev/null; then if [ $_iInstances -gt 0 ]; then
typeset -i _iInstances; _iInstances=$( grep -c "Loaded: .*@" <<< "${_data}" )
_status="$_iActive of $_iInstances ${_unit} units are active" _status="$_iActive of $_iInstances ${_unit} units are active"
_out="$_data" _out="$_data"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment