Back to Resources
Level
Script
General
Extended system uptimes can lead to memory leaks, decreased performance, and unaddressed software updates, ultimately exposing endpoints to reliability issues and security vulnerabilities. Monitoring how long a system has been running helps IT Professionals and MSPs schedule timely reboots or maintenance before problems escalate.
This resource uses OsQuery to check a system’s current uptime in days. By returning a simple numeric result, it provides a straightforward glimpse into how long a system has been operational since its last reboot.
When combined with Level’s script-based monitoring or automated workflows, this query can alert you if a machine has exceeded a preset threshold. In addition, you can schedule it at regular intervals to maintain a clear picture of overall system stability and proactively plan reboots.
Script
1/*
2# -----------------------------------------------------------------------------
3# This resource is provided as a convenience for Level users. We cannot
4# guarantee it will work in all environments. Please test before deploying
5# to your production environment. We welcome contributions to our community
6# library
7
8# Level Library
9# https://level.io/library/script-osquery-monitor-uptime
10*/
11
12SELECT days FROM uptime;
uptime
table and retrieves the number of days since the last reboot.uptime
table is available on your target OS.OsQuery Monitor - Uptime
This osquery script queries the system's uptime table to return the number of days since the last reboot, which is useful for monitoring system stability and identifying machines that may need maintenance.
OsQuery
100
Local system
Explore more automations, scripts, and policies to further enhance your IT operations.