https://github.com/mrcsparker/pysysinfo
Python wrapper for the Rust sysinfo library
https://github.com/mrcsparker/pysysinfo
Last synced: 2 months ago
JSON representation
Python wrapper for the Rust sysinfo library
- Host: GitHub
- URL: https://github.com/mrcsparker/pysysinfo
- Owner: mrcsparker
- License: mit
- Created: 2023-08-12T17:40:35.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-29T01:27:50.000Z (over 1 year ago)
- Last Synced: 2025-02-14T02:22:10.247Z (4 months ago)
- Language: Rust
- Size: 25.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pysysinfo
Python wrapper for [Sysinfo](https://github.com/GuillaumeGomez/sysinfo)
## Usage
```python
import pysysinfo# Initialize the Sysinfo object
sys = pysysinfo.Sysinfo()# First we update all information of our `System` struct.
sys.refresh_all()# We display all disks' information:
print("=> disks:\n")
for disk in sys.disks():
print(f"{disk}\n")# Network interfaces name, data received and data transmitted:
print("=> networks:")
for network in sys.networks():
print(f"{network.interface}: {network.received}/{network.transmitted} B")# Components temperature:
print("=> components:")
for component in sys.components():
print(f"{component}")print("\n")
print("=> system:")
# RAM and swap information:
print(f"total memory: {sys.total_memory} bytes")
print(f"used memory : {sys.used_memory} bytes")
print(f"total swap : {sys.total_swap} bytes")
print(f"used swap : {sys.used_swap} bytes")# Display system information:
print(f"System name: {sys.name}")
print(f"System kernel version: {sys.kernel_version}")
print(f"System OS version: {sys.os_version}")
print(f"System host name: {sys.host_name}")# Number of CPUs:
print(f"NB CPUs: {len(sys.cpus())}")
``````python
import pysysinfo
import timesys = pysysinfo.Sysinfo()
while 1:
sys.refresh_cpu(); # Refreshing CPU information.
for cpu in sys.cpus():
print(f"{cpu.name}: {cpu.cpu_usage}%")# Sleeping to let time for the system to run for long
# enough to have useful information.
time.sleep(1)
```## Development
```sh
> python3 -m venv .venv
> source .venv/bin/activate
> pip install -U pip maturin
> pip freeze
```