This will show you how to monitor the traffic of your TTN gateway. This guide works for the single channel gateway by Jaab Braam and for the most Raspberrya Pi based DIY gateways.
The traffic problem should be solved now, so please check for the now flow on GitHub.
- monitoring of outbound traffic
- accurate order by time, some measurements are stacked togehther
To monitor your gateways you need an instance runnig:
- InfluxDB with a database
- Grafana with the InfluxDB database as datasource
- tcpdump installed on the gateway
Single Channel Gateway (Jaap Braam)
The single channel gateway by Jaap Braam is pretty easy to monitor. You only have to open a telnet session and you will get all infos we need. Node-RED will generate the payload out of this stream. All intersting data will be saved into an InfluxDB and visualized by Grafana.
I uploaded the flow to GitHub. You only have to change the IP of your gateway and your InfluxDB settings.
You can find the Grafana dashboard also on GitHub, you only change the DB query, according to your setup.
On thing to keep in mind. If you restart your gateway the connection will get lost. You have to restart Node-RED or you double change the IP address of your Gateway in the Node-RED flow.
DIY Gateways based on Raspberry Pi
The idea behind this is to establish a SSH connection to our gateway and perform a tcpdump on port 1700.
To establish the connection i use the node big-ssh, which has to be installed with manage palette. Now you can coppie the flow from GitHub and edit your InfluxDB preferences.
big-ssh need a private RSA key to work so we have to generate one. Before that you can look if you not have already one:
root@raspberrypi:/# ls ~/.ssh/
id_rsa id_rsa.pub known_hosts
Otherwise we will make a new one with a pass phrase:
ssh-keygen -t rsa -b 1024
Now we have to check which user is running node-red. If it is not root, we have to copy the key to a location readable by this user. In my example node-red runs under the user pi.
root@raspberrypi:/# ps -ef |grep node-red
pi 405 1 0 Oct27 ? 01:05:30 node-red
cp ~/.ssh/id_rsa /home/pi
chmod 644 /home/pi/id_rsa
Now we have to copy to our gateways authorized keys.
ssh-copy-id -i ~/.ssh/id_rsa.pub gw-user@gw-ip
Now we can edit the big-ssh preferences. We have to edit the host ip, the directory of the private key an the pass phrase.
Once you inject the time into the flow, all should be running fine. Now you can build a fancy dashbaird with Grafana.
One thing to keep in mind. big-ssh is not able to disconnect the ssh session, so it will remain open until your gateway or your node-red restarts. Evry time you inject into the flow, it will open another ssh session, which will not be terminated. So big-ssh is only suitable for permanent connections.