-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·64 lines (50 loc) · 1.36 KB
/
run.sh
File metadata and controls
executable file
·64 lines (50 loc) · 1.36 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /bin/bash
# Evaluate network uptime
#
# WHY cURL?
# Curl is a simple way to do tcp.
# We care about tcp because that is how our webserver accesses data.
# If curl fails, our webserver will fail.
#
# In the beginning we used ping (icmp) as our smoke test.
# But according to https://en.wikipedia.org/wiki/Packet_loss
# ping is considered low priority traffic, and when they are dropped they are not re-sent.
#
# Why assets/simple.txt from our staging site?
# It's a small file that we control,
# being served directly from nginx so it's FAST.
# And it's in the amazon cloud which appears to have
# super reliable network.
#
# Why Bash?
# So we don't have to install anything extra to run this.
# Dependencies change things.
HOST='https://staging.elitecare.com/assets/simple.txt'
up_count=0
down_count=0
COMMAND="curl -k --max-time 8 $HOST > /dev/null 2> /dev/null"
echo '######################################################'
echo 'Uptime Monitor'
echo ''
echo $COMMAND
echo ''
echo '######################################################'
while true
do
printf $(date +'%FT%H:%M:%S.%N')
printf ' '
eval $COMMAND
if [ $? == 0 ]; then
up_count=$((up_count+1))
printf 'UP '
else
down_count=$((down_count+1))
printf 'DOWN '
fi
printf 'successes: '
printf $up_count
printf ' failures: '
printf $down_count
printf '\n'
sleep 0.1
done