FHEM (Friendly Home Easy Monitoring) is a highly extensible open-source home automation server written in Perl. It speaks dozens of device protocols — Z-Wave, ZigBee, KNX, MQTT, 433 MHz RF — and runs complex automation rules called "notify" and "at" commands. But FHEM has no built-in uptime monitoring: a Perl crash, a USB stick disconnect, or a broken SQLite logging backend fails silently until your automations stop working. Vigilmon fills that gap, monitoring every layer of your FHEM instance so you know the moment something stops responding.
What You'll Set Up
- HTTP availability monitor for the FHEM web interface
- Device module connection status (Z-Wave, ZigBee, KNX, MQTT) via telnet
- Telnet interface health check
- Database logging backend (SQLite/MySQL/PostgreSQL) heartbeat
- Automation rule processing engine verification
- MQTT bridge connectivity monitoring
- Event notification delivery check
- Scheduled task execution heartbeat
- Webcam/media integration service monitoring
Prerequisites
- FHEM running and accessible (default port 8083 for web UI, port 7072 for telnet)
- Root or sudo access to the FHEM host for scripting health checks
- A free Vigilmon account
Step 1: Monitor the FHEM Web Interface
The FHEM FHEMWEB module serves the web interface on port 8083. If the Perl process crashes or the web module dies, this is the first place you'll see it.
- Log in to vigilmon.online and click Add Monitor.
- Set Type to
HTTP / HTTPS. - Enter:
http://your-fhem-host:8083/fhem(orhttps://fhem.yourdomain.combehind a reverse proxy). - Set Check interval to
1 minute. - Set Expected HTTP status to
200. - Set Expected response body contains to
FHEMto confirm the page actually rendered. - Click Save.
If you have HTTP authentication enabled on FHEMWEB, add credentials to the monitor or use the Vigilmon HTTP Auth option.
Step 2: Monitor the Telnet Interface
FHEM's telnet server (default port 7072) is the low-level command interface. Scripts, integrations, and helper tools talk to FHEM through telnet. If FHEM is partially crashed (web up but event loop stuck), the telnet interface often fails first.
Add a TCP monitor:
- Click Add Monitor → TCP Port.
- Enter your FHEM host and port
7072. - Set interval to
1 minute.
For a deeper health signal, send a test command over telnet and verify the response:
#!/bin/bash
RESPONSE=$(echo "version" | nc -w 3 your-fhem-host 7072 2>/dev/null)
if echo "$RESPONSE" | grep -q "fhem.pl"; then
curl -s https://vigilmon.online/heartbeat/TELNET_HEARTBEAT_ID
fi
Schedule every minute: * * * * * /opt/checks/fhem-telnet.sh
The version command is safe to call repeatedly and returns the FHEM version string — confirming the event loop is processing commands.
Step 3: Monitor Device Module Connection Status
FHEM's power is in its device modules: CUL for 433 MHz, HMLAN for HomeMatic, ZWave for Z-Wave, ZigBee2MQTT for ZigBee, KNX for building bus. Each module can disconnect silently if its USB stick is unplugged or the daemon crashes.
Check device status via telnet and ping a heartbeat per module:
#!/bin/bash
FHEM_HOST="your-fhem-host"
FHEM_PORT="7072"
check_device() {
local device="$1"
local heartbeat="$2"
STATUS=$(echo "get $device openDev" | nc -w 3 "$FHEM_HOST" "$FHEM_PORT" 2>/dev/null)
if echo "$STATUS" | grep -qiE "opened|connected|ok"; then
curl -s "https://vigilmon.online/heartbeat/$heartbeat"
fi
}
# Check each protocol module
check_device "ZWave" "ZWAVE_HEARTBEAT_ID"
check_device "ZigBee" "ZIGBEE_HEARTBEAT_ID"
check_device "KNX" "KNX_HEARTBEAT_ID"
check_device "MQTT2_CLIENT" "MQTT_HEARTBEAT_ID"
Adjust device names to match your actual FHEM device definitions. Create a separate Vigilmon heartbeat monitor for each protocol module with a 5-minute expected interval.
Step 4: Monitor the Database Logging Backend
FHEM logs device readings to SQLite (default), MySQL, or PostgreSQL via the DbLog module. A full disk or locked SQLite file causes logging to silently stop — readings are lost forever.
SQLite
#!/bin/bash
DB_PATH="/opt/fhem/fhem.db"
# Try a lightweight read query
sqlite3 "$DB_PATH" "SELECT COUNT(*) FROM history WHERE TIMESTAMP > datetime('now', '-5 minutes');" > /dev/null 2>&1
if [ $? -eq 0 ]; then
curl -s https://vigilmon.online/heartbeat/DB_HEARTBEAT_ID
fi
MySQL
#!/bin/bash
mysqladmin -h localhost -u fhem -pYOUR_PASSWORD ping 2>/dev/null | grep -q "alive"
if [ $? -eq 0 ]; then
curl -s https://vigilmon.online/heartbeat/DB_HEARTBEAT_ID
fi
PostgreSQL
#!/bin/bash
pg_isready -h localhost -p 5432 -U fhem -d fhem > /dev/null 2>&1
if [ $? -eq 0 ]; then
curl -s https://vigilmon.online/heartbeat/DB_HEARTBEAT_ID
fi
Create a Cron Heartbeat in Vigilmon with a 5-minute interval, and add the check to cron:
*/5 * * * * /opt/checks/fhem-db.sh
Step 5: Monitor the Automation Rule Processing Engine
FHEM's automation engine processes notify, at, and doif commands in its Perl event loop. If the loop stalls (e.g., a blocking Perl call or infinite loop), automations stop but FHEM appears to be running.
Verify the event loop is processing by setting a test timer and checking it executes:
#!/bin/bash
FHEM_HOST="your-fhem-host"
FHEM_PORT="7072"
# Create a one-shot "at" command that sets a dummy reading
echo "define vigilmon_check at +00:01:00 setreading vigilmon_dummy lastcheck \$(time)" \
| nc -w 3 "$FHEM_HOST" "$FHEM_PORT" > /dev/null
# Wait 65 seconds, then check the reading was updated
sleep 65
READING=$(echo "get vigilmon_dummy lastcheck" | nc -w 3 "$FHEM_HOST" "$FHEM_PORT" 2>/dev/null)
CURRENT_MINUTE=$(date +%H:%M)
if echo "$READING" | grep -q "$CURRENT_MINUTE"; then
curl -s https://vigilmon.online/heartbeat/AUTOMATION_HEARTBEAT_ID
fi
This is more complex — run it via a cron job that allows 2-minute execution time. The result is a genuine end-to-end test of the FHEM event scheduler.
Step 6: Monitor MQTT Bridge Connectivity
Many FHEM setups use the MQTT2_CLIENT or MQTT2_SERVER module to integrate with Zigbee2MQTT, Node-RED, or Home Assistant. A broken MQTT connection means cross-platform automations stop silently.
Add a TCP monitor for your MQTT broker port:
- Click Add Monitor → TCP Port.
- Enter your MQTT broker host and port
1883. - Interval:
1 minute.
Check FHEM's MQTT client connection state via telnet:
#!/bin/bash
STATUS=$(echo "list MQTT2_CLIENT state" | nc -w 3 your-fhem-host 7072 2>/dev/null)
if echo "$STATUS" | grep -q "opened"; then
curl -s https://vigilmon.online/heartbeat/MQTT_CLIENT_HEARTBEAT_ID
fi
Step 7: Monitor Event Notification Delivery
FHEM can send notifications via email, push (Pushover, Telegram), or HTTP webhooks when events occur. If the notification service fails, you lose alerting for device events.
Test the notification path by triggering a test notification on a schedule:
#!/bin/bash
# Trigger a test notification via FHEM telnet
RESPONSE=$(echo "trigger vigilmon_notify_test 1" | nc -w 3 your-fhem-host 7072 2>/dev/null)
# A successful trigger returns an empty line or "OK"
if [ $? -eq 0 ]; then
curl -s https://vigilmon.online/heartbeat/NOTIFY_HEARTBEAT_ID
fi
In FHEM, define a dummy notify that sets a reading when triggered:
define vigilmon_notify_test dummy
define vigilmon_notify_check notify vigilmon_notify_test:* setreading vigilmon_notify_check lastCheck $EVENT
Step 8: Monitor Scheduled Task Execution
FHEM's at and cron commands handle scheduled home automation tasks — turning lights on at sunset, running the robot vacuum, triggering irrigation. A stalled scheduler silently breaks all time-based automations.
Create a watchdog reading that must be updated on schedule:
In FHEM (define in fhem.cfg or via the web):
define vigilmon_watchdog at *08:00:00 { system("curl -s https://vigilmon.online/heartbeat/WATCHDOG_HEARTBEAT_ID") }
Set the Vigilmon heartbeat interval to 25 hours (longer than daily) to alert if the 8 AM task doesn't run.
For more granular scheduler monitoring, add a minutely watchdog:
define vigilmon_minutely at +*00:01:00 { system("curl -s https://vigilmon.online/heartbeat/SCHEDULER_HEARTBEAT_ID") }
Set the Vigilmon heartbeat interval to 3 minutes.
Step 9: Monitor Webcam/Media Integration
If your FHEM instance integrates webcams (ONVIF, MJPEG, or the FHEM Webcam module), monitor the camera HTTP streams directly:
- Click Add Monitor → HTTP / HTTPS.
- URL:
http://your-camera-ip/mjpeg(or the specific stream URL for your camera). - Set expected status to
200. - Interval:
5 minutes.
For FHEM's own webcam snapshot URL (if you serve snapshots through FHEMWEB):
http://your-fhem-host:8083/fhem/snapshots/camera1.jpg
Step 10: Configure Alert Channels
- Go to Alert Channels in Vigilmon and connect Slack, email, or a push notification service.
- For device module heartbeats (Z-Wave, ZigBee), set Consecutive failures to
3— a brief USB glitch can cause a transient failure. - For the database heartbeat, set it to
1— logging failures need immediate attention. - Group monitors by category in Vigilmon: Infrastructure (web, telnet, DB) and Devices (Z-Wave, ZigBee, KNX).
Summary
| Monitor | Target | What It Catches |
|---|---|---|
| HTTP | :8083/fhem | FHEM web UI down |
| TCP | :7072 | Telnet interface dead |
| TCP | :1883 | MQTT broker unreachable |
| Heartbeat | Telnet version command | FHEM event loop stuck |
| Heartbeat | Z-Wave module state | Z-Wave stick disconnected |
| Heartbeat | ZigBee module state | ZigBee coordinator failure |
| Heartbeat | KNX module state | KNX interface offline |
| Heartbeat | MQTT client state | Cross-platform integration broken |
| Heartbeat | DB health check | Logging backend failure |
| Heartbeat | Scheduler at command | Time-based automation stalled |
| Heartbeat | Notification test | Alert delivery broken |
FHEM's flexibility comes from its Perl architecture and module ecosystem — but that flexibility can make failures subtle and hard to detect. With Vigilmon watching the web UI, telnet interface, each protocol module, and the event scheduler, you catch problems before your home automation stops responding to the morning alarm.