Can an application query the supervisors online state


#1

Each of my devices has a user interface. I would like to display whether or not the supervisor is connected to the balena cloud backend or not.
So e.g. if a firewall is blocking the connection, I want to announce an “offline” state.

I have not been able to find this state in the supervisor API:
https://www.balena.io/docs/reference/supervisor/supervisor-api


#4

Hi, @krix this is an interesting question, I don’t think we have that functionality at the moment.

I’ve added a ticket for the supervisor where you can follow changes to to this

On the other hand, we’d like to ask some more questions about your request:

The supervisor in general is not related to the online/offline status. Whether a device shows up online or offline in the dashboard means just whether the device is connected to the balena backend over the VPN. If the device is “online” in the network connected way, but cannot connect through the VPN one way or another, it wouldn’t show up online in the dashboard.

Thus I wonder what online state are you interested in, really?

  • Connected to the network in general?
  • Connected to the balena backend?

If the former, you can do network checks instead.

If the latter, it might currently work with the backend API, getting the status by requesting the device info, either https://www.balena.io/docs/reference/api/resources/device/#device-by-id or using the SDK https://www.balena.io/docs/reference/sdk/node-sdk/#balena.models.device.isOnline For this you could use the device’s API key (need to set a label in your docker-compose.yml file for that to be added to the service that you need it in https://www.balena.io/docs/reference/supervisor/docker-compose/#labels ) In the case your API request succeeds, you know the reply of the backend whether the device is online/offline in the dashboard. If the API request fails due to network, then you can know it is surely offline in the dashboard.

Does this help? What do you think overall of the suggestions and questions above? And thanks for the feature request!


#5

Thanks for you suggestion, I am looking forward to follow the ticket.

The workaround you describe: As far as I understand this means letting the device know a key, that in principle gives it more or less full access to the Balena backend including access to information about all other devices. I am a bit concerned about the security risk in this.