-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomework 1
More file actions
82 lines (62 loc) · 2.52 KB
/
Homework 1
File metadata and controls
82 lines (62 loc) · 2.52 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
ping -c1 8.8.8.8 1>/dev/null 2>/dev/null
SUCCESS=$?
echo Check /home/ubuntu/bruh.log
if [ $SUCCESS -eq 0 ]
then
echo "$(date)" ": The ip $HOST is online and has replied" >> /home/ubuntu/bruh.log
else
echo "$(date)" ": The ip $HOST is offline and has not replied" >> /home/ubuntu/bruh.log
tail -2 /home/ubuntu/bruh.log | mail -s "BadPing" ubuntu@localhost.us-east-2.compute.internal
fi
#EOF
cap=20
current_latency=$(ping -c 4 8.8.8.8 | tail -1| awk -F '/' '{print $5}' | cut -d"." -f1)
if [ $current_latency == 20.0 ]
then
echo "$(date)" ": Latency is High" >> /home/ubuntu/bruh.log
tail -2 /home/ubuntu/bruh.log | mail -s "HighLatency" ubuntu@localhost.us-east-2.compute.internal
else
echo "$(date)" ": Latency is normal" >> /home/ubuntu/bruh.log
fi
#######################################################################################################
ping -c1 127.0.0.1 1>/dev/null 2>/dev/null
SUCCESS=$?
echo Check /home/ubuntu/bruh.log
if [ $SUCCESS -eq 0 ]
then
echo "$(date)" ": The ip $HOST is online and has replied" >> /home/ubuntu/bruh.log
else
echo "$(date)" ": The ip $HOST is offline and has not replied" >> /home/ubuntu/bruh.log
tail -2 /home/ubuntu/bruh.log | mail -s "BadPing" ubuntu@localhost.us-east-2.compute.internal
fi
#EOF
cap=20
current_latency=$(ping -c 4 8.8.8.8 | tail -1| awk -F '/' '{print $5}' | cut -d"." -f1)
if [ $current_latency == 20.0 ]
then
echo "$(date)" ": Latency is High" >> /home/ubuntu/bruh.log
tail -2 /home/ubuntu/bruh.log | mail -s "HighLatency" ubuntu@localhost.us-east-2.compute.internal
else
echo "$(date)" ": Latency is normal" >> /home/ubuntu/bruh.log
fi
############################################################################################################
ping -c1 2.2.2.2 1>/dev/null 2>/dev/null
SUCCESS=$?
echo Check /home/ubuntu/bruh.log
if [ $SUCCESS -eq 0 ]
then
echo "$(date)" ": The ip $HOST is online and has replied" >> /home/ubuntu/bruh.log
else
echo "$(date)" ": The ip $HOST is offline and has not replied" >> /home/ubuntu/bruh.log
tail -2 /home/ubuntu/bruh.log | mail -s "BadPing" ubuntu@localhost.us-east-2.compute.internal
fi
#EOF
cap=20
current_latency=$(ping -c 4 8.8.8.8 | tail -1| awk -F '/' '{print $5}' | cut -d"." -f1)
if [ $current_latency == 20.0 ]
then
echo "$(date)" ": Latency is High" >> /home/ubuntu/bruh.log
tail -2 /home/ubuntu/bruh.log | mail -s "HighLatency" ubuntu@localhost.us-east-2.compute.internal
else
echo "$(date)" ": Latency is normal" >> /home/ubuntu/bruh.log
fi