diff --git a/sats/sysd b/sats/sysd index 654d579..6832eec 100644 --- a/sats/sysd +++ b/sats/sysd @@ -16,13 +16,12 @@ source $ROOT/com/config_sats; # (2) Start daemon #--------------------------------------------------------# -SERV_LIST="ls /lib/systemd/system/sats-*"; +SERV_LIST="`systemctl list-units --plain | grep 'sats' | grep -v '.slice' | awk '{print $1}'`"; while sleep 1; do - for i in $SERV_LIST; do + for serv in $SERV_LIST; do - status="`systemctl is-active $(basename $i)`"; - serv="`basename $i`"; + status="`systemctl is-active $(basename $serv)`"; if [ "$status" = "failed" ]; then echo "SYSD0$serv" >> $BUF_OUT; diff --git a/sub-view/systemd b/sub-view/systemd index a7f7e5c..bf16406 100755 --- a/sub-view/systemd +++ b/sub-view/systemd @@ -29,15 +29,30 @@ while sleep 1; clear; do # (5) Store each service # while IFS= read -r line; do - SERV["${line:1}"]="${line:0:1}"; + test "`echo -ne $line | wc -m`" -ge 5 && SERV["${line:1}"]="${line:0:1}"; done <<< "$SERV_LIST"; # (6) Display each service # for s in "${!SERV[@]}"; do + # if failed -> red + if [ "${SERV[$s]}" = "0" ]; then + echo -e "(${SERV[$s]}) \e[31m$s\e[0m"; + + # if activating -> orange + elif [ "${SERV[$s]}" = "2" ]; then + echo -e "(${SERV[$s]}) \e[33m$s\e[0m"; + # if active -> green - test "${SERV[$s]}" = "1" && echo -e "\e[32m$s\e[0m" || echo -e "\e[0m$s\e[0m"; + elif [ "${SERV[$s]}" = "3" ]; then + echo -e "(${SERV[$s]}) \e[32m$s\e[0m"; + + # if inactive -> grey + else + echo -e "(${SERV[$s]}) \e[90m$s\e[0m"; + + fi; done;