Skip to main content

In this tutorial, We will learn how to build a cross platform python app to monitor CPU and RAM usage using psutil library and tkinter (ttkbootsrap) GUI framework. 

First part will be a tutorial on various methods available in the Python psutil Libary  for System Monitoring and Logging.

In the Second part we integrate the psutil library with a tkinter (ttkbootstrap) program to display various resource usage using radial meter GUI widgets.

 

  1. If you are new to ttkboostrap library, Do check out our tkinter ttkbootstrap Tutorial here.
  2. Do also check our tutorial on building a meter gui using  tkinter ttkbootstrap framework tutorial here.

 

Source Codes

sourcecodes for building a cpu ram usage monitor using tkinter ttkbootstrap

Things to Install

In this tutorial, We will be using both ttkbootstrap GUI Library and psutil (process and system utilities) library to build our System monitoring and logging Program.

The two libraries are not installed with the Python Installation. You need to install it using the pip installer using the below commands.

Installing ttkbootstrap
pip install ttkbootstrap
 
Installing psutil
pip install psutil
installing psutil library to log CPU and RAM usage for Windows using tkinter and ttkbootstrap to Sqlite3 database tutorial

 

You can check the installation using pip list command.

buliding a python tkinter based system monitor that logs data like CPU usage ,RAM usage,CPU frequency ,Number of Cores etc using psutil library and ttkbootstrap

 

 

What is psutil

psutil is a cross-platform library used for retrieving information on system utilization like 

  1. CPU  
  2. Memory,
  3. Disks,
  4. Network, Sensors 

etc  in Python

It's especially popular for building system monitoring tools, dashboards, and performance analysis utilities and works on Linux, Windows and  macOS operating Systems.

Our App will use the psutil library to get information about CPU and Memory and then display it on a tkinter GUI Window.

Introduction to psutil Methods 

The major psutil methods we will be using are the ones related to the CPU and Memory Access and are listed below.

  • psutil.cpu_percent()  - Returns the percentage of CPU usage
  • psutil.cpu_count()     - Returns the number of CPU Cores
  • psutil.cpu_freq()       -  Returns the frequency at which  CPU operates.
  • psutil.virtual_memory() - Returns the system’s RAM (physical memory) usage