I would like to periodically grab a list of all nodes on the mesh with IP Address and host name. Basically, the first two columns of the Topology Entries section from http://localnode.local.mesh:1978/nodes, sorted for unique entries. The IP Addresses are available from http://localnode.local.mesh:2006/topo, but not the host names. I know I can loop through this list and get the host names through several means. But, it would be nice to get this in one simple grab.
So, does anyone know a way to do this, or maybe has already got a script for it?
BTW, my application is to maintain a list of hosts and the last time they were seen.
TIA
So, does anyone know a way to do this, or maybe has already got a script for it?
BTW, my application is to maintain a list of hosts and the last time they were seen.
TIA
that will do it.
Thanks.
For anyone interested in this discussion, here is a snippet of Python code to grab the node names and addresses from the json output:
------------------------------------------------------------------
#!/usr/bin/python2.6
import urllib2
import json
nodeAddr = "wb6tae-1998" # put the name or address oif your node here
url = 'http://' + nodeAddr + ':8080/cgi-bin/sysinfo.json?hosts=1'
response = urllib2.urlopen(url)
decoded_response = response.read().decode("UTF-8")
jsonResponse = json.loads(decoded_response)
jsonData = jsonResponse["hosts"]
for item in jsonData:
hostname = item.get("name", "Null")
ipaddr = item.get("ip", "Null")
print("%-28s %-16s" % (hostname, ipaddr))
------------------------------------------------------------------
nodeAddr="localnode.local.mesh"
that will resolve to the node that you are connected directly to.
Now don't be too picky... this was just a snippet for demo sake. The main point is how to get the json data and extract the needed elements.
But, yes that would be a good idea. In my case, I have .local.mesh in my dns search string so I don't have to worry about including a full domain name.
The script above using the json info all looks good except I want the node router LAN ip. Is there a way to get that?
I don't need the device WIFI address.
In the end I'll do a sort: sort -t . -k 2,3n -k 4,4n
The idea is to show all the hosts and node devices grouped together by LAN addresses.
- Mike