This is a SAMPLE TESTING MESSAGE sent through Cell Broadcasting System by Department of Telecommunication

Image
  This is a SAMPLE TESTING MESSAGE sent through Cell Broadcasting System by Department of Telecommunication, Government of India. Please ignore this message as no action is required from your end. This message has been sent to test Pan-India Emergency Alert System being implemented by National Disaster Management Authority. It aims to enhance public safety and provide timely alerts during emergencies. Timestamp: 12-10-2023 12:13 PM 21

Shell script to check domain expiry date and send alerts to Slack on Ubuntu

 

1. Create a file with list of domain names

vi /home/ubuntu/domain_names.txt
example.com
example.in
example.org
exp123.com

2. Create a shell script for domain expiry check

vi /home/ubuntu/domain-expiry-check.sh
#!/bin/bash

#Specify all the domains you want to check
WEBSITE_LIST=`cat /home/ubuntu/domain_names.txt` #WEBSITE_LIST
MAX_DAYS=30
MIN_DAYS=1
current_epoch=$(date '+%s')
for dm in $WEBSITE_LIST
do
expiry_date=$(curl -s https://www.whatsmydns.net/api/domain?q=$dm | jq --raw-output '.[].expires | select( . != null )' )
echo -n " $dm - Expires on $expiry_date "
expiry_epoch=$(date --date="$expiry_date" '+%s')
epoch_diff=$((expiry_epoch - current_epoch))
days=$((epoch_diff / 86400))
if [[ $days -lt $MAX_DAYS && $days -gt $MIN_DAYS ]];
then
echo -n " $dm - Expires on $expiry_date and $days days remaining. "
curl -X POST -H 'Content-type: application/json' --data '{"text":" *:globe_with_meridians: '$dm' - Expires on '$expiry_date' | '$days' days remaining.*"}' https://hooks.slack.com/services/TBTD5BKT3/BLZPAXXXX/XXXXXXXXXXXXXXXX
fi
done


3. Replace the slack webhook URL with your webhook URL and execute

chmod +x /home/ubuntu/domain-expiry-check.sh

./domain-expiry-check.sh


https://medium.com/@arungowda325/shell-script-to-check-domain-expiry-date-and-send-alerts-to-slack-on-ubuntu-8f573d500a80


Comments

Popular posts from this blog

Google doodle celebrates India Republic Day

This is a SAMPLE TESTING MESSAGE sent through Cell Broadcasting System by Department of Telecommunication