[BUG] [API] OnlineMemberCount value is always zero

Environment
OS: All operative systems
Version: All versions
Affected functionality: API

Description
When obtaining a list of all networks using the

https://api.zerotier.com/api/v1/network

endpoint, the returned value for "onlineMemberCount" is always zero, despite several members are actually online.When the network ID is included in the endpoint, for example when requesting

https://api.zerotier.com/api/v1/network/n3tw0rk1dH3r3

then the onlineMemberCount value is correctly populated with the number of currently online devices.

Steps to reproduce

  • Create a new ZeroTier network and join a new device on that network
  • While being sure that the device is authorized and online, perform an API request to the https://api.zerotier.com/api/v1/network endpoint or to the https://api.zerotier.com/api/network endpoint
  • Note the value of onlineMemberCount which will be equal to zero
  • While being sure that the device is authorized and online, perform an API request to the https://api.zerotier.com/api/v1/network/networkID or to the https://api.zerotier.com/api/network/networkID where networkID is the ID of the created network
  • Note the value of onlineMemberCount that will be the correct, expected value.

Expected behaviour
A call the https://api.zerotier.com/api/v1/network endpoint returns a list of all networks along with the number of authorized and online devices on each network. Obtaining a list of all networks and the number of online devices is not possible at the present time, unless a network ID is specified.

Thanks in advance, have a nice day!

image

Dennis Preatto
IT Specialist
SPAC S.p.A.
36071 Arzignano (Vi) Italy
Z.I. Sesta strada 45
Tel 0444.451451
www.spac.eu

This is not a bug. It’s intentional. Online member count for networks is not calculated when getting the full network list.

Good morning @zt-grant,

may I ask why the field onlineMemberCount is not calculated when obtaining the full list of network, while the authorizedMemberCount field and the totalMemberCount is? Pardon me if I sound annoying but that makes no sense at all, and that is why our IT team (which is testing the software for an idea of a massive future implementation of your software) thought it was a bug.

Would it be possible to perform the calculation of the onlineMemberCount field when getting the networks list somehow, without having to perform an API call for every single network or having to count all online members? At the present time this is an issue, since it requires us to perform the calculation on our end to obtain the needed data.

Thank you for your assistance, have a nice day.

image

Dennis Preatto
IT Specialist
SPAC S.p.A.
36071 Arzignano (Vi) Italy
Z.I. Sesta strada 45
Tel 0444.451451

It’s due to data sharding in the backend and its effect on performance of the network list endpoint. It’s not an issue calculating it per individual network, but it becomes an exponential slowdown when requesting the full network list. So unfortunately, no, we will not be calculating that field for the full network list.

Also note that “Online” is in terms of the last time a network member sent a message to the network controller. It has no bearing on whether or not a machine can talk to other machines on the ZeroTier network. If you’re using this for uptime monitoring of individual machines, we recommend going a more traditional route of ping monitoring over the zerotier network if that is your goal.

Good evening @zt-grant,

Thank you a lot for your reply and for the explanation,

I understand the problem and I can imagine that calculating the value of onlineMemberCount would be quite slow when getting all the networks. On our end we can work around this issue by looping through every member and counting how many of them have the online property set to true.

Actually, my idea was to use the onlineMemberCount value to check which members are online, and on which networks, at the time the API request is performed, with the aim to show a simple representation of the data (something like: 3 authorized - 1 online on Network networkID).

I will keep in mind your suggestion in case we need to start monitoring machine uptime.

Thank you a lot for your help and kindness,
have a nice evening!

P.S. I am pretty thunderstruck to see that previous messages got marked as spam, I suppose because of the link in the signature. It was not intended as spam, but to allow ZeroTier staff to get to know the people they are talking to.

image

Dennis Preatto
IT Specialist
SPAC S.p.A.
36071 Arzignano (Vi) Italy
Z.I. Sesta strada 45
Tel 0444.451451

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.