summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranweshadas <anwesha@das.community>2022-05-09 16:12:58 +0200
committeranweshadas <anwesha@das.community>2022-05-09 16:12:58 +0200
commit7d62db016d6c4fc62263ddff840f2e69f7b23e1c (patch)
tree8af0888914bd9ca0e53b172da459f9b174b1ce8e
parentdf489971a659cba17012cb1d82cbb8369425597a (diff)
Adds the initial email code on error
-rw-r--r--scripts/monitor.sh11
1 files changed, 3 insertions, 8 deletions
diff --git a/scripts/monitor.sh b/scripts/monitor.sh
index bc274a8..ce0c29c 100644
--- a/scripts/monitor.sh
+++ b/scripts/monitor.sh
@@ -7,15 +7,10 @@ do
echo $url #this is for testing purpose. To be removed in thhe final code.
response=$(curl -s -w "%{http_code}" $url)
http_code=$(tail -n1 <<< "$response")
+ domain_name=$(echo $url | awk -F[/:] '{print $4}')
if [[ "$http_code" != 200 ]]; then
- echo Fatal. $url is down. status_code $http_code
- domain_name=$(echo $url | awk -F[/:] '{print $4}')
- echo $domain_name
- # 1. Find IP address via dig
- # 2. Check if we can ping the ip address
- ip_address=$(dig +short $domain_name)
- echo $dig_response #this is for testing purpose. To be removed in thhe final code.
- #ping_response=$(ping $ip_address)
+ msg="Warning: $url is down. status_code $http_code"
+ echo $msg | mail -s "Warning: $domain_name is down" anwesha@verkligendata.se
else
echo $url is working. status_code $http_code
fi