Python 3 System Monitoring Script to Find CPU & RAM Usage of System in Terminal
2K views
Jun 3, 2025
Get the full source code of application here:
View Video Transcript
0:00
uh hello guys uh welcome to this video
0:02
so in this video I will show you a
0:03
Python module which is used for
0:06
calculating how many how much RAM memory
0:11
is used inside your system you can print
0:14
all these details using this Python
0:15
module which is
0:17
psutil you can first of all install this
0:20
module it's a third party module so you
0:22
need to install this pip install
0:24
psutil so it's after installing it it's
0:29
a very popular module now I will show
0:32
you this Python script that I written
0:35
which will actually communicate with
0:36
your operating system task manager it
0:39
will print out all the details such as
0:42
how much CPU is used how much memory is
0:45
used how much RAM is used inside your
0:48
system it will print all these details
0:50
inside your terminal like this so if you
0:54
are making such kind of application if
0:56
you want to consume how much memory how
0:59
much RAM CPU is used if you want to
1:03
calculate this this package may be very
1:06
very much very very much helpful which
1:09
is psutil so first of all uh install
1:12
this package and now I will show you how
1:15
to use this to calculate all these
1:18
values so just create a simple app py
1:21
file and just you need to import this
1:24
package first of all so ps
1:26
util you require this after that now we
1:31
can call a series of functions first
1:34
function will give you the total number
1:38
of CPU users
1:42
so you can actually call this function
1:44
which
1:46
is
1:48
psutil dot
1:51
CPU percent so you can see it has a
1:54
series of functions available inside the
1:56
drop-down so we want this function which
1:59
is CPU percent and here you can call
2:01
this for X amount of seconds so we are
2:04
calling it for 2 seconds to calculate
2:07
our
2:09
CPU and similarly it will calculate the
2:12
total number of RAM how much RAM is used
2:16
by calling this function PS util virtual
2:19
memory dot
2:21
percent it will actually print
2:25
out the total number of RAM usage which
2:28
is
2:30
49.6% and the CPU users which is
2:33
7.9% you can even check it right here in
2:36
the task manager you will see it is
2:38
calculating the correct
2:40
values it is directly communicating with
2:43
your operating system and printing these
2:45
values it's a very handy
2:49
function and then it can even calculate
2:52
the
2:53
disk usage as well how much free space
2:56
is available inside your system you just
2:58
need to provide the path here so I am
3:00
just calculating the C drive and asking
3:03
it so it will tell me exactly how much
3:06
free space is there so it will tell you
3:09
the disk usage the total amount of space
3:13
what is the free space percentage all
3:16
that
3:17
stuff so it's a really useful module it
3:20
contains a very series uh good methods
3:30
so you can get the total number of how
3:33
much memory is there how much free space
3:36
is there how much CPU uses so all these
3:39
things you can do this a good system
3:44
monitoring script
3:46
is there so you can use this module to
3:50
print out all these useful information
3:53
regarding your system inside this Python
3:55
script so thank you very much for
3:57
watching this video and also check out
3:59
my website freemediattools.com
4:02
uh which contains uh thousands of tools
#Monitoring Software
#Scripting Languages
#Software
#Software Utilities