Rust development slice / linux (push) Failing after 15s
linux.proxmox gets a strict validator and a 128 KiB scope budget. Device details expose guests, backup jobs with ok/failed/missed/running status and linked devices. Base snapshots reconcile unique guest MACs into assets.hypervisor_asset_id with hypervisor_source='proxmox'; manual choices are kept and can be handed back to automatic detection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
1.5 KiB
SQL
29 lines
1.5 KiB
SQL
-- Current devices of customer $1 linked to host $2, with the MACs they report themselves.
|
|
SELECT asset.asset_id, inst.agent_id, asset.hypervisor_source,
|
|
inventory.data->>'hostname' AS hostname,
|
|
COALESCE((
|
|
SELECT jsonb_agg(DISTINCT lower(i->>'mac'))
|
|
FROM jsonb_array_elements(CASE WHEN jsonb_typeof(inventory.data->'observations')='array'
|
|
THEN inventory.data->'observations' ELSE '[]'::jsonb END) o,
|
|
jsonb_array_elements(CASE
|
|
WHEN jsonb_typeof(o->'data')='array' THEN o->'data'
|
|
WHEN jsonb_typeof(o#>'{data,entries}')='array' THEN o#>'{data,entries}'
|
|
ELSE '[]'::jsonb END) i
|
|
WHERE o->>'scope' IN ('linux.interfaces','windows.interfaces') AND o->>'quality'='valid'
|
|
AND i->>'mac' IS NOT NULL
|
|
), '[]'::jsonb) AS macs
|
|
FROM assets asset
|
|
JOIN LATERAL (
|
|
SELECT a.agent_id, a.revoked_at FROM agent_installations a
|
|
WHERE a.tenant_id=asset.tenant_id AND a.asset_id=asset.asset_id AND NOT a.customer_transfer_pending
|
|
ORDER BY a.enrollment_generation DESC, a.created_at DESC, a.agent_id LIMIT 1
|
|
) inst ON inst.revoked_at IS NULL
|
|
LEFT JOIN LATERAL (
|
|
SELECT data FROM observations
|
|
WHERE tenant_id=asset.tenant_id AND agent_id=inst.agent_id AND source_id IN ('linux.base','windows.base')
|
|
ORDER BY observed_at DESC, received_at DESC, sequence DESC LIMIT 1
|
|
) inventory ON true
|
|
WHERE asset.tenant_id=$1 AND asset.hypervisor_asset_id=$2 AND asset.archived_at IS NULL
|
|
ORDER BY asset.asset_id
|
|
LIMIT 1024
|