Send event data to remote server



  • We run a number of machines and are looking to collate the event log data on a central server. This will enable us to monitor machines, analyse the data perhaps eventually run a print queue from that server.
    Looking at IoT dashboards, such as thingsboard.io (and there are many others), it appears that devices need to authenticate with the server before being able to send data.
    I see a few people have discussed the idea of the Duet sending data, (https://forum.duet3d.com/topic/4285/g-code-to-actually-send-a-message, https://forum.duet3d.com/topic/4795/how-to-use-m118-to-send-http-requests) but no neat solution has been presented.

    I think it would be useful to add a webclient class to RepRapfirmware to be used by M118 and M929 to send data to a remote server.

    Before I tackle adding this myself, I wanted to ask whether anyone else is working on such a solution so as not to reinvent the wheel?

    There are plenty of example code snippets online, such as http://lwip.wikia.com/wiki/Raw/TCP, which describe how to structure such a feature.



  • I would carefully consider how much you want TCP/IP connections that depend on a remote server running on the Duet itself, even under RTOS. It might work just fine, with careful enough coding. It also might turn into a can of worms.

    The other alternative, that could easily be implemented with no changes to the Duet itself, is to periodically "poll" using the same status commands that Duet Web uses today. An intermediary would do the polling, and then push the resulting data logs wherever you wished. The intermediary could be very simple, a script with curl commands, or could be in whatever platform/language you prefer.

    Just a thought...



  • This is in many ways pretty far from what you want... I'm showing it because it is an example of multi-printer polling.

    This only took a few days to build, using the existing Duet Web control as a starting point.

    https://github.com/DanalEstes/MultiDuetWebMonitor



  • @Danal Thank you for your comments. I already played around with your MultiDuetWebMonitor. It looks good.
    I am also considering polling from the remote server, but although that would give me data to draw some nice graphs, it wouldn't provide accurate data for print start/stop/cancel events and filament usage.
    In a production scenario, the standard DuetWebControl interface wouldn't be running as print start commands would come from the remote server, so opening an intermittent outgoing connection from the Duet shouldn't add too much strain on its processes, but I agree this extra overhead will have to be investigated further and monitored.
    Perhaps it would be safer to modify the data written to the eventlog on the SD card, and have the server poll the last line to check for new events.



  • Yeah, I think there are a lot of ways it could work.

    Accuracy? DWC polls four times a second today. I believe that's a bit much, but one second polls would certainly work, and would seem to give "accurate enough" stats.

    You probably already got this, but just to be super clear: I'm talking about an intermediate "marshaling point" for the farm, pulling from multiple printers, and pushing only aggregated stuff to the final repository server.

    And, again, probably lots of ways... 🙂 Will be interesting to follow.


Locked
 

Looks like your connection to Duet3D was lost, please wait while we try to reconnect.