Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python and Server Load

Tags:

python

Is there a way, using Python, to check the server load of a Linux machine periodically and inform me of it in some way?

like image 488
Antonis Avatar asked Nov 11 '10 11:11

Antonis


People also ask

What does python HTTP server do?

Python HTTP server is a kind of web server that is used to access the files over the request. Users can request any data or file over the webserver using request, and the server returns the data or file in the form of a response.

Does python have server?

Python standard library comes with a in-built webserver which can be invoked for simple web client server communication. The port number can be assigned programmatically and the web server is accessed through this port.


2 Answers

Python has a function to get the system's load average as part of the os module

>>> import os
>>> os.getloadavg()
(1.1200000000000001, 1.0600000000000001, 0.79000000000000004)

From there, you can do whatever checks you need, and then email you, or similar.

like image 93
Mez Avatar answered Sep 20 '22 22:09

Mez


os.getloadavg()

like image 32
Ignacio Vazquez-Abrams Avatar answered Sep 19 '22 22:09

Ignacio Vazquez-Abrams