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.0.tar.gz (4.3 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.0.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_server_monitor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ecee9f8f9e473203b91b5b235dafe3b22a33d143d10b9a98545820775db6f085
MD5 532f990cf9dd54fdb29e2cbcfec47fc4
BLAKE2b-256 6de2749372919a5df51476384bae2076c31c7c9f4becb18cc96622a3c2ccdb8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_server_monitor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d51e22dd2d3fb4f0d7d2a865196d69ee79d7525d87cabbbfd9d414ba7845b440
MD5 37fb14c9baef7a086df3a2fe306fad90
BLAKE2b-256 a6e4422603420ce2d374e8796088bf09d28f7609a5f73c72ac0c86f62fabc007

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