Status code check
<3
:1

Date posted: Feb. 20, 2023, 4:25 a.m.
Problem: customer says "all my sites are down" but doesn't give an example
What does it do?: Checks the http status code of all sites confirmed pointing at this server by IP address
Problem: customer says "all my sites are down" but doesn't give an example
What does it do?: Checks the http status code of all sites confirmed pointing at this server by IP address
sean@castle-murray.com[~/bash/cpanel] #
( IPS=$(hostname -I | sed '$s/.$//' | tr ' ' '|') domains=$(awk -F ": " '!/*/ {system("echo -e " $1 " $(dig +short " $1 ")")}' /etc/userdomains) echo "Domains that are pointed here:" echo "$domains" | grep -E "$IPS"| awk '{system("echo -e " $0 " $(timeout 3 curl -s -A 'STATUS-TEST' -o /dev/null -w '%{http_code}' https://" $1"); echo")}' | column -t echo echo "domains not pointed here" echo "$domains" | grep -v -E "$IPS" | awk '{print $1}' )
sean@castle-murray.com[~/bash/cpanel] #
sean@castle-murray.com[~/bash/cpanel] #
This will not confirm status codes for sites using Cloudflare or other proxy servers.
sean@castle-murray.com[~/bash/cpanel] #
This is a comment