Skip to content

Instantly share code, notes, and snippets.

@TimKraemer
Last active June 27, 2018 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimKraemer/32698a06bfde06e4b188ac4aa4ef3b64 to your computer and use it in GitHub Desktop.
Save TimKraemer/32698a06bfde06e4b188ac4aa4ef3b64 to your computer and use it in GitHub Desktop.
script to check LOCKBASE online services availability
#!/bin/bash
# PURPOSE: Script to check LOCKBASE online services availability
LOG_FILE="/var/log/online_services_health.log"
EMAIL_ADDRESS="lockbase@koertner-muth.com"
HetznerURL="https://lockbase.net/cgi-bin/"
BackupURL="https://lockbase.org/cgi-bin/"
OnlineCheckURL="https://www.google.com/"
WebsiteURL="https://koertner-muth.de/koertner-muth/Navi.cgi"
lease_status=$(curl -s $HetznerURL"LbwLease.cgi")
backup_lease_status=$(curl -s $BackupURL"LbwLeaseBak.cgi")
b2b_status=$(curl -s $HetznerURL"B2B.cgi")
website_status=$(curl -s -o /dev/null -w "%{http_code}" $WebsiteURL)
online_status=$(curl -s -o /dev/null -w "%{http_code}" $OnlineCheckURL)
service_error=false
if [ $lease_status != "2" ] || [ $b2b_status != "1" ] || [ $website_status != "200" ]
then
service_error=true
fi
if $service_error
#if true
then
echo 'Einer oder mehrere LOCKBASE Onlineservices sind nicht erreichbar' > ${LOG_FILE}
echo '============================' >>${LOG_FILE}
echo $(date) >>${LOG_FILE}
echo '' >>${LOG_FILE}
if [ $online_status -ne 200 ]
then
echo "* HAL Server hat _keine_ Verbindung zum Internet!" >>${LOG_FILE}
echo $online_status
else
echo "* Internet-Verbindung: OK." >>${LOG_FILE}
fi
if [ $lease_status -ne 2 ]
then
echo "* LBW-Lease: Störung!!!" >>${LOG_FILE}
else
echo "* LBW-Lease: OK." >>${LOG_FILE}
fi
if [ $backup_lease_status -ne 2 ]
then
echo "* Backup (1und1) LBW-Lease: Störung!!!" >>${LOG_FILE}
else
echo "* Backup (1und1) LBW-Lease: OK." >>${LOG_FILE}
fi
if [ $b2b_status -ne 1 ]
then
echo "* LBW-B2B: Störung!!!" >>${LOG_FILE}
else
echo "* LBW-B2B: OK." >>${LOG_FILE}
fi
if [ $website_status -ne 200 ]
then
echo "* Website: Störung!!! (HTTP-Status: "$website_status")" >>${LOG_FILE}
echo $website_status
else
echo "* Website: OK." >>${LOG_FILE}
fi
echo '' >>${LOG_FILE}
echo '============================' >>${LOG_FILE}
/usr/bin/mail -a "Content-Type: text/plain; charset=UTF-8" -s "[HAL] Lockbase Online Services nicht erreichbar!" "$EMAIL_ADDRESS" < ${LOG_FILE}
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment