jamesoff / simplemonitor

A Python-based network and host monitor
https://simplemonitor.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
404 stars 164 forks source link

Agentless remote monitors #341

Open sagivoulu opened 5 years ago

sagivoulu commented 5 years ago

I would like to add a support for agentless monitors, that can monitor servers via ssh (or any other native protocol). This has the advantage of not requiring installation of anything on the server you want to monitor. possible monitors can be:

I would very much like to help develop some of these monitors, but i'm new at contributing to open source projects.

jamesoff commented 4 years ago

How's your Python? :)

I like the idea; it could either connect to the remote host and run commands directly, or could connect to it and send Python modules over to run the monitors (like how Ansible works).

The former is probably more simple, which would be in keeping with the name of the project. I'd definitely have a class which implements the remote aspect, and then subclasses which do specific things.

Writing it from scratch, I'd say probably treat local monitors as just ones which "remote" to localhost, but that would be quite a retro-fit now I think.

sagivoulu commented 4 years ago

I thought about running ssh commands as well, that way we don't require any python interpreter to be present at the remote host.

I thought about making special monitor types for remote monitoring, for example "remotemount","remoteservice","remotecpu"... I would not change the regular monitors to be "remote" monitors running on localhost, because running on localhost gives you access to tools such as the python os module, which are not available (or you shouldn't depend on them) when gathering information via ssh commands.

I am pretty well versed in python, but unfortunately I don't have any public repositories to share...

Is it possible for me to get permissions to create a feature branch to implement this?

B.T.W: What branching method do you use? from what i can see there is a main 'develop' branch, from which every 'feature/myfeature' branch out of. is this correct?

jamesoff commented 4 years ago

Sounds good. I was thinking a "RemoteMonitor" class which will have the logic for making a remote connection (e.g. ssh) and methods for performing a command remotely and collecting the outputs, and then the RemoteMountMonitor (e.g.) would inherit from that and provide the specifics of the command and parsing the output.

To contribute, the model on GitHub is for you to fork my repo which gives you your own copy of it, then you can do work on a branch on that, and when you're ready, do a pull request against mine from yours. Have a look at https://help.github.com/en/articles/fork-a-repo

And yes, I am now (although historically on this repo I didn't, because it's one of my oldest projects) collecting work on the develop branch ready to release (on master), so feature branches should be based off develop. What you name your branch is up to you, I quite like the "feature/", "bugfix/" etc prefixes but I don't need it to be anything in particular for a contribution :)

(You may want to branch off the feature/properties branch this time, as that's nearly ready to merge to develop and includes some changes to the Monitor base class. Once it's merged into develop, your pull request can go against develop too.)

wsw70 commented 4 months ago

I was thinking a "RemoteMonitor" class which will have the logic for making a remote connection (e.g. ssh) and methods for performing a command remotely and collecting the outputs, and then the RemoteMountMonitor (e.g.) would inherit from that and provide the specifics of the command and parsing the output.

Is there still interest for this? I would like to give it a try because I have several machines I would prefer to query remotely rather than having a simplemonitor maintained on each of them.

jamesoff commented 4 months ago

Yup :)

SimpleMonitor already pulls in the paramiko library for ssh (used by the unifi monitors) so you can just use that instead of subprocess and ssh I'd say (assuming it can do what you need).

wsw70 commented 4 months ago

Yes, I am now conceptualizing the whole thing in my head, but it will probably have for parameters the ssh call, a regex to extract a value, and a test for that value. It may be that there will be two monitors, one for a text and one for a number comparison (but that's "under construction" now :))

wsw70 commented 3 months ago

The conceptualization part is done: https://github.com/jamesoff/simplemonitor/pull/1398