-
Notifications
You must be signed in to change notification settings - Fork 15
/
status.sh
executable file
·41 lines (31 loc) · 1.15 KB
/
status.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# lookup the domain's ip and compare to external ip for this host
# list the aegis host process/es and listener sockets;
# otherwise, display a message that the server is down.
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
DOMAIN1=aegis.module-federation.org
DOMAIN2=aegis2.module-federation.org
# Get public IP of this host
IPADDR_PUBLIC=$(curl -s checkip.amazonaws.com)
# Get IP of domain1
IPADDR_DOMAIN1=$(nslookup -recurse $DOMAIN1 | grep Address | grep -v "#" | awk '{print $2}')
# Get IP of domain2
IPADDR_DOMAIN2=$(nslookup -recurse $DOMAIN2 | grep Address | grep -v "#" | awk '{print $2}')
# print the public IP and fully qualified domain name of this host
echo "public address $IPADDR_PUBLIC"
if [ "$IPADDR_PUBLIC" == "$IPADDR_DOMAIN1" ]; then
echo -e "domain${GREEN} $DOMAIN1 $NC"
fi
if [ "$IPADDR_PUBLIC" == "$IPADDR_DOMAIN2" ]; then
echo -e "domain${GREEN} $DOMAIN2 $NC"
fi
# print current running process
sudo lsof -P -i | grep LISTEN | grep aegis
# get process ID of aegis
PID=$(sudo lsof -P -i | grep LISTEN | grep aegis | awk '{print $2}')
if [[ ${PID} ]]; then
echo -e "${GREEN}server is up $NC"
else
echo -e "${RED}server is down $NC"
fi