In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Share a monitoring of domain name validity using shell script today.
Don't like the prologue, or go straight to the practical information.
#! / bin/bash# detects whether the domain name is out of date # author: xuexiaobai@shell.com# date: 2020022 version: v0.The current date and time stamp is used to compare with the expiration time of the domain name currentTimestamp= `date +% s` # check whether the whois command exists Install the whois package isInstallWhois () {which whois > / dev/null 2 > / dev/null if [$?-ne 0] then yum install-y whois | | apt-get install whois-y fi} notify () {expiredate= `whois $1 | grep 'Registry Expiry Date' | awk' {print $4}'| cut-d'T'- f 1` # represents the domain name and iterates through it. # if the value of eExd is empty Then filter the keywords' Expiration Time' if [- z "$expiredate"] then expiredate= `whois $1 | grep 'Expiration Time' | awk' {print $3} '`fi # convert the expiration date of the domain name into a timestamp expiredatestamp= `date-d $expiredate +% s` # calculate the total number of seconds in half a month # 15d 1296000 30d 2592000 35d 3024000 40d 3456000 expiredatestamp 2592000 timeBeforce=$ [$expiredatestamp-$n] # timestamp timeAfter=$ before 15 days of expiration [$expiredatestamp + $n] # timestamp if [$currentTimestamp-ge $timeBeforce] & & [$currentTimestamp-lt $expiredatestamp] then curl-X POST\-H 'Content-type: application/json'\-- data'{"text": ": warning:Domain'$1' will to be expired less then 15d. And domain'$1' expiredate is'$expiredate' @ xuexiaobai "}'\ https://hooks.slack.com/services/*****/xxxxxxx/qqqqqqqqqqqqqqqqqqqqqq fi if [$currentTimestamp-ge $expiredatestamp] then curl-X POST\-H 'Content-type: application/json'\-data' {" text ":": interrobang:Domain'$1' has been expired. And domain'$1' expiredate is'$expiredate' @ xuexiaobai "}'\ https://hooks.slack.com/services/*****/xxxxxxx/qqqqqqqqqqqqqqqqqqqqqq fi} # check whether the last whois query process exists # if it exists, you need to kill the process so as not to affect the execution of this script if pgrep whois & > / dev/nullthen killall-9 whoisfiisInstallWhoisfor d in baidu.com google.comdo notify $ddone
There are a few things to pay attention to in the above script:
Slack notification is used in the script. If you choose to use slack, you need to modify the hooks address to customize the validity period of the check, control how many days it still has to expire for notification, and modify the n variable in the shell script to run in a scheduled task.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.