1,17 → 1,17 |
#!/bin/bash |
|
# |
# Script that checks if given sites are up and sends an e-mail if the are not. |
# Script that checks if given sites are up and sends an e-mail if they are not. |
# You should not run this script on the same servers your monitoring, |
# neither should your e-mail account reside on a server behind same firewall as the sites your checking. |
# |
# Developer: oSource Development |
# DevTeam: Marcus Uddenhed |
# Version: 0.6.1 |
# Version: 0.5.0 |
# Web: http://www.osource.se |
# Updated: 2017-10-30 |
# Updated: 2017-08-31 |
# |
# Requires: heirloom-mailx (http://heirloom.sourceforge.net/mailx.html) |
# Requires: mailx (http://heirloom.sourceforge.net/mailx.html) |
# |
# Licensed under BSDL license, see license information on our homepage. |
# |
18,8 → 18,8 |
|
#### Global variables #### |
# Sites |
checkSite[1]="http://" # Add sites that you want to monitor, can be as many as you want. |
checkSite[2]="https://" |
checkSite[1]="https://"; # Add sites that you want to monitor, can be as many as you want. |
checkSite[2]="http://"; |
|
# Retries |
rInterval=8 # How many times should it retry until it set the site as down. |
28,13 → 28,12 |
# Mail |
sendMail=yes # Should i send an e-mail with failed sites. |
mailFrom="" # From whom shall this mail be sent? |
mailTo="" # To whom shall the mail be sent? |
mailTo="" # To whom shall the mail be sent? Seperate recipients with a "," |
smtpHost="" # The SMTP mail server that is going to process the mail. |
smtpAuth=yes # Does the SMTP mail server require authentication(yes/no). |
smtpUser="" # Username if smtpAuth is set to yes. |
smtpPass="" # password if smtpAuth is set to yes. |
smtpPort=587 # Standard for non authenticated SMTP is 25, 587 is for authenticated SMTP. |
mailBin="heirloom-mailx" # executable file for mailx. |
|
# Logging |
logStatus=yes # Should we log to local logfile(yes/no). |
140,14 → 139,14 |
echo "Your $(cat /etc/hostname) server." >> $tmpPath/mailbody.txt |
|
# Send data |
MAILRC=/dev/null $mailBin -n |
MAILRC=/dev/null mailx -n |
if [ $smtpAuth = "no" ] |
then |
env MAILRC=/dev/null from=$mailFrom smtp=$smtpHost:$smtpPort $mailBin -v -n -s "$mailSubject" $mailTo <$tmpPath/mailbody.txt |
env MAILRC=/dev/null from=$mailFrom smtp=$smtpHost:$smtpPort mailx -v -n -s "$mailSubject" $mailTo <$tmpPath/mailbody.txt |
fi |
if [ $smtpAuth = "yes" ] |
then |
env MAILRC=/dev/null from=$mailFrom smtp=$smtpHost:$smtpPort smtp-auth-user=$smtpUser smtp-auth-password=$smtpPass smtp-use-starttls=yes ssl-verify=ignore smtp-auth=login $mailBin -n -s "$mailSubject" $mailTo <$tmpPath/mailbody.txt |
env MAILRC=/dev/null from=$mailFrom smtp=$smtpHost:$smtpPort smtp-auth-user=$smtpUser smtp-auth-password=$smtpPass smtp-use-starttls=yes ssl-verify=ignore smtp-auth=login mailx -n -s "$mailSubject" $mailTo <$tmpPath/mailbody.txt |
fi |
|
# Remove temporary mailbody.txt file |
186,14 → 185,14 |
echo "Your $(cat /etc/hostname) server." >> $tmpPath/mailbody.txt |
|
# Send data |
MAILRC=/dev/null $mailBin -n |
MAILRC=/dev/null mailx -n |
if [ $smtpAuth = "no" ] |
then |
env MAILRC=/dev/null from=$mailFrom smtp=$smtpHost:$smtpPort $mailBin -v -n -s "$mailSubject" $mailTo <$tmpPath/mailbody.txt |
env MAILRC=/dev/null from=$mailFrom smtp=$smtpHost:$smtpPort mailx -v -n -s "$mailSubject" $mailTo <$tmpPath/mailbody.txt |
fi |
if [ $smtpAuth = "yes" ] |
then |
env MAILRC=/dev/null from=$mailFrom smtp=$smtpHost:$smtpPort smtp-auth-user=$smtpUser smtp-auth-password=$smtpPass smtp-use-starttls=yes ssl-verify=ignore smtp-auth=login $mailBin -n -s "$mailSubject" $mailTo <$tmpPath/mailbody.txt |
env MAILRC=/dev/null from=$mailFrom smtp=$smtpHost:$smtpPort smtp-auth-user=$smtpUser smtp-auth-password=$smtpPass smtp-use-starttls=yes ssl-verify=ignore smtp-auth=login mailx -n -s "$mailSubject" $mailTo <$tmpPath/mailbody.txt |
fi |
|
# Remove temporary mailbody.txt file |
200,14 → 199,6 |
rm $tmpPath/mailbody.txt |
} |
|
script_help() { |
echo "Usage: oSiteChecker.sh <parameter>" |
echo "" |
echo "Parameters:" |
echo "--check Does a test connection to pre-configured sites and test to see if they are responding." |
echo "--mail-test Does a test on the mail function to see if all mail related settings are okay." |
} |
|
case $1 in |
--check) |
check_sites |