This bash script will help you monitor a REST API heartbeat with a Raspberry Pi
(or any linux box for that matter) and set off an alert if it goes down
- NO PYTHON (full bash script)
- Easy to configure
- Usable via a cron job (use the root's crontab, see the docs directory for more info)
- Trigger a GPIO pin on Raspberry Pi
- Sends a message on Rocket Chat
- Sends an email (requires sendmail, see the docs directory for more info)
- The API you want to monitor needs to be able to send a JSON object when querying a specific endpoint with a common HTTP verb (GET, POST, PUT...)
- The default expected response should look like :
{
"response":"PONG"
}
- The following packages installed :
cURL, jq (JSON processor), realpath, dirname & git (to clone the repo, you can uninstall it afterwards)
sudo apt install -y curl jq dirname realpath git
- Sendmail installed for email alerting
Check the docs directory for instructions on how to
- Clone this repo
git clone https://github.com/pepinpin/rpi_RESTless.git
- cd into the project folder
cd rpi_RESTless
- rename the CONFIG_FILE.sample to CONFIG_FILE
mv CONFIG_FILE.sample CONFIG_FILE
- edit the CONFIG_FILE to suit your needs
nano CONFIG_FILE
# or
vim CONFIG_FILE
- Run the script to see if it works
./runMe.sh
- setup a cron (every minute or so)
(check the docs directory for more info)
sudo crontab -e