Watchdog for 'last seen'

Hello all,

I'm using a Ardeunis device which only sends data if any of the monitoring ports have changed and at least one 'Keep Alive Frame' every 24 hours so I can be sure the device is still alive.

What would you recommend as best approach to send an alarm if the device has not been 'seen' for more than 24 hours? My first approach was to handle each Keep Alive Frame combined with a timer. If the timer is overdue, lets say 25 hours, it will send an alarm.

But now my second idea is not only to use the Keep Alive Frames, but if any package is received, to set the epoch time in a file. Why a file? If I understood correctly, all variables get lost if the flow gets redeployed, right? So from that point of view a file containing just the epoch time of the last package seems to be a better way of storing this data.

Next, some kind of timer, or just a daily check at a fixed time for all epochs. For now I have just one device, but this single device will get company sooner or later :slight_smile:

If you also wrote some kind of watchdog in your project and are willing to share, please let me know.

Kind regards,

Peter Hunt.

For a simple watchdog where persistence over a restart is not required then this can be easily done using a Trigger node, set to send nothing, then delay (25 hours in this case) then send the failure message. In addition select Extend Delay if New Message arrives. The result is that once a message is received then if there is an interval of 25 hours with no message then it will trigger. You will need an Inject node feeding it (as well as your message stream) set to fire once on restart in order to prime it the first time.
For persistence over a restart then your idea saving the current time (new Date() will get that for you) and updating it each time a message arrives is the way to go. However you don't need to write logic to save it in a file, you can use Persistent Context to get node-red to save it for you. Search for node red persistent context and you will find it explained in the docs.

Dear Colin,

Thanks for your prompt reply!

I will have a look into the Persistent Context and see it this fits my needs. It sounds easier to use :slight_smile:

Kind regards,

Peter Hunt.

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