Created
August 18, 2014 18:29
-
-
Save vidul-nikolaev-petrov/469c97837ed71d79ae57 to your computer and use it in GitHub Desktop.
email HTTP response code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sample usage (crontab): | |
# 55 11 * * * /home/monitor/bin/email_http_response_code.pl | |
my $email = 'YOUR EMAIL ADDRESS'; #example: root@google.com | |
my $website = 'YOUR WEBSITE URL'; #example: http://google.com | |
my $date_now = localtime; | |
my $result_http_code = `curl -sL -w '%{http_code} %{url_effective}' '$website' -o /dev/null`; | |
$result_http_code =~ s/(\S+)$/($1)/; | |
`echo "$date_now" | mail -s "HTTP response code: $result_http_code" "$email"`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment