example powershell script

You can easily configure the SysOrb agent to execute powershell scripts. Get the result presented in a graph in SysOrb and configure the threshold for the check. Below is provided an example for inspiration on how to do it.

In custom.conf:

# Custom check configuration for the SysOrb agent.
[System uptime]
command=powershell -NoLogo "C:\Get-UpTime.ps1"
result_pattern=TotalDays: ([[:digit:]]+\.?[[:digit:]]*)

In C:\Get-UpTime.ps1

#  Powershell script for getting system uptime in days

# Helper Function - convert WMI date to TimeDate object
function WMIDateStringToDate($Bootup) {

# Main script
$Computer = "." # adjust as needed
$computers = Get-WMIObject -class Win32_OperatingSystem -computer $computer

foreach ($system in $computers) {
    $Bootup = $system.LastBootUpTime
    $LastBootUpTime = WMIDateStringToDate($Bootup)
    $now = Get-Date
    $Uptime = $now - $lastBootUpTime
    "TotalDays: {0}" -f [string]$Uptime.TotalDays
# End script