Landscape UI online status new dashboard: how calculated?

Hello,

We are trying to determine whether our devices are online from the Landscape API. On the new dashboard there is such a thing (see the status column):

How does the frontend calculate this value? In the get_computer endpoint we get these values, if we include the “alerts”:

{
    "count": 22,
    "results": [
        {
            "id": 70310329,
            "title": "00afce94-7c10-d461-7384-107c61d47383",
            "comment": "",
            "hostname": "00afce94-7c10-d461-7384-107c61d47383",
            "total_memory": 7814,
            "total_swap": 0,
            "reboot_required_flag": false,
            "update_manager_prompt": "normal",
            "clone_id": null,
            "secrets_name": null,
            "last_exchange_time": "2024-10-28T15:50:01Z",
            "last_ping_time": "2024-10-28T16:43:11Z",
            "tags": [],
            "access_group": "global",
            "distribution": "22",
            "distribution_info": {
                "description": "Ubuntu Core 22",
                "distributor": "Ubuntu Core",
                "release": "22",
                "code_name": "ubuntu-core"
            },
            "cloud_instance_metadata": {},
            "vm_info": "",
            "container_info": "",
            "default_child": null,
            "ubuntu_pro_info": {
                "_doc": "Content provided in json response is currently considered Experimental and may change",
                "_schema_version": "0.1",
                "account": {
                    "created_at": "",
                    "external_account_ids": [],
                    "id": "",
                    "name": ""
                },
                "attached": false,
                "config": {
                    "contract_url": "https://contracts.canonical.com",
                    "data_dir": "/var/lib/ubuntu-advantage",
                    "log_file": "/var/log/ubuntu-advantage.log",
                    "log_level": "debug",
                    "security_url": "https://ubuntu.com/security",
                    "ua_config": {
                        "apt_news": false,
                        "apt_news_url": "https://motd.ubuntu.com/aptnews.json",
                        "global_apt_http_proxy": null,
                        "global_apt_https_proxy": null,
                        "http_proxy": null,
                        "https_proxy": null,
                        "metering_timer": 14400,
                        "ua_apt_http_proxy": null,
                        "ua_apt_https_proxy": null,
                        "update_messaging_timer": 21600
                    }
                },
                "config_path": "/etc/ubuntu-advantage/uaclient.conf",
                "contract": {
                    "created_at": "",
                    "id": "",
                    "name": "",
                    "products": [
                        "landscape"
                    ],
                    "tech_support_level": "n/a"
                },
                "effective": "2024-10-25T12:23:42.637574+00:00",
                "environment_vars": [],
                "errors": [],
                "execution_details": "No Ubuntu Pro operations are running",
                "execution_status": "inactive",
                "expires": "2024-11-24T12:23:42.637574+00:00",
                "features": {},
                "machine_id": null,
                "notices": [],
                "result": "success",
                "services": [
                    {
                        "available": "yes",
                        "description": "Management and administration tool for Ubuntu",
                        "description_override": null,
                        "name": "landscape"
                    }
                ],
                "simulated": false,
                "version": "31.1",
                "warnings": []
            },
            "livepatch_info": null,
            "ubuntu_pro_reboot_required_info": null,
            "num_child": 0,
            "cloud_init": {},
            "is_wsl_instance": false,
            "children": [],
            "is_default_child": null,
            "parent": null,
            "alerts": [
                {
                    "type": "ComputerOfflineAlert",
                    "summary": "Offline",
                    "severity": "warning"
                }
            ]
        }
    ],
    "next": "/api/v2/computers?limit=1&with_alerts=true&offset=1",
    "previous": null
}

What data is used? Ping time? Exchange time? Minimum of both? Or the lack of “offline” alerts? Something else?

Tagging @mikecw :slight_smile:

Hi,

It uses both the ping time and the exchange time. There are two thresholds - so a device could still be pinging the server but if there has been no exchange for a longer time it is marked as offline.

I think defaults are 5mins for ping and 60 mins for exchange. And to pre-empt you - no those are not currently configurable.

And when ping is still None? I guess it can still go online?

I believe that is correct.

Ok, maybe it would be nice to expose the “online” status to the API, so not every developer has to figure this out again :smiley: And also to document this somewhere.

Where would the fun be in that if we made it easy!

I’ve forward this on to the Landscape Technical author and see if we can get it added in to the documentation for those who follow in your footsteps.

:joy: hahaha, thanks for keeping my life interesting I guess