CheckHost v1.0.1 SYNTAX ====== checkhost.sh host recipients [hostname] Parameters: ----------- host - IP-Address or Domain (use Google-IP: 8.8.8.8 for checking the internet connection) recipients - e-mail addresses for the notifications. Separate several e-mail addresses by a comma sign and enclose all in single quotation marks(e.g. 'egon@gmx.de,ziggi@arcor.de'). hostname - (optional) description or name of a host. It appears in the e-mail and log text as an identification, e.g. Vodafone Internet, NAS-Server, HP Printer or similar. Descriptions with space characters must be enclosed in single quotation marks ('Vodafone Internet', 'HP Printer'). If no hostname defined, the script uses by default the name 'Device'. DESCRIPTION =========== The checkhost.sh script is executed manually or automatically by cron (see installation below). The execution requires "root" permissions. A ping request is sent to the defined host and an e-mail notification is sent out if the host network connection has colapsed or regenerated. Checking the internet connection the notifications are sent after the host has become available again. Logically, no e-mail can be passed over an unavailable internet access. Therefore the re-connection mail will contain the elapsed host offline time according to the flag file timestamp. REQUIREMENTS ============ - Linux/Unix operating system - BASH Shell - Postfix, sSMTP or equivalent Mail Transfer Agent INSTALLATION ============ 1. Unzip the downloaded GZIP archive file: cd /home/$USER/Downloads tar -xvzf checkhost_1.0.1.tar.gz cd checkhost_1.0.1 The folder checkhost_1.0.1 contains files as follow: - checkhost.jpg - the script flow chart - checkhost.tar.gz - checkhost.sh script and README file archive - README - script description and installation guide (this file!) 2. Unzip the checkhost.tar.gz archive file to the /etc directory of an UNIX device connected to a network (like Raspberry Pi, NAS-Server, Desktop-PC with Linux etc.): sudo tar -xvzf checkhost.tar.gz -C /etc 3. Change permissions and make the script executable: sudo chmod -R 755 /etc/checkhost 4. Change owner and ownergroup to root: sudo chown -R root:root /etc/checkhost 5. Open the root crontab: sudo crontab -e 6. Add the cronjob as follow: */5 * * * * /etc/checkhost/checkhost.sh host recipients [hostname] > /dev/null 2>&1 see above the synthax for host, recipients and hostname The script is executed every 5 minutes. For any other time interval change the cronjob values. SYSTEM FILES ============ /etc/checkhost/checkhost.sh - the script itself /etc/checkhost/README - script description and installation guide (this file!) /var/log/checkhost - log files directory /tmp/ping-alarm-xxx.xxx.xxx.xxx - temporary flag file created on lost connection and deleted on connection resume. RELEASE NOTES ============= 1.0.1 [2018-04-04] - parameter description added to the script header comment; - constant SCRIPT_FILE_BASENAME added; 1.0.0 [2018-04-29] - initial release