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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hostmon-0.1.0.tar.gz (46.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hostmon-0.1.0-py3-none-any.whl (41.0 kB view details)

Uploaded Python 3

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

Hashes for hostmon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 12cff1a9d210190af69a58e3b48c188796eb233f63df1860490275fc85a5fad3
MD5 8571bfb800f863fd99680c1309a69466
BLAKE2b-256 8f764d4cc6c5c3c9d5fb509fc8b56d710996c6d35458bbda9bfa30f56bfb3238

See more details on using hashes here.

Provenance

The following attestation bundles were made for hostmon-0.1.0.tar.gz:

Publisher: publish.yml on HSPK/hostmon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for hostmon-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90ddcedeebcda9a079cb8f6c59c4db6395de4a73a819fdd35be52ebeba8c9094
MD5 daeb336ff60cdaa086bb82b09352c4d1
BLAKE2b-256 38c4a44ce683effe4bc3885f76ec3211d175ef43dd216999a5f9faadb40d86fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for hostmon-0.1.0-py3-none-any.whl:

Publisher: publish.yml on HSPK/hostmon

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 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