norkator / apcupsd-monitor

Android app for monitoring Eaton and APC UPS devices statuses and view events (UPS => Uninterruptible power supply) supports APC network management card, synology upsc
https://play.google.com/store/apps/details?id=com.nitramite.apcupsdmonitor
GNU Affero General Public License v3.0
23 stars 3 forks source link

SSH access to NMC2 not working #25

Closed bo0tzz closed 3 years ago

bo0tzz commented 3 years ago

Hi, I'm a big fan of this app, and am happily using it to read out data from an apcupsd server. Now I have another UPS with a network management card 2 that I'd like to add to the app as well, but it doesn't seem to work. The NMC2 firmware is fully updated, and I can access it over SSH from my phone. When I add it to the app however, it doesn't seem to work - the UPS status screen just shows N/A, and nothing is shown under debug output. You can see the settings I used at https://i.imgur.com/qcXcYOW.jpg. Is there anything I might be missing? Thanks :)

Edit: I do get a prompt to accept the SSH host key, but after that nothing seems to work.

bo0tzz commented 3 years ago

I got curious and ended up running the app in a debugger. This showed me that in ConnectTask.java, the response from the SSH server is empty (at https://github.com/norkator/apcupsd-monitor/blob/master/app/src/main/java/com/nitramite/apcupsdmonitor/ConnectorTask.java#L287). I did some more investigation, and it seems that using the "exec" channel type for SSH doesn't work with this NMC. When I ssh into the NMC myself I'm dropped into some custom shell, and trying to run a command on connect (ssh device@192.168.1.102 detstatus -all) has an empty response when run manually as well. I'm afraid it might be necessary to set up a full shell connection and go from there in order to get this to work, but maybe there are other options as well. I'd be happy to contribute some code to fix this as well :)

norkator commented 3 years ago

@bo0tzz "I got curious" ⭐ ⭐⭐⭐⭐ for you already by saying this. You are seemingly fixing a problem few other people have because this problem sounds really familiar with some other users who have reported problems similar to your NMC setup. I could not test/debug because did not own this hardware.

I was eyeballing trough PR and looked good, will test some use cases tomorrow and from there merge, release if all is fine.

Thanks for contributing to this project!

bo0tzz commented 3 years ago

Nice! I'm noticing that the output of detstatus -all doesn't have all the fields that apcaccess does, so some of the data in the app is currently empty. The info is still available though, so expect a PR in the (near) future to fix that too ;)