This article shows how to monitor the routes of one gateway driver (here called MCR). This example will send an email if no routes are executed since 1 hour, which would suggest that the installation has become inactive for some unknown reason.
In this scenario, the device has a modbus gateway named MCR, and we want to monitor the routing to make sure that the modbus registers are being regularly updated.

The values are routed from existing KNX lines into the Modbus MCR gateway using some advanced routes (regexs and scripts). If those routes are stopped by someone or stop to work because the KNX or the Modbus has connectivity issues, then the heating regulation of the building will stop (causing too much or not enough heating).

In order to send email alerts, the SMTP gateway is convenient. Once the SMTP gateway is configured and connected, it is possible to send emails by writing the email body text content to the following address structure user@company.ch:subject_of_the_email. Like any other type of addresses, email addresses can be written through the logic module has shown in the following section, or using routes has shown in this other article.
After creating the logic circuit, add one custom programmable gate, and one write gate. Edit the programmable gate (delete the default input, and configure two outputs, one named running and another named alert. In the write gate configure the email address and subject of the email address has shown in the screenshot below.

By double clicking on the programmable gate you can the edit its Javascript code. The code below shows how to implement the watchdog. Here the code listens to the gateways api routeWrite event. This event is triggered whenever a route is executed by the IoT universal gateway. Once the logic circuit is correctly configured correctly, don't forget to save the changes and start its execution in the CURRENT STATUS mode.
var peers = require('peers')('routingWatchdog') // loads the API peers module.
peers.connect('/tmp/supervision') // connects to the supervision internal socket.
// loads the gateways api
peers('supervision').require('gateways',function(err, gw){
if(err) {
console.error("failed to require gateways",err)
alert("COULD NOT LOAD GW " + err) //alert output
return
}
var noRouteWatchdogInterval = null;
function resetWatchdog(){
clearInterval(noRouteWatchdogInterval)
noRouteWatchdogInterval = setInterval(function(){
// sends the email text to the "alert" gate output
alert("NO ROUTES EXECUTED ON THE MCR GATEWAY SINCE 1 HOUR")
},60000*60) //one hour delay before sending the alert.
}
resetTimeout() //initializes the watchdog
//load all addresses from the gateway named "MCR"
gw.getAddressesByGateway("MCR",function(err,ads){
var mcrIds = {} //contains the addresses ids of the MCR gateway.
for(var ad of ads){
mcrIds[ad.id] = true
}
//listens to the routing events
gw.on('routeWrite',function(routeId,addressSourceId,addressDestId){
if(mcrIds[addressDestId]){ // if a route writes a value to the MCR gateway.
resetWatchdog() // reset the watchdog to not send the alert.
}
})
running(1) // indicates that the watchdog is up and running.
})
})