Add process status handling

This commit is contained in:
Salt 2020-09-28 15:15:55 -05:00
parent 77ece8b2ef
commit abdb942772

View File

@ -227,6 +227,34 @@ fsstatus() {
printf "$errorline\n"
fi
fi
# Service information
if [ -d "$_optrundir" ]; then
for pidfile in "$_optrundir"/*.pid; do
local name="$(basename -- "$pidfile" .pid)"
local pid="$(< "$pidfile")"
local len=16
local status
local description
if [ -z "$pid" ]; then
# PID is empty
status="\e[31m○\e[0m"
description="No PID"
elif ! [ "$pid" -gt 0 ] 2> /dev/null; then
# PID is not a number greater than 0
status="\e[31m○\e[0m"
description="Invalid PID ($pid)"
elif ! [ -d "/proc/$pid" ]; then
# PID is valid, but does not exist in /proc (i.e. is dead)
status="\e[31m●\e[0m"
description="Dead (PID $pid)"
else
# PID is good, time for secondary validation
status="\e[32m●\e[0m"
description="Running (PID $pid)"
fi
printf "\t$status %-${len}.${len}s $description\n" "$name"
done
fi
}
step_preexecute() {
# Special things that can't use simple configuration files