Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Health Monitor for your EeePC home server

Checks system health, hardware, and your running services every 5 minutes, and sends a Telegram message only when something changes state — no spam, no repeat alerts for a problem that's already been reported. Plus one daily heartbeat at 08:00 so you know the monitor itself hasn't died.

What it checks

  • Disk usage on / (default threshold: 85%)
  • Memory usage (default threshold: 90%)
  • CPU load (5-min load average vs core count)
  • CPU temperature (default threshold: 75°C — reads /sys/class/thermal, so it works on non-Pi hardware like your EeePC)
  • Services and ports — auto-discovered (see below)
  • Internet reachability (ping 1.1.1.1)
  • DNS resolution (confirms Pi-hole is actually resolving names, not just running)

Auto-discovery — no config edits needed for new services

Every run, the script scans:

  • Listening TCP ports (via ss), skipping anything bound only to loopback (internal plumbing, not a real "service")
  • Running systemd services (via systemctl), skipping generic system internals (systemd-*, dbus*, user@*, getty@*) so you're not flooded with noise from things you didn't set up

First run: whatever's currently running/listening becomes the baseline silently — you won't get a wall of "new service!" messages for Pi-hole, Apache, lighttpd, your FastAPI app, and qBittorrent all at once.

After that:

  • Add a new service or open a new port → you get one 🔵 "new service/port detected, now monitoring it" message, and it's tracked from then on automatically.
  • A tracked service/port disappears (crash, or you stopped it) → you get one 🔴 alert. If you meant to decommission it, run the forget command below so it stops being tracked (otherwise it just stays quiet after the one alert — no repeat spam either way).

Stop monitoring something on purpose

sudo /opt/health-monitor/health-monitor.sh --forget-port 8080
sudo /opt/health-monitor/health-monitor.sh --forget-service qbittorrent-nox

See everything currently tracked

sudo /opt/health-monitor/health-monitor.sh --status

Shows every tracked port/service and its current OK/FAIL state, plus what's on the ignore lists.

Step 1 — Create a Telegram bot (2 minutes)

  1. In Telegram, message @BotFather
  2. Send /newbot, give it a name and a username (must end in "bot")
  3. BotFather gives you a token like 123456789:ABCdefGhIJKlmNoPQRstuVWXyz — this is your TELEGRAM_BOT_TOKEN

Step 2 — Get your chat ID

  1. Send any message to your new bot (e.g. "hi")
  2. Visit this URL in a browser (replace with your token): https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
  3. Look for "chat":{"id":123456789,...} — that number is your TELEGRAM_CHAT_ID

Step 3 — Install

sudo bash setup.sh

Then edit the generated env file and fill in your token/chat ID:

sudo nano /opt/health-monitor/health-monitor.env

This file is separate from the script on purpose — it's created with placeholders on first install and never touched by upgrades, so your real token never has to live inside the (version-controlled) script itself.

Test it manually:

sudo /opt/health-monitor/health-monitor.sh
tail -f /var/log/health-monitor.log

You should get a Telegram message the first time any check fails, and a "recovered" message when it's fixed. To force a test alert, you could temporarily stop a service you're monitoring (sudo systemctl stop lighttpd) and watch for the alert within 5 minutes, then start it again.

Why every 5 minutes?

Frequent enough to catch a service dying without much delay, infrequent enough that it won't add meaningful load to an EeePC. If you want it tighter or looser, edit the cron line directly:

crontab -e

Customizing thresholds

All thresholds live in the CONFIG section at the top of health-monitor.sh:

  • DISK_WARN_PCT, MEM_WARN_PCT, LOAD_MULTIPLIER, TEMP_WARN_C
  • SERVICE_IGNORE_PATTERNS — shell glob patterns for systemd services to never auto-track (default excludes systemd-*, dbus*, user@*, getty@*, serial-getty@*)
  • HEARTBEAT_HOUR — hour (0–23) for the daily "still alive" ping

Note: ports are not filtered by pattern — every non-loopback listening port gets tracked. Use --forget-port for any you don't care about.

Uninstalling

sudo crontab -l | grep -v health-monitor.sh | sudo crontab -
sudo rm -rf /opt/health-monitor /var/lib/health-monitor /var/log/health-monitor*.log
sudo rm -f /etc/logrotate.d/health-monitor

About

plug-and-play Linux server monitoring that discovers what you're running and keeps you posted over Telegram

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages