Exec stdout and SSH

G'Day all!

I am SSH'ing to other pi's to get their CPU load and Temp

It runs and gives output in a shell however node-red isnt seeing it because its not stdout

it runs locally fine.

ssh -l pi 192.168.2.246 top -d 0.5 -b -n2 | grep "Cpu(s)"|tail -n 1 | awk '{print $8}'

when run over SSH in node-red it returns ""

Any hints or ideas?

[{"id":"7913f633.36c7f8","type":"ui_level","z":"9f18fd18.1b796","group":"6b0bdb50.b72734","order":12,"width":2,"height":1,"name":"Nanna Temp","label":"","colorHi":"#e60000","colorWarn":"#ff9900","colorNormal":"#00b33c","colorOff":"#595959","min":0,"max":100,"segWarn":"60","segHigh":"70","unit":" °c","layout":"sh","channelA":"","channelB":"","decimals":0,"animations":"soft","shape":2,"colorschema":"fixed","textoptions":"default","colorText":"#eeeeee","fontLabel":"","fontValue":"","fontSmall":"","colorFromTheme":true,"textAnimations":false,"hideValue":false,"tickmode":"auto","peakmode":false,"property":"payload","peaktime":3000,"x":930,"y":2500,"wires":[]},{"id":"d88463d5.3666c","type":"ui_level","z":"9f18fd18.1b796","group":"6b0bdb50.b72734","order":11,"width":3,"height":1,"name":"Nanna CPU","label":"","colorHi":"#e60000","colorWarn":"#ff9900","colorNormal":"#00b33c","colorOff":"#595959","min":0,"max":100,"segWarn":"25","segHigh":"50","unit":"%","layout":"sh","channelA":"","channelB":"","decimals":0,"animations":"soft","shape":2,"colorschema":"fixed","textoptions":"default","colorText":"#eeeeee","fontLabel":"","fontValue":"","fontSmall":"","colorFromTheme":true,"textAnimations":false,"hideValue":false,"tickmode":"auto","peakmode":false,"property":"payload","peaktime":3000,"x":950,"y":2580,"wires":[]},{"id":"341af67d.e41fea","type":"exec","z":"9f18fd18.1b796","command":"ssh -l pi 192.168.2.246 'vcgencmd measure_temp'","addpay":false,"append":"","useSpawn":"false","timer":"","name":"Temp","x":410,"y":2520,"wires":[["b4e2036e.5c914"],[],[]]},{"id":"b4e2036e.5c914","type":"function","z":"9f18fd18.1b796","name":"SubString","func":"str = msg.payload \nmsg.payload  = str.substring(5, 9);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":2500,"wires":[["db29db56.38e768"]]},{"id":"e81b48d6.2a7358","type":"exec","z":"9f18fd18.1b796","command":"ssh -l pi 192.168.2.246 top -d 0.5 -b -n2 | grep \"Cpu(s)\"|tail -n 1 | awk '{print $8}' ","addpay":false,"append":"","useSpawn":"","timer":"","name":"LOAD","x":410,"y":2580,"wires":[["5d8ae535.27bc0c"],[],[]]},{"id":"5d8ae535.27bc0c","type":"function","z":"9f18fd18.1b796","name":"","func":"msg.payload = Number(msg.payload);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":660,"y":2580,"wires":[["d88463d5.3666c"]]},{"id":"db29db56.38e768","type":"function","z":"9f18fd18.1b796","name":"","func":"msg.payload = Number(msg.payload);\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":2500,"wires":[["7913f633.36c7f8"]]},{"id":"387ca3a5.e3010c","type":"inject","z":"9f18fd18.1b796","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"20","crontab":"","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":230,"y":2540,"wires":[["341af67d.e41fea","e81b48d6.2a7358"]]},{"id":"6b0bdb50.b72734","type":"ui_group","name":"PI status","tab":"4f89aa36.129a94","order":2,"disp":true,"width":7,"collapse":false},{"id":"4f89aa36.129a94","type":"ui_tab","name":"Devices","icon":"fa-tablet","order":4,"disabled":false,"hidden":false}]

edit: I thought id try node-red-contrib-interactive-ssh

Its suppose to return an string of the output but it returns a buffer with nothing I can see useful?

image

What do you see if you click the raw button on the debug message?

image

its outputting the input?

You flow using the ssh command works for me (with appropriate IP and user change).

Add debug nodes set to show Complete Message to each output of the exec node and see what they show.

see thats weird because I wasnt getting any output the payload was ""

now i reimport the flow and it works.... WEIRD!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.