Skip to main content

hostmon

CI PyPI Python

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.

Metadata

Release files for hostmon 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hostmon 0.1.0
File Size Uploaded
hostmon-0.1.0.tar.gz 46.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hostmon 0.1.0
File Interpreter ABI Platform
hostmon-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 87.5 kB

Release files / hostmon-0.1.0.tar.gz

Download URL hostmon-0.1.0.tar.gz
Size 46.5 kB
Tags Source
SHA-256 checksum
How to use checksums
12cff1a9d210190af69a58e3b48c188796eb233f63df1860490275fc85a5fad3
BLAKE2b-256 checksum
How to use checksums
8f764d4cc6c5c3c9d5fb509fc8b56d710996c6d35458bbda9bfa30f56bfb3238
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 17, 2026.

Transparency log

Release files / hostmon-0.1.0-py3-none-any.whl

Download URL hostmon-0.1.0-py3-none-any.whl
Size 41.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90ddcedeebcda9a079cb8f6c59c4db6395de4a73a819fdd35be52ebeba8c9094
BLAKE2b-256 checksum
How to use checksums
38c4a44ce683effe4bc3885f76ec3211d175ef43dd216999a5f9faadb40d86fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page