From 75cd7b6c4ff50e8ea299d90694f0c59334cc4e55 Mon Sep 17 00:00:00 2001 From: Raymon Mens Date: Sun, 5 Nov 2023 14:10:43 +0100 Subject: [PATCH] Heartbeat monitoring (#7) * Ask user about heartbeat monitoring * Monitoring logic * Add a work about heartbeat monitoring to README --- README.md | 3 +++ setup.sh | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0440418..e906ac2 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file diff --git a/setup.sh b/setup.sh index e546889..153207e 100755 --- a/setup.sh +++ b/setup.sh @@ -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" @@ -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"