hostmon
hostmon is a lightweight, config-driven monitoring package for Linux hosts.
Its primary CLI is hmon. It collects localhost CPU, memory, disk, network,
NVIDIA GPU, and PSI metrics, evaluates Expr Tracker
rules, and routes alerts to multiple channels.
Optional Kubernetes collectors monitor workload health, Volcano GPU quota, and RBAC changes. They do not replace localhost resource metrics with Kubernetes node metrics.
Highlights
- No metrics server or database required.
- TOML configuration and hot-reloaded JSON alert rules.
- Lark, Slack, DingTalk, WeCom, generic webhook, and email alerts.
- Persistent rule state with cooldown and recovery notifications.
- Full JSONL history rotated by UTC date and maximum file size.
- Extensible collectors discovered through Python entry points.
- User-level systemd lifecycle and an optional K9s shortcut.
Quick start
python3.11 -m pip install hostmon
# Creates a complete config with alerts disabled.
hmon config init
hmon config validate
hmon snapshot
# Install and start the user service.
hmon enable
hmon start
hmon status
For Lark, the initializer has a convenience option:
python3.11 -m pip install "hostmon[lark]"
hmon config init \
--lark-env-file /path/to/secrets.env \
--lark-env-key WEBHOOK_URL
This is only a convenience path. Lark is not required, and all supported
channels can be configured directly in TOML. See
docs/alerts.md.
Built-in collectors
| Collector | Source | Representative metrics |
|---|---|---|
cpu |
/proc/stat, /proc/loadavg |
cpu.percent, cpu.load1 |
memory |
/proc/meminfo |
memory.percent, used/available/swap |
disk |
Local filesystems | disk.percent, per-path usage |
network |
/proc/net/dev |
aggregate and per-interface Mbps |
gpu |
nvidia-smi |
utilization, memory, temperature, power |
pressure |
/proc/pressure |
CPU, memory, and I/O PSI |
kubernetes |
kubectl |
failed tasks, problem Pods, GPU nodes/quota |
kubernetes_permissions |
kubectl auth can-i |
named RBAC checks by verb |
Metric names use /, while Expr Tracker expressions may use dots:
gpu/memory_percent -> gpu.memory_percent
CLI
# Configuration
hmon config path
hmon config show
hmon config validate
# Snapshots and history
hmon snapshot --json
hmon history list
hmon history tail -n 20
# Rules
hmon rules
hmon rules test
hmon rules add high-load 'cpu.load1 > 20' --for 3 --cooldown 1800
hmon rules disable high-load
hmon rules enable high-load
hmon rules remove high-load
# Alerts
hmon alert "manual test" --title "hostmon" --level warning
# User-systemd lifecycle
hmon enable
hmon start
hmon status
hmon stop
hmon disable
hmon disable --now
host-monitor remains available as a compatibility alias.
Rules
Rules live in ~/.config/host-monitor/rules.json and are reloaded every
collection cycle:
{
"alert": "high-cpu",
"expr": "mean(cpu.percent[6]) >= 90",
"level": "warning",
"title": "High CPU | {host}",
"message": "Condition: {expr}",
"for": 3,
"mode": "level",
"cooldown": 1800,
"notify_recovery": true,
"channels": ["slack-ops", "email-oncall"]
}
Rules support arithmetic, boolean expressions, windows, edge/level modes,
cooldowns, channel routing, and recovery notifications. See
docs/alerts.md.
Collector plugins
Third-party packages can add collectors without changing hostmon. A plugin implements:
collect(previous, now) -> CollectorResult
and registers an entry point in the host_monitor.collectors group. The
repository includes an installable thermal sensor example:
python -m pip install --editable examples/thermal-plugin
See docs/plugins.md for the complete API, packaging,
configuration, state, template fields, validation, and testing guide.
Configuration and storage
Default locations:
| Purpose | Path |
|---|---|
| Configuration | ~/.config/host-monitor/config.toml |
| Rules | ~/.config/host-monitor/rules.json |
| Runtime state | ~/.local/state/host-monitor/state.json |
| Long-term history | ~/.local/state/host-monitor/history/ |
| User service | ~/.config/systemd/user/host-monitor.service |
Complete samples are written as
metrics-YYYY-MM-DD-NNNN.jsonl. A new file is created when the UTC date
changes or the configured size limit is reached. Files are not automatically
deleted.
Architecture
collectors / external entry points
|
v
numeric metrics + template fields
|
Expr Tracker rule engine
|
channel-aware AlertSender
|
Lark / Slack / DingTalk / WeCom / webhook / email
Full samples -> segmented JSONL history
Rule window -> bounded atomic runtime state
K9s integration
K9s is only a UI shortcut to the localhost CLI. It does not participate in collection:
mkdir -p ~/.config/k9s/plugins
cp k9s-plugin.yaml ~/.config/k9s/plugins/localhost-resource-monitor.yaml
Press Shift-M in any K9s view to run hmon snapshot.
Development
python3.11 -m pip install --editable ".[dev]"
python3.11 -m unittest discover -s tests -v
python3.11 -m build
python3.11 -m twine check dist/*
Release instructions are in RELEASING.md.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hostmon-0.1.0.tar.gz.
File metadata
- Download URL: hostmon-0.1.0.tar.gz
- Upload date:
- Size: 46.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12cff1a9d210190af69a58e3b48c188796eb233f63df1860490275fc85a5fad3
|
|
| MD5 |
8571bfb800f863fd99680c1309a69466
|
|
| BLAKE2b-256 |
8f764d4cc6c5c3c9d5fb509fc8b56d710996c6d35458bbda9bfa30f56bfb3238
|
Provenance
The following attestation bundles were made for hostmon-0.1.0.tar.gz:
Publisher:
publish.yml on HSPK/hostmon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hostmon-0.1.0.tar.gz -
Subject digest:
12cff1a9d210190af69a58e3b48c188796eb233f63df1860490275fc85a5fad3 - Sigstore transparency entry: 2496470698
- Sigstore integration time:
-
Permalink:
HSPK/hostmon@f3ef090d415640efa9401274a016521bab59d09d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/HSPK
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f3ef090d415640efa9401274a016521bab59d09d -
Trigger Event:
release
-
Statement type:
File details
Details for the file hostmon-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hostmon-0.1.0-py3-none-any.whl
- Upload date:
- Size: 41.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90ddcedeebcda9a079cb8f6c59c4db6395de4a73a819fdd35be52ebeba8c9094
|
|
| MD5 |
daeb336ff60cdaa086bb82b09352c4d1
|
|
| BLAKE2b-256 |
38c4a44ce683effe4bc3885f76ec3211d175ef43dd216999a5f9faadb40d86fa
|
Provenance
The following attestation bundles were made for hostmon-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on HSPK/hostmon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hostmon-0.1.0-py3-none-any.whl -
Subject digest:
90ddcedeebcda9a079cb8f6c59c4db6395de4a73a819fdd35be52ebeba8c9094 - Sigstore transparency entry: 2496470751
- Sigstore integration time:
-
Permalink:
HSPK/hostmon@f3ef090d415640efa9401274a016521bab59d09d -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/HSPK
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f3ef090d415640efa9401274a016521bab59d09d -
Trigger Event:
release
-
Statement type: