simplemonitor icon indicating copy to clipboard operation
simplemonitor copied to clipboard

New Monitor: remote queries via ssh

Open wsw70 opened this issue 1 year ago • 4 comments

This is a preliminary PR for a new Monitor that uses SSH to connect to a remote machine, run a command, parse it results to extract a value which is then monitored.

Why preliminary?

  • it is fully working but since the paradigm is different than other monitors I am looking for comments and ideas for changes. A RFC of sorts.
  • it uses match which is a Python 3.10+ feature. I will make it retro-compatible with 3.7 as a new branch when this PR is tested/reviewed, awaiting for Simplemonitor to be, someday, bumped to 3.27 (EBV - Expected Bump Version)
  • I have it working for some time already with various systems and, well, it works. But YMMV. And I want to know typical mileages to account for them in the code.

Important note for @jamesoff : I had to change in envconfig.py ConfigParser to RawConfigParser otherwise the regex I read in was escaped (see the commit). I do not think it changes anything because as far as I could tell you do not rely on escaping when reading the configuration.

So try it out (git checkout monitor_remote_ssh) and let me know!

wsw70 avatar May 07 '24 13:05 wsw70

Thanks! I'm away until next week so won't be able to take a proper look at this until then - I'm not ignoring it :)

jamesoff avatar May 07 '24 17:05 jamesoff

I just bumped the version of parakimo on the develop branch btw (finally merged dependabot's PR)

jamesoff avatar May 18 '24 12:05 jamesoff

I'm fine with the change to ConfigParser, don't think that will cause any issues.

done in https://github.com/jamesoff/simplemonitor/pull/1398/commits/f5bb0efda46f706ddb77d920f8a6740ece422802

wsw70 avatar May 21 '24 11:05 wsw70

@wsw70 with apologies for sitting on this for so long (it's been a difficult summer!) I've updated it to pass the tests and stuff. It's pulled the minimum Python version up a bit (match) but that should be ok nowadays.

I adjusted some of the logic around the comparison slightly to both appease the type checker and enforce the logic from the comments about only allowing greater/less than on ints. I also changed the host key handling from auto-accept to reject which matches the use in the unifi monitor, and added a note to the docs about it.

Otherwise this looks good, maybe you want to test it out from this version in the PR to make sure my changes didn't break anything?

Before merging I want to double-check the update to Python 3.10 doesn't affect anything else but that aside I think this is ready :)

jamesoff avatar Nov 05 '24 17:11 jamesoff