Skip to content

Commit

Permalink
Heartbeat monitoring (#7)
Browse files Browse the repository at this point in the history
* Ask user about heartbeat monitoring
* Monitoring logic
* Add a work about heartbeat monitoring to README
  • Loading branch information
rmens authored Nov 5, 2023
1 parent 94dfabc commit 75cd7b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ This repository contains the MicroMPX set-up for [ZuidWest FM](https://www.zuidw
- Download and run the VPN script with the command `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/oszuidwest/rpi-umpx-decoder/main/vpn.sh)"`
- Check with `ip a` if you have an interface named `wg0` with the correct IP
- If the `wg0` interface is not showing, enable debugging with `modprobe wireguard && echo module wireguard +p > /sys/kernel/debug/dynamic_debug/control` and `tail -f /var/log/syslog` to look for errors

## Optional heartbeat monitoring
You can optionally integrate heartbeat monitoring. In this case the Pi will `wget --spider` a given url every minute, acting as a heartbeat. This can be any url, but we tested with Uptime Robot. A paid account is required at Uptime Robot for heartbeat monitoring.
13 changes: 12 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ is_this_linux
is_this_os_64bit

# Check if we are running on a Raspberry Pi 3 or newer
check_rpi_model 3
check_rpi_model 4

# Something fancy for the sysadmin
cat << "EOF"
Expand Down Expand Up @@ -87,6 +87,17 @@ curl -s -o /etc/systemd/system/micrompx.service https://raw.githubusercontent.co
systemctl daemon-reload > /dev/null
systemctl enable micrompx > /dev/null

# Heartbeat monitoring
ask_user "ENABLE_HEARTBEAT" "n" "Do you want to integrate heartbeat monitoring via UptimeRobot (y/n)" "y/n"
if [ "$ENABLE_HEARTBEAT" == "y" ]; then
ask_user "HEARTBEAT_URL" "https://heartbeat.uptimerobot.com/xxx" "Enter the URL to get every minute for heartbeat monitoring" "str"

# Add a cronjob that calls the HEARTBEAT_URL every minute
echo -e "${BLUE}►► Setting up heartbeat monitoring cronjob...${NC}"
(crontab -l 2>/dev/null; echo "* * * * * wget --spider $HEARTBEAT_URL > /dev/null 2>&1") | crontab -
echo -e "${GREEN}Heartbeat monitoring cronjob added.${NC}"
fi

# Disable only the hdmi audio so we can use the minijack for monitoring
echo -e "${BLUE}►► Disabling onboard audio...${NC}"
readonly CONFIG_FILE="/boot/firmware/config.txt"
Expand Down

0 comments on commit 75cd7b6

Please sign in to comment.