Can an application query the supervisors online state

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

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!

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.

Can you elaborate by what you mean by online in the network connected way, but cannot connect through the VPN one way or another? Is this the difference between the device response info is_online and is_connected_to_vpn? Does it mean we can launch a shell in the latter but not the former? Perhaps in the former case, the logs may stream to be visible in the dashboard?

A device can be online on the network - eg. available with an IP address in the local network - but not able to establish a VPN connection to the balena backend. This could be due to firewall or name resolution issues. In this case the device will show up on the dashboard as not online and you will not be able to open a shell to the device via the dashboard or the balena cli.
You might still be able to open a shell in the following cases:

  • you have another device in the same local network that is online and can be used as a proxy
  • the device runs a development image and you have access to the local network
  • you have set up your ssh keys on the device and you have access to the local network

I have not understood your question regarding is_online and is_connected_to_vpn . What interface are you referring to ?