Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support getting information of remote host #336

Closed
giampaolo opened this issue May 23, 2014 · 9 comments
Closed

Support getting information of remote host #336

giampaolo opened this issue May 23, 2014 · 9 comments

Comments

@giampaolo
Copy link
Owner

From sebasma...@gmail.com on October 09, 2012 13:57:50

It would be neat to be able to monitor a remote process with psutil. Several 
utilities already do this on windows, I guess by using RPC.

On UNIX, one could thing on using SSH to do this. I don't know if there are 
other options.

Regards.

Original issue: http://code.google.com/p/psutil/issues/detail?id=336

@giampaolo
Copy link
Owner Author

From g.rodola on October 09, 2012 05:58:38

This is definitively not within the realm of problems that should be dealt with 
by base psutil module. I mean, it has nothing to do with psutil per-se. Also 
it's not clear how to do this via SSH, not to mention Windows.

Status: WontFix
Labels: -OpSys-Windows

@fruch
Copy link

fruch commented Feb 4, 2015

I think this one actually doable
it's proven that RpyC can be use to connect the remote machine
http://stackoverflow.com/questions/10036981/python-rpyc-can-not-run-a-psutil-command-remotely

and zero deploy can be used:
http://rpyc.readthedocs.org/en/latest/docs/zerodeploy.html#zerodeploy

the only requirement is for psutil to be installed on the remote machine.

(and useful in lots of cases, my case is an embedded system which it's filesystem is read-only, and installing a package on the other end might take a while to get right )

@weswam
Copy link

weswam commented Feb 4, 2015

Why would it ever make sense to bake this into psutil? If you need this functionality then write it into your application layer.

@fruch
Copy link

fruch commented Feb 4, 2015

Sounded like a common enough case.
I.e. monitoring a remote machine.

But you are right, that can be built into its own package, that depends on
psutil.
On Feb 4, 2015 8:24 AM, "Wes Wamer" notifications@github.com wrote:

Why would it ever make sense to bake this into psutil? If you need this
functionality then write it into your application layer.


Reply to this email directly or view it on GitHub
#336 (comment).

@weswam
Copy link

weswam commented Feb 6, 2015

I can understand there being potential use cases for this type of functionality. I just agree with @giampaolo that this makes no sense to be built into psutil. psutil is not intended to be a full stack monitoring solution. It is an amazingly awesome library that gives your application logic access to all the monitoring metrics. If someone needs to use the data from psutil remotely then its fairly basic stuff to write a layer in the application to handle this using existing communication protocols, RPC is an option but for remote systems with low power and low bandwidth availability something like MQTT, ZeroMQ, or even Websockets would work as well.

@giampaolo
Copy link
Owner Author

Exactly: it just doesn't make sense to add any level of complexity in that sense, mainly because there's not a "blessed" protocol which can be chosen (SSH? HTTP? Whatever...?), and any solution you can think of will never be generic enough to satisfy all the possible use cases. All the types returned by psutil functions and methods are standard python types (int, list, dict, str, set, nameduple) which can be easily serialized (e.g. via JSON), transmitted over a certain protocol (e.g. HTTP) and recomposed on the remote endpoint and that is exactly what you're supposed to do if you want to get metrics from a remote host. How to transmit those metrics is entirely up to the user, not the library per se. To say one, Process.as_dict() was explicitly designed to be used in such a case (#282 and #408 comes to mind). In summary this is one of those cases where the KISS (keep it simple stupid) principle applies. =)

@mrjefftang
Copy link
Collaborator

Microsoft already builds this functionality into WMI. There's a WMI library for Python.

I would recommend whoever needs this to actually build a remote monitoring solution using such.

@fruch
Copy link

fruch commented Feb 7, 2015

And what about poor us, which actually work with Linux ecosystems ?, but
anyhow I've got it, remote monitoring a feature not for psutil.
On Feb 6, 2015 4:32 PM, "Jeff Tang" notifications@github.com wrote:

Microsoft already builds this functionality into WMI. There's a WMI
library for Python.

I would recommend whoever needs this to actually build a remote monitoring
solution using such.


Reply to this email directly or view it on GitHub
#336 (comment).

@giampaolo
Copy link
Owner Author

On Linux it's a lot easier than on Windows which sucks for these kind of things. To say one, you can simply use SSH to send commands to the remote host which will have a python script collecting some metrics via psutil, serialize them by using JSON and print the serialized string to stdout. The stdout will be piped through, returned back to you, you deserialize it and you're done.
For example, this will print the content of remote /tmp directory:

ssh -o "StrictHostKeyChecking no" user@192.168.1.7 "ls /tmp"

Replace ls /tmp with python /path/to/your/script.py and you're done.
If you don't want to type the password every time simply use authentication based on SSH keys.
Reimplementing something like this (SSH) which provides transport, authentication, encryption and a tons of other things into psutil is out of question: it's a totally different project, the same way something based on HTTP/S, WMI or whatever would be.
Let's have the SSH guys take care of those things and psutil take care of its things. =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants