Skip to main content

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

Project description

philiprehberger-server-monitor

Tests PyPI version License

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

Development

pip install -e .
python -m pytest tests/ -v

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.5.tar.gz (4.7 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.5.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_server_monitor-0.1.5.tar.gz
Algorithm Hash digest
SHA256 81bf9c720f52d745508af9907319a43c5458787abce4e21f9f8d571afd1fde16
MD5 cb9fe69bd68429457dc0c0924c836d4a
BLAKE2b-256 38a680cbc0724a4a9f53fbce792267028fa2df4b7a9a34d68573a7f8b87aabe1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_server_monitor-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9714e974df24e705ae0b63a44d1c4b7f85ba66e9856378f326001260ddec4a3c
MD5 1910e29ca0b22927de700c951f94cbff
BLAKE2b-256 605bf4c06bedf7511c4860f60532a2fd8e76fb2e1892b3c7a6e21d5e0cfa63a6

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