A tiny script to watch if some IP is alive
Requirements:
- A working DB, in my case i use MariaDB. You need to create the following database:
CREATE DATABASE <DBNAME>;
USE <DBNAME>;
CREATE TABLE ping(id INT unsigned NOT NULL AUTO_INCREMENT, ip VARCHAR(15), status VARCHAR(10), tx INT UNSIGNED, rx INT UNSIGNED, percent_lost INT UNSIGNED, min FLOAT, avg FLOAT, max FLOAT, mdev FLOAT, PRIMARY KEY (id),ts timestamp default current_timestamp);
- If you need mail notify, you need to configure it and replace it in the code of the script
Install:
- Clone it:
git clone https://github.com/x11tete11x/watchdog-ping.git
- Make executable
chmod +x /path/to/script/watchdog-ping.sh
- You can put in cron, to execute periodically, for example every 5 minutes
crontab -e
*/5 * * * * /path/to/script/watchdog-ping.sh