As the subject says: is there a way to monitor the uptime of a GX device ?
(I already browsed through a bunch of options but couldn’t directly pinpoint a candidate)
Node red. Exec node command:uptime. Reports average load as a bonus too.
Meanwhile I’ve found the ‘node-red-contrib-os’ node group and that provides (among others) an Uptime node.
Looking at the source code, I think it should be possible to do the same with a (more or less) regular function node, but so far my efforts have not produced a working result ![]()
EUREKA !
This works ![]()
Edit: fancied the output a bit.
[{"id":"128227f1a0610411","type":"function","z":"0a0a18ed80bee54e","name":"Uptime","func":"Uptime_In_Seconds = os.uptime();\nfunction format(sec){\n function pad(s){\n return (s < 10 ? '0' : '') + s;\n }\n var seconds = Math.floor(sec % 60);\n var minutes = Math.floor(sec % (3600) / 60);\n var hours = Math.floor(sec % (3600*24) / 3600);\n var days = Math.floor(sec / (3600*24));\n var dayspadded = days > 0 ? days + (days == 1 ? \" day, \" : \" days, \") : \"\";\n return dayspadded + pad(hours) + ':' + pad(minutes) + ':' + pad(seconds);\n}\nmsg.payload = format(Uptime_In_Seconds);\nnode.status({text: msg.payload});\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"os","module":"os"}],"x":660,"y":300,"wires":[[]]},{"id":"b696ce79589ac8f6","type":"inject","z":"0a0a18ed80bee54e","name":"","props":[{"p":"payload"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":510,"y":300,"wires":[["128227f1a0610411"]]},{"id":"824b2318628b8000","type":"inject","z":"0a0a18ed80bee54e","name":"","props":[{"p":"payload"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":510,"y":240,"wires":[["4fd5c95544baf2fc"]]},{"id":"4fd5c95544baf2fc","type":"function","z":"0a0a18ed80bee54e","name":"Uptime","func":"msg.payload = os.uptime();\nnode.status({text: msg.payload});\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"os","module":"os"}],"x":660,"y":240,"wires":[[]]}]
I used the exec node, until I realized my serial battery driver provides in the GUI.
Chasing random restarts?
Not actively chasing random restarts, mainly me being a geek being curious if/when the device reboots by itself.
If it would reboot while I’m not actively working on it, I would never know.
Until now ![]()
My reboots fire off a zillion battery related alarms. We leave in 3 days, I have to stop messing with this code and start packing the coach.
Have fun and thanks for keeping my brain trickled in these nightly hours ![]()
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.