Problem overview.
The challenge this resource is designed to solve.
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.
About this resource.
What it does and how it fits into your workflow.
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
/*
# -----------------------------------------------------------------------------
# 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;Use cases.
Common ways to put this resource to work.
- 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
Recommendations.
Practical guidance for a reliable rollout.
- 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