See what you’re importing.
Read-only preview
/*
# -----------------------------------------------------------------------------
# This resource is provided as a convenience for Level users. We cannot
# guarantee it will work in all environments. Please test before deploying
# to your production environment. We welcome contributions to our community
# library
# Level Library
# https://level.io/library/script-osquery-monitor-uptime
*/
SELECT days FROM uptime;Before you run it.
Test the query in a development or sandbox environment
Pair with a script-based monitor in Level to trigger alerts when uptime crosses a defined limit
Use a scheduled Level Automation to run this query regularly
Combine with other OsQuery checks for a comprehensive overview of system health
Review the results to identify trends and anticipate required reboots
More about this resource.
What it does
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
When to use it
- Notifying teams when a server or endpoint surpasses a recommended uptime window
- Planning scheduled maintenance or patch cycles based on uptime data
- Ensuring reliable performance in mission-critical systems
- Monitoring endpoints with known memory or resource constraints
The problem it solves
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.