#!/bin/bash # config DIR="/archive/obj/cssap" # coloring RED="$(tput setaf 1)" GREEN="$(tput setaf 2)" SGR0="$(tput sgr0)" BOLD="$(tput bold)" echo "NIoP --> No instance on port" echo "WIoP --> Wrong instance on port" tput bold; tput setaf 6; echo 'STATUS ARCHWIN_PORT WEBPORT INSTANCE'; tput sgr0 while read INIFILE; do while read KEY VALUE; do case $KEY in 'ARCHWIN_PORT') ARCHWIN_PORT="$VALUE" ;; 'WEBPORT') WEBPORT="$VALUE" ;; esac done < "$INIFILE" STATUS="${GREEN} OK${SGR0}" read PID __ < <(fuser 2>&- "${ARCHWIN_PORT}/tcp") INIFILE="${INIFILE##*/}" if [[ -z $PID ]]; then # No instance on port STATUS="${RED}${BOLD} NIoP${SGR0}" else read CMD < <(ps -p "$PID" -o cmd=) [[ $CMD == *$INIFILE ]] ||\ # Wrong instance on port STATUS="${RED}${BOLD} WIoP${SGR0}" fi printf '%s %12s %7s %s\n' \ "${STATUS}" \ "${ARCHWIN_PORT}" \ "${WEBPORT}" \ "${INIFILE##*/}" done < \ <(find "$DIR" -type f -regex '.*archint\.ini\.[^.]+') |