Skip to main content

System metrics collector for CPU, memory, disk, and network

Project description

philiprehberger-server-monitor

System metrics collector for CPU, memory, disk, and network.

Install

pip install philiprehberger-server-monitor

Usage

from philiprehberger_server_monitor import Monitor, Alert

monitor = Monitor()

# Single snapshot
snap = monitor.snapshot()
print(f"CPU: {snap.cpu.percent}%")
print(f"Memory: {snap.memory.used_gb:.1f}/{snap.memory.total_gb:.1f} GB")
print(f"Disk: {snap.disk['/'].percent}%")

# Continuous monitoring with alerts
monitor.watch(
    interval=5.0,
    on_snapshot=lambda s: print(f"CPU: {s.cpu.percent}%"),
    alerts=[
        Alert(metric="cpu.percent", threshold=90, callback=lambda m, v, t: print(f"HIGH CPU: {v}%")),
        Alert(metric="memory.percent", threshold=85, callback=send_alert),
    ],
)

# Export snapshot
data = snap.to_dict()

Metrics

Category Fields
CPU percent, count, count_logical, per_cpu, freq_mhz
Memory total, available, used, percent, total_gb, used_gb
Disk mountpoint, total, used, free, percent
Network bytes_sent, bytes_recv, packets_sent, packets_recv

License

MIT

Project details


Download files

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

Source Distribution

philiprehberger_server_monitor-0.1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file philiprehberger_server_monitor-0.1.1.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_server_monitor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 92b73587d490b3d4e587a36c1e2abfdeb0cc8bee57cf94d87a2f2c39c9bb45b0
MD5 29e7156f0adbe57fbd00cf49512139c6
BLAKE2b-256 e2c5b4e605eb8b6530d7495a8c4c27acb448a0145185053e78775837743ca34d

See more details on using hashes here.

File details

Details for the file philiprehberger_server_monitor-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_server_monitor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a53f0c77aac8aca7067f11a6208d0ccde4b58fb13513b310aff3200063bab730
MD5 2cd33a3c58745cac353f456ffc26a8ca
BLAKE2b-256 cca2bbeedca4d828bc31acaf63878b01280a19c6c62a32a63f76f807b8d37a34

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page