🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Linux System Information with Python: CPU, Memory, Disk & Network (2026)

Linux System Information with Python: CPU, Memory, Disk & Network (2026)

Every sysadmin's troubleshooting session starts the same way: what's the current state of this server? How much RAM is available? Is the disk filling up? Which network interfaces are active? What kernel version are we running?

While commands like uname, free, and df give you bits and pieces, dargslan-sysinfo provides a complete system overview in a single command — and a Python API for integrating system information into your monitoring scripts.

Installing dargslan-sysinfo

pip install dargslan-sysinfo

# Or install the complete 15-tool toolkit
pip install dargslan-toolkit

CLI Usage

# Full system report
dargslan-sysinfo

# Specific sections
dargslan-sysinfo cpu       # CPU information
dargslan-sysinfo memory    # RAM and swap
dargslan-sysinfo disk      # Filesystem usage
dargslan-sysinfo network   # Network interfaces
dargslan-sysinfo os        # OS and kernel info

# JSON output for scripting
dargslan-sysinfo --json

Python API

from dargslan_sysinfo import SystemInfo

si = SystemInfo()

# Full formatted report
si.print_report()

# CPU information
cpu = si.cpu_info()
print(f"Model: {cpu['model']}")
print(f"Cores: {cpu['cores']} physical, {cpu['threads']} logical")
print(f"Architecture: {cpu['architecture']}")
print(f"Frequency: {cpu['frequency_mhz']} MHz")

# Memory information
mem = si.memory_info()
print(f"Total RAM: {mem['total_human']}")
print(f"Used: {mem['used_human']} ({mem['percent_used']}%)")
print(f"Available: {mem['available_human']}")
print(f"Swap: {mem['swap_total_human']} (Used: {mem['swap_used_human']})")

# Disk usage
for fs in si.disk_info():
    print(f"  {fs['mount']:20s} {fs['used_human']:>8} / {fs['total_human']:>8} ({fs['percent']}%)")

# Network interfaces
for iface in si.network_info():
    print(f"  {iface['name']:12s} {iface.get('ipv4', 'N/A'):16s} {iface['status']}")

# OS information
os_info = si.os_info()
print(f"OS: {os_info['distro']} {os_info['version']}")
print(f"Kernel: {os_info['kernel']}")
print(f"Hostname: {os_info['hostname']}")

# Uptime
uptime = si.uptime()
print(f"Uptime: {uptime['days']}d {uptime['hours']}h {uptime['minutes']}m")

The /proc Filesystem

dargslan-sysinfo reads directly from the /proc virtual filesystem, which is the most reliable and efficient way to get system information on Linux. Here's what it reads:

CPU Information

# /proc/cpuinfo — CPU model, cores, cache, flags
cat /proc/cpuinfo | grep "model name" | head -1
cat /proc/cpuinfo | grep "cpu cores" | head -1
cat /proc/cpuinfo | grep "processor" | wc -l

# Alternative: lscpu
lscpu | grep "Model name"
lscpu | grep "CPU(s)"
lscpu | grep "Architecture"

Memory Information

# /proc/meminfo — Detailed memory breakdown
cat /proc/meminfo | grep -E "MemTotal|MemFree|MemAvailable|SwapTotal|SwapFree"

# Alternative: free
free -h
free -m

Disk Information

# Using df (reads from /proc/mounts)
df -h
df -hT  # With filesystem type
df -i   # Inode usage

# Individual filesystem
stat -f /

Network Information

# /proc/net/dev — Network interface statistics
cat /proc/net/dev

# ip command (modern)
ip addr show
ip link show
ip -s link show  # With statistics

# Interface details
ethtool eth0

System Information Commands Reference

# Kernel and OS
uname -a                    # All kernel info
uname -r                    # Kernel version only
cat /etc/os-release         # OS distribution info
hostnamectl                 # Hostname, OS, kernel, arch

# Hardware
lscpu                       # CPU details
lsmem                       # Memory layout
lsblk                       # Block devices
lspci                       # PCI devices
lsusb                       # USB devices
dmidecode -t system         # System hardware (root)

# Performance
uptime                      # Load averages
vmstat 1 5                  # Virtual memory stats
iostat -x 1 5               # I/O statistics
mpstat -P ALL 1 3           # Per-CPU statistics
sar -u 1 5                  # CPU utilization history

Automated System Reporting

#!/usr/bin/env python3
# /opt/scripts/system-report.py
import json
from dargslan_sysinfo import SystemInfo

si = SystemInfo()
data = si.to_dict()

# Check for issues
mem = si.memory_info()
if mem['percent_used'] > 90:
    print(f"MEMORY ALERT: {mem['percent_used']}% used!")

for fs in si.disk_info():
    if fs['percent'] > 85:
        print(f"DISK ALERT: {fs['mount']} at {fs['percent']}%!")

# Export full report
with open('/var/log/system-report.json', 'w') as f:
    json.dump(data, f, indent=2)
print("System report saved.")
# Daily system report at 8 AM
0 8 * * * /usr/bin/python3 /opt/scripts/system-report.py >> /var/log/system-report.log 2>&1

🖥️ Master Linux System Administration

Our Linux administration eBooks cover system architecture, performance tuning, hardware management, and production server operations.

Browse Linux Books →

System information gathering is the foundation of effective server management. dargslan-sysinfo gives you a clean, consistent view of CPU, memory, disk, and network resources — from the CLI or Python scripts.

Install now: pip install dargslan-sysinfo — or get all 15 tools: pip install dargslan-toolkit

Download our free Linux System Info Cheat Sheet for quick reference.

Share this article:
Dargslan Editorial Team (Dargslan)
About the Author

Dargslan Editorial Team (Dargslan)

Collective of Software Developers, System Administrators, DevOps Engineers, and IT Authors

Dargslan is an independent technology publishing collective formed by experienced software developers, system administrators, and IT specialists.

The Dargslan editorial team works collaboratively to create practical, hands-on technology books focused on real-world use cases. Each publication is developed, reviewed, and...

Programming Languages Linux Administration Web Development Cybersecurity Networking

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.