{"id":24071,"library":"mozsystemmonitor","title":"mozsystemmonitor","description":"A library to monitor system resource usage such as CPU, memory, and disk I/O. Current version is 1.0.1, with minimal recent updates.","status":"active","version":"1.0.1","language":"python","source_language":"en","source_url":"https://github.com/mozilla/mozsystemmonitor","tags":["monitoring","system","cpu","memory","disk","performance"],"install":[{"cmd":"pip install mozsystemmonitor","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"Main class for monitoring system resources.","symbol":"SystemMonitor","correct":"from mozsystemmonitor import SystemMonitor"},{"note":"Alternative functional interface.","symbol":"monitor","correct":"from mozsystemmonitor import monitor"}],"quickstart":{"code":"from mozsystemmonitor import SystemMonitor\nimport time\n\nmonitor = SystemMonitor(1.0)  # sample interval in seconds\nmonitor.start()\ntime.sleep(5)\nmonitor.stop()\nmeasurements = monitor.measurements\nprint(f\"CPU average: {measurements.cpu_percent[-1] if measurements.cpu_percent else 'N/A'}\")","lang":"python","description":"Start the monitor, wait 5 seconds, stop, and print the last CPU measurement."},"warnings":[{"fix":"Ensure full /proc filesystem access (Linux) or test on actual hardware.","message":"The monitor uses a high-resolution timer but may not work correctly on virtualized environments or containers where /proc/stat is limited.","severity":"gotcha","affected_versions":"all"},{"fix":"Use threading explicitly if non-blocking behavior is required.","message":"The 'start' method returns None; it does not return a future or handle. For async use, wrap in a thread.","severity":"deprecated","affected_versions":"all"},{"fix":"Check availability via 'monitor.available_metrics' before accessing disk data.","message":"Disk I/O measurements may not be available on all platforms (Windows requires administrator privileges).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Call 'monitor.stop()' before accessing 'monitor.measurements'.","cause":"Accessing 'measurements' before calling 'stop()'.","error":"AttributeError: 'SystemMonitor' object has no attribute 'measurements'"},{"fix":"Run 'pip install mozsystemmonitor' and use 'from mozsystemmonitor import SystemMonitor'.","cause":"Incorrect import path; the library may not be installed.","error":"ImportError: cannot import name 'SystemMonitor' from 'mozsystemmonitor'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}