else 조건은 bash 스크립트에 표시되지 않습니다

else 조건은 bash 스크립트에 표시되지 않습니다

누구든지 이 문제를 해결하도록 도와줄 수 있나요?

이 스크립트는 여러 서버를 모니터링하고 로그에서 해당 오류 상태를 표시하기 위한 것입니다. 다른 서버에서 사용하는 것과 동일한 논리이지만 작동하고 있으며 동일하게 인코딩되었더라도 작동하지 않는 것이 있습니다.

여기서 일어나는 일은 경고 상태를 추출했지만 경고가 모든 if 조건을 만족하지 않는 경우, else 조건에서 마지막 부분인 경고 없음 상태를 표시하지 않는다는 것입니다. 공백으로 표시됩니다. 도움을 주셔서 미리 감사드립니다.

for ((i=0;i<${#arrPNMIP[@]};++i)); do

ssh -o ConnectTimeout=30 ${arrPNMIP[i]} cat /logs/notificationmanager.log |
    grep -i ALARM | grep ${_date}T${_hour} |
    tail -1 > ${_dir}overload_${arrPNMHOST[i]}.txt
ssh -o ConnectTimeout=30 ${arrPNMIP[i]} cat /logs/notificationmanager.log |
    grep 'disconnectUnsafe disconnected host' | grep ${_date}T${_hour} |
    tail -1 > ${_dir}DCHU_${arrPNMHOST[i]}.txt


_count=$(wc -l ${_dir}overload_${arrPNMHOST[i]}.txt | awk '{print $1}')
_timestamp=$(cat ${_dir}overload_${arrPNMHOST[i]}.txt | awk '{print $1}' |
    tail -1 | cut -c 10-13)
_typeR=$(cat ${_dir}overload_${arrPNMHOST[i]}.txt | grep RAISED | wc -l)
_typeC=$(cat ${_dir}overload_${arrPNMHOST[i]}.txt | grep CEASED | wc -l)
_overload=$(cat ${_dir}overload_${arrPNMHOST[i]}.txt | grep -i overload | wc -l)
_sftp=$(cat ${_dir}overload_${arrPNMHOST[i]}.txt | grep -i sftp | wc -l)
_linkbus=$(cat ${_dir}overload_${arrPNMHOST[i]}.txt | grep -i linkbus | wc -l)
_dbconn=$(cat ${_dir}overload_${arrPNMHOST[i]}.txt | grep -i dbconn | wc -l)
_hbmgr=$(cat ${_dir}overload_${arrPNMHOST[i]}.txt | grep -i hbmgr | wc -l)

_DChostUnsafeCount=$(cat ${_dir}DCHU_${arrPNMHOST[i]}.txt |
    grep 'disconnectUnsafe disconnected host' | wc -l)
_dcIPhostUnsafe=$(cat ${_dir}DCHU_${arrPNMHOST[i]}.txt |
    grep 'disconnectUnsafe disconnected host' | awk -F " " '{print $8}' |
    cut -c 2-14 )


#echo ""

if (( ${_count[@]} >= 1)) || (( ${_DChostUnsafeCount[@]} >= 1));
then
  if (( ${_typeR[@]} >= 1)) && (( ${_overload[@]} >= 1 ));
  then
    echo -e "${arrPNMHOST[i]} ${arrPNM[i]}:${BG_RED}${F_BLACK}RAISED ALARM "\
"OVERLOAD at ${_timestamp}${BG_NC}"
  fi
  if (( ${_typeR[@]} >= 1)) && (( ${_sftp[@]} >= 1 ));
  then
    echo -e "${arrPNMHOST[i]} ${arrPNM[i]}:${BG_RED}${F_BLACK}RAISED ALARM "\
"SFTP at ${_timestamp}${BG_NC}"
  fi
  if (( ${_typeR[@]} >= 1)) && (( ${_linkbus[@]} >= 1 ));
  then
    echo -e "${arrPNMHOST[i]} ${arrPNM[i]}:${BG_RED}${F_BLACK}RAISED ALARM "\
"LINKBUS at ${_timestamp}${BG_NC}"
  fi
  if (( ${_typeR[@]} >= 1)) && (( ${_dbconn[@]} >= 1 ));
  then
    echo -e "${arrPNMHOST[i]} ${arrPNM[i]}:${BG_RED}${F_BLACK}RAISED ALARM "\
"DBCONN at ${_timestamp}${BG_NC}"
  fi
  if (( ${_typeR[@]} >= 1)) && (( ${_hbmgr[@]} >= 1 ));
  then
    echo -e "${arrPNMHOST[i]} ${arrPNM[i]}:${BG_RED}${F_BLACK}RAISED ALARM "\
"HBMGR at ${_timestamp}${BG_NC}"
  fi
  if (( ${_DChostUnsafeCount[@]} >= 1 ));
  then
    echo -e "${arrPNMHOST[i]} ${arrPNM[i]}:${BG_RED}${F_BLACK}Disconnected "\
"Host with IP:${_dcIPhostUnsafe} at ${_timestamp}${BG_NC}"
  fi

  if (( ${_typeC[@]} >= 1)) && (( ${_overload[@]} >= 1 ));
  then
    echo -e "${arrPNMHOST[i]} ${arrPNM[i]}:${BG_YELLOW}${F_BLACK}CEASED ALARM "\
"OVERLOAD at ${_timestamp}${BG_NC}"
  fi
  if (( ${_typeC[@]} >= 1)) && (( ${_sftp[@]} >= 1 ));
  then
    echo -e "${arrPNMHOST[i]} ${arrPNM[i]}:${BG_YELLOW}${F_BLACK}CEASED ALARM "\
"SFTP at ${_timestamp}${BG_NC}"
  fi
  if (( ${_typeC[@]} >= 1)) && (( ${_linkbus[@]} >= 1 ));
  then
    echo -e "${arrPNMHOST[i]} ${arrPNM[i]}:${BG_YELLOW}${F_BLACK}CEASED ALARM "\
"LINKBUS at ${_timestamp}${BG_NC}"
  fi
  if (( ${_typeC[@]} >= 1)) && (( ${_dbconn[@]} >= 1 ));
  then
    echo -e "${arrPNMHOST[i]} ${arrPNM[i]}:${BG_YELLOW}${F_BLACK}CEASED ALARM "\
"DBCONN at ${_timestamp}${BG_NC}"
  fi
  if (( ${_typeC[@]} >= 1)) && (( ${_hbmgr[@]} >= 1 ));
  then
    echo -e "${arrPNMHOST[i]} ${arrPNM[i]}:${BG_YELLOW}${F_BLACK}CEASED ALARM "\"
"HBMGR at ${_timestamp}${BG_NC}"
  fi

else
  echo -e "${arrPNMHOST[i]} ${arrPNM[i]}:${BG_GREEN}${F_BLACK}NO ALARM${BG_NC}"
fi
done

=================================================================
sample result display of the script

Event Detection Trigger
VMRVNAPD07 EDT07:NO ALARM
VMRVNAPD08 EDT08:NO ALARM
VMRVNAPD09 EDT09:NO ALARM
VMRVNAPD10 EDT10:NO ALARM
VMRVNAPD11 EDT11:NO ALARM
VMRVNAPD12 EDT12:NO ALARM
VMRVNAPD13 EDT13:NO ALARM
VMRVNAPD14 EDT14:NO ALARM
VMRVNAPD15 EDT15:NO ALARM
VMRVNAPD16 EDT16:NO ALARM
VMRVNAPD28 EDT28:NO ALARM

Personal Notification Manager

Access Manager
VMRVNAPD17 AM01: NO ALARM
VMRVNAPD18 AM02: RAISED ALARM SFTP at 0332

Messaging Server
VMRVNAPD30 MSVM01: NO ALARM
VMRVNAPD31 MSVM02: NO ALARM
VMRVNAPD37 MSVM03: NO ALARM
VMRVNAPD40 MSVM04: NO ALARM

관련 정보