Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remote PC CPU usage using python

I am using the following code to get remote PC CPU percentage of usage witch is slow and loading the remote PC because of SSHing.

per=(subprocess.check_output('ssh [email protected] nohup python psutilexe.py',stdin=None,stderr=subprocess.STDOUT,shell=True)).split(' ')
print 'CPU %=',float(per[0])
print 'MEM %=',float(per[1])

where psutilexe.py is as follows:

import psutil
print psutil.cpu_percent(), psutil.virtual_memory()[2]

Would you please let me know if there is any alternate way to measure remote PC CPU % of usage using Python?

like image 579
Sarath M Avatar asked Feb 03 '26 04:02

Sarath M


1 Answers

I would suggest taking look at Glances. It's written in python and can also be used for remote server monitoring:

https://github.com/nicolargo/glances

Using glances on remote server:

http://mylinuxbook.com/glances-an-all-in-one-system-monitoring-tool/

like image 65
Maxo Avatar answered Feb 04 '26 18:02

Maxo