You can possibly create some eye-candy using Grafana and Prometheus but the underlying data will likely need to come from using the ss tool. If you look at the code in gLiveView it also uses the ss tool. You don’t need the eye-candy and using it is arguably detrimental to your understanding in the long run.
I recommend just using the ss tool directly yourself for a better understanding.
Start with this:
Here I have assumed that your node is listening on port 3001. Any incoming connections from other relays will connect to your node port (3001).
Here is the output of the above command (using port 2700) on my block producer since it is listening on port 2700 instead of 3001.
192.168.27.9:2700 144.126.157.46:41729
192.168.27.9:2700 144.126.157.46:2700
192.168.27.9:2700 192.168.28.1:2700
192.168.27.9:2700 192.168.28.1:43161
127.0.0.1:2700 127.0.0.1:46936
192.168.27.9:2700 192.168.27.7:2700
192.168.27.9:2700 192.168.27.8:2700
These are all the established TCP connections to my cardano-node on port 2700. The connection to 127.0.0.1:2700 is cncli running on the same machine. All the other connections are to/from my relays.
Note that my block producer is running in P2P mode.
If we just consider the 2 connections to/from IP address 144.126.157.46. The connection on port 41729 is an incoming connection which was set up from 144.126.157.46 (relay3.terminada.io) in to my block producer. Whereas the connection on port 2700 is an outgoing connection set up by my block producer out to relay3.
How do I know this? I know this because my relay3 is running in normal mode so it sets up connections from random high ports. Whereas my block producer is running in P2P mode so all its connections are set up using port 2700.
If you are running normal mode then it will be easier for you to figure out which way the connections were set up. This is because all nodes running in normal mode set up their connections using random high ports. Therefore running this ss command on your block producer (assuming it listens on port 3001):
ss -4Htnp state established | grep -Po '[0-9\.]+:3001\s+[0-9\.:]+'
Will give you all the incoming connections set up by your relays into your block producer. You should see output like this:
bpIP:3001 relay1IP:highport
bpIP:3001 relay2IP:highport
To see the TCP connections that were set up by your block producer out to your relays then you need to look for the TCP connections that go to your relay listening ports. Again assuming all your relays are listening on port 3001 then you could use a command like this:
ss -4Htnp state established | grep -Po '[0-9\.]+:\d+\s+[0-9\.]+:3001'
Or you can just run the ss command without any grep to filter:
ss -4Htnp state established
Which on my block producer results in:
0 0 192.168.27.9:2700 144.126.157.46:41729 users:(("cardano-node",pid=683451,fd=42))
0 0 192.168.27.9:2700 144.126.157.46:2700 users:(("cardano-node",pid=683451,fd=45))
0 0 192.168.27.9:2700 192.168.28.1:2700 users:(("cardano-node",pid=683451,fd=63))
0 0 192.168.27.9:22 172.16.0.45:34088 users:(("sshd",pid=724219,fd=4))
0 0 192.168.27.9:2700 192.168.28.1:43161 users:(("cardano-node",pid=683451,fd=38))
0 0 127.0.0.1:46936 127.0.0.1:2700 users:(("cncli",pid=474,fd=10),("cncli",pid=474,fd=9))
0 0 127.0.0.1:2700 127.0.0.1:46936 users:(("cardano-node",pid=683451,fd=41))
0 0 192.168.27.9:12798 172.16.0.45:42146 users:(("cardano-node",pid=683451,fd=28))
0 0 192.168.27.9:2700 192.168.27.7:2700 users:(("cardano-node",pid=683451,fd=88))
0 0 192.168.27.9:2700 192.168.27.8:2700 users:(("cardano-node",pid=683451,fd=52))
0 0 192.168.27.9:22 172.16.0.45:57854 users:(("sshd",pid=494,fd=4))
Which then also gives you details about the processes.
I recommend experimenting with the ss tool and taking a look at its man page. You will be glad you did because then you will have a much better understanding. Note that the ss tool doesn’t tell you which way the TCP connection was set up. This is why you need to apply reasoning by looking at the ports involved to figure out how the connection must have been set up.
The eye-candy tools like gLiveView are just using this same ss tool.
Now that you understand better how things work, you can create your own script that runs every minute via a cron job. This script can grab data using the ss tool and export this information using something like prometheus node exporter so that you can have your eye-candy in Grafana.
What I do personally is run a command like this:
printf "%0.s-" {1..70}; \
echo; startsec=$(curl -s -H 'Accept: application/json' http://localhost:12788 | jq '.cardano.node.metrics.nodeStartTime.int.val'); \
startdate="$(date -d @${startsec})"; nowsec=$(date '+%s'); nowdate="$(date)"; runhrs=$(( (nowsec - startsec) / 3600 )); runmins=$(( (nowsec - startsec) % 3600 / 60 )); \
rtsconf="$(ps aux | grep -Po "cardano-node\s.*\+RTS\s.*\-RTS")"; \
missedslots=$(curl -s -H 'Accept: application/json' http:/localhost:12788 | jq '.cardano.node.metrics.slotsMissedNum.int.val'); \
echo "Node Started: ${startdate} (Running: ${runhrs} hrs ${runmins} mins)"; \
echo "RTS settings: ${rtsconf}"; \
echo "Missed slots: ${missedslots}"; \
echo "Memory use:"; free; \
echo; ss -4Htnp state established | grep -Po '192\.168\.27\.9:2700\s+(192\.168\.\d+\.\d+|144\.126\.157\.46):\d+'
The user bash history then has this command saved and I just hit the up arrow to scroll back through my history to repeat this same command as needed. Or you can just save it as a document note somewhere for future copy - paste ability. If you read through the above mini script you can see what it is doing. Then modify it for your needs. But note that my bp is running in P2P mode which provides more useful data via cardano.node.metrics. Experiment with the curl command then pull out the data you want using jq.
The real take-home message, for anyone reading, is to find your own way. Tear apart other people’s scripts and steal ideas. Ensure you understand how things are working. Then build your own scripts to produce the data you want. Don’t trust the scripts created by others until you understand what they do.
Beware that some eye-candy tools can inadvertently open up security holes in your system if you are not careful.