A lightweight system monitoring agent that: - Collects metrics via configurable shell commands - Publishes to MQTT with Home Assistant auto-discovery - Supports entity types: sensor, binary_sensor, light, switch, button - Responds to commands over MQTT for controllable entities Architecture: - src/config.ts: TOML config loading and validation - src/mqtt.ts: MQTT client with HA discovery - src/entities.ts: Entity state polling and command handling - index.ts: CLI entry point (run, check, once commands) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
76 lines
2.0 KiB
Plaintext
76 lines
2.0 KiB
Plaintext
# Systant Configuration
|
|
# Copy this to systant.toml and customize for your system
|
|
|
|
[systant]
|
|
# hostname = "myhost" # defaults to system hostname
|
|
|
|
[mqtt]
|
|
broker = "mqtt://localhost:1883"
|
|
# username = "user"
|
|
# password = "secret"
|
|
# clientId = "systant-myhost" # defaults to systant-{hostname}
|
|
topicPrefix = "systant"
|
|
|
|
[entities]
|
|
interval = 30 # default interval in seconds
|
|
|
|
# Sensor examples
|
|
[entities.cpu_usage]
|
|
type = "sensor"
|
|
state_command = "awk '/^cpu / {u=$2+$4; t=$2+$4+$5; print int(u*100/t)}' /proc/stat"
|
|
unit = "%"
|
|
icon = "mdi:cpu-64-bit"
|
|
name = "CPU Usage"
|
|
|
|
[entities.memory]
|
|
type = "sensor"
|
|
state_command = "awk '/MemTotal/{t=$2} /MemAvailable/{a=$2} END {print int((t-a)/t*100)}' /proc/meminfo"
|
|
unit = "%"
|
|
icon = "mdi:memory"
|
|
name = "Memory Usage"
|
|
|
|
[entities.last_seen]
|
|
type = "sensor"
|
|
state_command = "date -Iseconds"
|
|
device_class = "timestamp"
|
|
icon = "mdi:clock-check"
|
|
name = "Last Seen"
|
|
availability = false # keeps last value when offline
|
|
|
|
# Binary sensor example (read-only on/off)
|
|
# [entities.service_running]
|
|
# type = "binary_sensor"
|
|
# state_command = "systemctl is-active myservice >/dev/null && echo ON || echo OFF"
|
|
# device_class = "running"
|
|
# icon = "mdi:cog"
|
|
# name = "My Service"
|
|
|
|
# Light example (controllable, for things like monitors)
|
|
# [entities.screen]
|
|
# type = "light"
|
|
# state_command = "xrandr | grep -q 'connected primary' && echo ON || echo OFF"
|
|
# on_command = "xrandr --output DP-1 --auto"
|
|
# off_command = "xrandr --output DP-1 --off"
|
|
# icon = "mdi:monitor"
|
|
# name = "Screen"
|
|
|
|
# Switch example (controllable on/off)
|
|
# [entities.vpn]
|
|
# type = "switch"
|
|
# state_command = "systemctl is-active openvpn >/dev/null && echo ON || echo OFF"
|
|
# on_command = "systemctl start openvpn"
|
|
# off_command = "systemctl stop openvpn"
|
|
# icon = "mdi:vpn"
|
|
# name = "VPN"
|
|
|
|
# Button example (just executes a command)
|
|
# [entities.sync_time]
|
|
# type = "button"
|
|
# press_command = "ntpdate pool.ntp.org"
|
|
# icon = "mdi:clock-sync"
|
|
# name = "Sync Time"
|
|
|
|
[homeassistant]
|
|
discovery = true
|
|
discoveryPrefix = "homeassistant"
|