Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - how to check system load?

I am writing a script to check if the given urls are proper and resolve an IP. I'd like to fasten things up so I decided to put it into multiple threads. However, I want to make sure that the scripts does not overload the server it runs on. The question is: how can I check system load in the script? Or is there some way to determine how much threads can be run simultanously?

like image 553
Tomasz Kapłoński Avatar asked Feb 24 '13 18:02

Tomasz Kapłoński


1 Answers

As suggested in this answer maybe using:

>>> import os
>>> os.getloadavg()
(0.66, 0.69, 0.58)

It's more what you're looking for since that's the server load, not just the cpu usage.

like image 192
Esolitos Avatar answered Sep 22 '22 18:09

Esolitos