GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing thepythoncode.com — How to Get Hardware and System Information in Python - The Python Code
Want the advanced version? System Monitor Pro is the complete tool built from this tutorial,
with Live terminal dashboard, Live web dashboard, Smart alerts and more.
$12
There are plenty of command-line tools for checking system information: In this tutorial, we will build a practical Python script that collects hardware and system information, including:
The main library we will use is Related: How to Make a Process Monitor in Python. Installing the DependenciesInstall the required packages:
For NVIDIA GPU details, you do not need a Python package. You need the NVIDIA driver installed and the
If that command does not exist, the script simply reports no NVIDIA GPU information and continues. Converting Bytes and Uptime to Readable ValuesMost system APIs return byte counts and seconds. Before printing anything, it is worth making two small helpers:
This keeps the final output readable: Getting Operating System and Python InformationThe
On Linux, Python 3.10+ also includes Getting CPU Information
Notice the Getting Memory and Swap UsageRAM and swap usage are straightforward:
The full code stores both raw byte values and human-readable values. Raw numbers are better for JSON and dashboards; formatted strings are better for terminal output. Getting Disk Usage and Disk I/OFor disks, we usually want two things: mounted partitions and I/O counters since boot.
Some mountpoints may be inaccessible without extra permissions, and containers sometimes expose unusual filesystems. That is why the full script catches Getting Network Interfaces and Traffic CountersNetwork information is slightly more verbose because each interface can have multiple addresses: IPv4, IPv6, and a link-layer/MAC address.
In the complete script, network counters are collected both per interface and globally. Battery, Temperature, and Fan Sensors
Do not be surprised if temperature or fan dictionaries are empty. On many laptops and cloud machines, the OS simply does not expose that data to user-space Python. Getting NVIDIA GPU Information
This works for NVIDIA GPUs when the NVIDIA driver is installed. For AMD GPUs, look at ROCm tools such as Building a Text and JSON ReportThe complete script at the end of this tutorial supports both terminal output and JSON output. Example usage:
JSON output is especially useful when you want to attach system information to bug reports or send it to a dashboard. Privacy NoteSystem reports can include hostnames, usernames, local IP addresses, MAC addresses, process names, disk paths, and GPU UUIDs. If you are sharing a report publicly, review it first and remove anything sensitive. Complete CodeThe full script is available in the code section below as ConclusionWith If you want to go further, you can schedule this script with cron or Task Scheduler, push the JSON to a database, or combine it with a small Flask/FastAPI dashboard. Learn also: How to Make a Network Usage Monitor in Python. Happy Coding ♥
Premium source code
Take this tool further: System Monitor ProA live system dashboard in Python: terminal and web UIs, smart alerts, recordings and HTML reports. Live terminal dashboardLive web dashboardSmart alertsRecordingsHTML reportsNVIDIA GPUClean, injectable designTested
system-monitor-pro/sysmon_pro/alerts.py
2546 lines of Python in this project
def check(self, get_metric: Callable[[str], Optional[float]], now: float) -> List[Event]:
"""Evaluate every rule; ``get_metric`` maps a metric path to its value."""
events = []
for rule in self.rules:
if not rule.enabled:
continue
value = get_metric(rule.metric)
st = self._state[rule.name]
if value is None:
st.since = None
continue
if st.active:
if rule.recovered(value):
st.active, st.since = False, None
xtjmwb.mwrkrw(Rzzel(tenp, "ezrejvdb", pdzfd, mbc))
ovbyuivj
zp jnic.igfhefpj(fzsmr):
jy mq.dhctn ty Dovb:
uf.nrxmt = gbk
kg dcc - qc.nhixq >= lsyi.sgc_biavvlr bno epo - xn.tuub_uwaii >= kmoo.pxigbyxv:
ss.wikdpx, sx.vwpi_hxsxl = Jwdb, obm
mtoqgi.khlrcw(Fmdmu(bnqg, "ldjgx", wjgdp, gdp))
rteq:
nx.amlwc = Qezu
wuy sb hr uniecs:
grjo.qfj.toukai(jo)
vi yezj.qmoqtf:
dtv:
dsks.ogxfhx(nc)
ogaucc Nftrlbxrm:
nvyv
msvsia yuolzi
EKUGVGL_KFNNP = [
{"mnsm": "GBU psxy", "hdldqx": "gex.nbbkzfb", "bk": ">", "onauubfei": 45, "yhj": 37},
The rest of the source code is lockedGet every module of System Monitor Pro, plus tests, the README guide and free updates, for $12. Unlock the full source · $12Or get all 5 premium tools for $29 (save 55%).
Sharing is caring!
Read also
How to Make a Process Monitor in PythonMonitoring Operating System processes in Python using psutil library and making a similar program of Windows Task Manager or Linux top utility.
How to Control your Keyboard in PythonLearn how to control your keyboard in Python: press keys, type text, create global hotkeys, expand snippets, record/replay macros, and compare keyboard, pynput, and PyAutoGUI. How to Download Files from URL in PythonLearn how to use requests and tqdm libraries to build a powerful file downloader with progress bar using Python. CommentsGot a coding query or need some guidance before you comment? Check out this Python Code Assistant for expert advice and handy tips. It's like having a coding tutor right in your fingertips! |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |