Created
September 12, 2026 23:01
-
-
Save nateyolles/2c25ddef70e147e60e4d0d123defd82b to your computer and use it in GitHub Desktop.
claude wifi monitor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # wifi-monitor.sh | |
| # Logs Wi-Fi / network diagnostics once per run. Intended to be run every | |
| # minute via cron so you have a timeline to look back on after an outage. | |
| # | |
| # Install on leota (or any of the affected Pis): | |
| # 1. Copy this file to the Pi, e.g. /home/pi/wifi-monitor.sh | |
| # 2. chmod +x /home/pi/wifi-monitor.sh | |
| # 3. crontab -e and add this line: | |
| # * * * * * /home/pi/wifi-monitor.sh | |
| # 4. Let it run. After the next outage (or once you regain access), | |
| # read /home/pi/wifi-monitor.log and look at the entries right | |
| # before/during the time it was unreachable. | |
| LOGFILE="/home/pi/wifi-monitor.log" | |
| IFACE="wlan0" | |
| GATEWAY="192.168.1.1" # change if your UDM's LAN IP differs | |
| { | |
| echo "=== $(date '+%Y-%m-%d %H:%M:%S') ===" | |
| echo "-- power_save --" | |
| iw dev "$IFACE" get power_save 2>&1 | |
| echo "-- link --" | |
| iw dev "$IFACE" link 2>&1 | |
| echo "-- station dump (signal, retries, tx/rx failures) --" | |
| iw dev "$IFACE" station dump 2>&1 | |
| echo "-- interface state --" | |
| ip -4 addr show "$IFACE" 2>&1 | |
| echo "-- neighbor/arp cache --" | |
| ip neigh show 2>&1 | |
| echo "-- can leota reach its own gateway right now? --" | |
| if ping -c1 -W2 "$GATEWAY" >/dev/null 2>&1; then | |
| echo "gateway: OK" | |
| else | |
| echo "gateway: FAIL" | |
| fi | |
| echo "-- can leota reach the internet right now? --" | |
| if ping -c1 -W2 1.1.1.1 >/dev/null 2>&1; then | |
| echo "internet: OK" | |
| else | |
| echo "internet: FAIL" | |
| fi | |
| echo | |
| } >> "$LOGFILE" | |
| # Keep the log from growing forever - retain the last ~2 days at 1/min. | |
| tail -n 2880 "$LOGFILE" > "$LOGFILE.tmp" 2>/dev/null && mv "$LOGFILE.tmp" "$LOGFILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment