Devices with uptime over 6 months
The following query shows devices that have been up for at least 6 months. For every device, the output includes the device name, OS, snapshot status, uptime in seconds, and a formatted uptime string.
import "Time/Utils";
secondsIn6Months = 60 * 60 * 24 * 365 / 2;
formatStatus(deviceSnapshotResult) =
when deviceSnapshotResult is
collectionFailed(collectionError) ->
"Collecting - " +
replace(toString(collectionError), "DeviceCollectionError.", "");
completed -> "Completed";
processingFailed(processingError) ->
"Processing - " +
replace(toString(processingError), "DeviceProcessingError.", "");
foreach device in network.devices
let uptimeSeconds = device.system.uptimeSeconds
where uptimeSeconds > secondsIn6Months
select {
deviceName: device.name,
os: device.platform.os,
Status: formatStatus(device.snapshotInfo.result),
"Uptime Seconds": uptimeSeconds,
Uptime: if isPresent(uptimeSeconds) then formatSeconds(uptimeSeconds) else ""
}