Index of /tools/watchdog

Icon  Name                                                         Last modified      Size  Description
[PARENTDIR] Parent Directory - [TXT] wd_stat.json 2017-05-18 13:55 646 [TXT] wd_alive.php 2024-02-12 12:49 1.2K [TXT] wd_check.php 2024-02-12 12:49 2.8K [TXT] wd_readme.txt 2024-02-12 12:49 1.7K
Simple PHP based watchdog
=========================
(c) 2017 Thorsten Maerz (info@netztorte.de) - Public Domain

Check, wether a certain device is on- or offline.

The device that should be watched has to request a PHP file on a remote
webserver. This updates a timestamp for that device on the webserver.
The webserver regularly checks, if the timestamps are up to date and sends an
email, if the state (on- or offline) changed.

* Setup:
** On the device:
Create a cronjob that updates the timestamp.
Every 15minutes may be a good start:
  */15 * * * * wget -O /dev/null -q http://HOST.TLD/PATH/wd_alive.php?host=HOSTNAME

** On the webserver:
Requires PEAR::Mail (or a readily configured local MTA).
Put the scripts "wd_check.php" and "wd_alive.php" into an accessible directory
on the webserver. Edit the "wd_check.php" and modify "$json_stat_name".
Use an absolute path for the status file ($json_stat_name), otherwise the cron
job may not find it.
Configure the SMTP setting at the top of wd_check.php.
Run the script using "php wd_check.php". This will create a sample status file
("wd_stat.json"), unless it already exists. You should receive 2 emails, that
the hosts are offline.

Edit the status file. Only hosts that are mentioned there, will be checked
(unless you set "ignore" to "true" or the current time lies outside
"watchstart" and "watchend"). Change "mailto" and "mailfrom" to sensible values.

The other fields should be self-explanatory.
Finally create a cronjob that regularly calls the "wd_check.php" script:
  */15 * * * * php /var/www/watchdog/wd_check.php
(If you cannot set up cron jobs, you may as well call the "wd_check.php"
script from any other host using wget, curl, etc.).