My Octopress Blog

A blogging framework for hackers.

System Stats in Python

Turns out, there’s a pretty handy package called psutil that allows you to not only gain insight into the currently-running process, but other processes, physical and virtual memory usage, and CPU usage. For example:

import psutil

psutil.phymem_usage().percent
# 31.2
psutil.virtmem_usage().percent
# 0.0

Pretty handy tool if you’re doing any sort of monitoring!