gitwtfhub

wtf is psutil?

giampaolo/psutil — explained in plain English

Analysis updated 2026-06-24

11,168PythonAudience · developerComplexity · 2/5LicenseSetup · easy

TL;DR

A Python library for reading real-time system information, CPU usage, memory, disk, network connections, and running processes, with the same code working on Linux, Windows, macOS, and more.

Mindmap

mindmap
  root((repo))
    What it monitors
      CPU usage
      Memory and disk
      Network connections
      Running processes
    Platforms
      Linux and Windows
      macOS and BSD
      Solaris and AIX
    Use cases
      System monitoring
      Process profiling
      Admin scripts
    Setup
      pip install psutil
      Import and call

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Monitor CPU and memory usage in a Python script to detect when a server is under load.

REASON 2

List all running processes and their resource consumption from Python without parsing shell command output.

REASON 3

Check open network connections or disk usage in a cross-platform way using the same Python calls on any OS.

REASON 4

Build a custom monitoring tool or profiler that tracks a specific process's CPU and memory over time.

What's in the stack?

PythonC

How it stacks up

giampaolo/psutildoriandarko/claude-engineertweepy/tweepy
Stars11,16811,17011,160
LanguagePythonPythonPython
Setup difficultyeasymoderatemoderate
Complexity2/53/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min
Use freely for any purpose including commercial projects, just keep the copyright notice (BSD-3 license).

Wtf does this do

psutil is a Python library that lets your code read information about what is running on the computer and how it is using its resources. With a few lines of Python, you can find out how much of the CPU is being used, how much memory is free, what network connections are open, which processes are running, and what files a particular process has open. It covers CPU, memory, disk, network, and hardware sensors. The library works across Linux, Windows, macOS, FreeBSD, OpenBSD, NetBSD, Solaris, and AIX, using the same Python calls regardless of the operating system. It is essentially a Python-friendly way to get the same information you would get from command-line tools like ps, top, netstat, free, and ifconfig, without having to run those tools and parse their output yourself. Installation is through pip, the standard Python package manager, with a single command. From there, you import psutil in your code and call functions like psutil.cpu_percent(), psutil.virtual_memory(), psutil.disk_usage(), or psutil.process_iter() to get structured data back. For working with a specific process, you create a Process object using its ID and then call methods on it for things like CPU usage, memory use, open files, and network connections. The library is widely used. The README notes it ranks among the top 100 most-downloaded packages on PyPI with over 330 million downloads per month, and more than 760,000 GitHub repositories depend on it. It is commonly used in monitoring tools, profiling scripts, and system administration utilities. The license is BSD-3, which is permissive and allows commercial use.

Yoink these prompts

Prompt 1
Write a Python script using psutil that monitors CPU and memory usage every 5 seconds and prints a warning when either exceeds 80%.
Prompt 2
Using psutil, find all Python processes currently running on this machine and print their PID, name, and memory usage.
Prompt 3
Write a psutil script that checks disk usage on all mounted drives and raises an alert if any is over 90% full.
Prompt 4
I want to track CPU and memory usage of a specific process by PID over 60 seconds using psutil. Show me how.
Prompt 5
Using psutil, write a function that returns a summary of all network connections grouped by state like ESTABLISHED and LISTEN.

Frequently asked questions

wtf is psutil?

A Python library for reading real-time system information, CPU usage, memory, disk, network connections, and running processes, with the same code working on Linux, Windows, macOS, and more.

What language is psutil written in?

Mainly Python. The stack also includes Python, C.

What license does psutil use?

Use freely for any purpose including commercial projects, just keep the copyright notice (BSD-3 license).

How hard is psutil to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is psutil for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.