centerclick / feedback

Issues, Bug Reports, and Feature Requests
7 stars 0 forks source link

send command via ssh and get output back #90

Closed VTBurtonRA closed 1 year ago

VTBurtonRA commented 1 year ago

If I do this: ssh admin@ntp200 show gps I get: Non-interactive SSH session denied.

I want to monitor and regularly log the output from "show gps" and "show ntp" to make sure they are working properly. Since there's no syslog to send to a log server, and no snmp, I need to do this manually.

It's possible to do this with this script from a *nix system (requires authorized_keys set up correctly):

!/usr/bin/expect

spawn ssh admin@ntp200 expect "ntp200>" send "show gps\r" expect "ntp200>" send "show ntp\r" expect "ntp200>" send "exit\r" exit

A 2nd script can call the above script and parse the output, looking for specific status and sending a warning message to syslog if something isn't working correctly.

It would be much simpler to do: ssh admin@ntp200 show gps ssh admin@ntp200 show ntp and parse the output that way.

Of course, having a system log and being able to forward that to a syslog server, and/or having snmp traps would also help.

dave4445 commented 1 year ago

How about:

$ curl -s 'https://demo.centerclick.com/?op=json' |jq .ntp.stratum 
1

or similar, see man jq for more fancy filter syntax.

snmp monitoring is in #59

VTBurtonRA commented 1 year ago

That works well. Thanks for the suggestion.