Is there a service call like
http://localnode.local.mesh:8080/cgi-bin/sysinfo.json or http://localnode.local.mesh:8080/cgi-bin/api?mesh=services to obtain the local clock setting on network nodes. I would like to be able to glance at all network nodes' clocks to see if any are 'way off' on time. 73, Chuck
http://localnode.local.mesh:8080/cgi-bin/sysinfo.json or http://localnode.local.mesh:8080/cgi-bin/api?mesh=services to obtain the local clock setting on network nodes. I would like to be able to glance at all network nodes' clocks to see if any are 'way off' on time. 73, Chuck
Chuck, you can always install 'links' on one of you mesh Linux systems, if you have such, then do this or something similar:
links -dump http://localnode.local.mesh/cgi-bin/status |grep "system time:"
Here is an output from one of my nodes:
LAN AP SSID: hAPac system time: Sun Aug 20 2023 11:20:29
And of course you could make a script that would give a cleaner output as well as store to a file or whatever...
- Mike
Hi, Mike:
Thanks.
I had not used 'links' in a few decades.
I used sysinfo.json?hosts=1
and extracted a list of hosts manually > nodelist.txt
Then coded:
while read NODE
do
# echo "links -no-connect -retries 1 -receive-timeout 4 -dump http://$NODE/cgi-bin/status |grep -o \"[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\""
time=$(links -no-connect -retries 1 -receive-timeout 4 -dump http://$NODE/cgi-bin/status |grep -oE "[0-9][0-9]:[0-9][0-9]:[0-9][0-9]..")
echo "$time $NODE"
done < nodelist.txt
Redirected to an output1.txt file
Then cut -d":" -f2- output1.txt > output2.txt # only use minutes cuz some nodes are ?DST verses UTC!
sort < output2.txt > ordered-nodelist.txt
Nodes with errant times will be at the top and/or bottom of the list.
73, Chuck
Thanks for posting that, Chuck. I tried it all in pieces and it works.
I wish there was an easy way to get a list of node names only versus having to manually extract them from the URL (http://localnode.local.mesh:8080/cgi-bin/sysinfo.json?hosts=1). That would make playing around with scripts much easier.
- Mike
When I run my script against my list of 27 nodes, it brings to light some interesting things:
By the way, I used 'topologr' (v0.1b5) to "Export Net" as a JSON. Then used the Windows program "JSONedit" to reflow the JSON file, to make it a clean uncompressed file. Then used NotePad++ to get rid of the quotes around the node names as well as the comma after each name, and then sorted the names and finally saved as nodelist.txt.
It's kind of a long, goofy way to get a nice list of node names, but works and would be just about as easy if doing a couple of hundred nodes.
(Oh, for completeness,) I run the script on my Raspberry Pi that is on the mesh, by SSHing into it from my Windows PC, in a MobaXterm terminal tab.
Also, by the way, I use JSONedit to easily get rid of the few ghost/stale/dead nodes from the topologr map to keep the map clean.
- Mike
http://localnode.local.mesh/cgi-bin/api?mesh=remotenodes
Working...
links -dump http://localnode.local.mesh/cgi-bin/api?mesh=remotenodes |jq '.'|grep name|cut -d":" -f2|cut -d'"' -f2
Thanks. Just added 'sort' and it is perfect!
links -dump http://localnode.local.mesh/cgi-bin/api?mesh=remotenodes |jq '.'|grep name|cut -d":" -f2|cut -d'"' -f2 |sort
- Mike
If 'mktemp' is used in the script, the list of node names will ne be seen anywhere. This can be hand if running from different directories and not wanting that file in the current directory.
-----
-----
!!!! I just realized that the above script does not capture localnode and local DtD nodes. In all, I have 3 and none are in the list of 'nodenames'. It's not obvious how to resolve this such that the one bash script runs alone and does it all. For now, in my case, I may hard-code my 3 nodes into a file then modify this script to append to my 3 nodes. It's no longer the nice clean solution I was looking for. Maybe someone else can come up with a clean solution.
- Mike
Here is a fix that seems to work. To include the localnode and any DtD nodes, the script must be manually edited to include those. I only have 3 so it is easy for me. I cannot see anyone having so many that it would be a real burden to make the edits. Here is the bash code:
Just to recap, Chuck (nc8q) asked about checking all nodes on a network to see if their clocks were showing correct time. That required having a list of all the node name to do the checks. So the bash program above will do that. And yes, it could probably be improved but seems to work nevertheless.
- Mike
You can also use the api without requiring the extra "links" package:
http://nodename.local.mesh/cgi-bin/api?status=sysinfo
{
"pages": {
"status": {
"sysinfo": {
"description": "Shack hub node",
"date": "Tue Aug 22 2023",
"time": "16:19:31 MST",
"api_version": "1.5",
"target_type": "ipq40xx\/mikrotik",
"first_boot": false,
"model": "MikroTik hAP ac2",
"uptime": "0 days, 1:12:35",
"loads": [
0.16,
0.19,
0.12
],
"node": "AB7PA-Hub",
"firmware_version": "20230815-8ce7c0b"
}
}
},
"api_version": "1.5"
}
Thanks. That is good to know.
I looked inside /www/cgi-bin/api and found this list of calls:
sysinfo
allhosts
localhosts
remotenodes
currentneighbors
services
previousneighbors
topology
Older nodes' OSs do not seem to support the /api calls, though.
73, Chuck
This is a very interesting thread with good information, I, for one, would really appreciate a final summary write-up posted here somewhere later on if possible.
A few years back there was a utility called "MeshStat" but it was apparently never continued; this thread made me think of how useful that was for us with our little mesh island, and the hope that a similar functionality would reappear in future:
MeshStat
========
Copyright (c) 2017-2018 License: GPL 2 or higher
Author: Jonathan M. Cameron, KF6RTA jmcameron@gmail.com
Thanks,
- Don / AA7AU
Don, see my recap at the bottom of posting #9.
This site probably needs a place to put little programs and hacks like this.
- Mike
The best way to maintain clock consistency is to have all the nodes use an NTP service on the mesh. If nodes are all getting their time via NTP then you don't have to track down "offenders" and spend a lot of time and energy figuring out what's going on. Here is the section in the online AREDN docs that discusses NTP and gives some easy options: https://docs.arednmesh.org/en/latest/arednServicesGuide/other_programs.html#network-time-services. Hope this helps.
The keywords are "If nodes are all getting their time...".
Occasionally we have issues with nodes, and the script above helps identify any problem nodes.
Right now, we have one node that has such a problem, even though we have three NTP servers on the network.
- Mike