Computer Uptime

Does anyone currently using SCOM/SquaredUP use a monitor/dashboard to report on servers that have uptime greater than x days. This would be useful in catching anything that was missing from the usual patching schedule.

3 Likes

Yes, we have one for that exact reason for 40 days.

You can do this by creating a monitor using ‘simple thresholds’ the slight flaw is, that if you have to vape the local health cache it will close the alert, however it will check again X hours later and re-open it.

There is another way you can do it via PowerShell and actually looking at the ‘net server statistics’ uptime and comparing it to the current date and time, but it wasn’t worth the effort to re-invent the wheel seeing as it’s been in place for a long time.

See the pictures below for the details.

From there we get a little fancy with it. We have a powershell script that runs every hour as a windows tasks, is searches SCOM for that alert ‘Windows server uptime exceeded’ and then it converts the alert from ‘new’ to a custom state.

We then have a dash in Squared Up which simply displays all the alerts with that state…

5 Likes

Works great, thanks. For anyone else that needs it the PowerShell script is below (you just need to change the alert name and the custom resolution state you create,

import-module operationsmanager
$Alerts = Get-SCOMAlert | Where-Object {($.ResolutionState -ne 255) -and ($.Name -like “System uptime exceeds 105 days”)}

foreach ($Alert in $Alerts)

{
get-scomalert $alert.id | set-scomalert -ResolutionState 13
}

For anyone that wants to run it as a task you can use the following, this also has scope to use a text file look up for the alert names, which means if you have 20 different alerts you automatically want to set to the Web team you can do so in one process…

#Made by Marnix Wolf

#Import SCOM 2012 Module & connect to Management Server
Import-Module OperationsManager
New-SCManagementGroupConnection -ComputerName SERVERNAME.domain

#Define array of operational SCOM Alerts based on text file
#Please adjust text file location in the next line
$Uptimestring = Get-Content “D:\Scripts\InfraAppsAlerts\Uptime.txt”

#Check for specific Alerts defined in array and flip Resolution State from ‘New’ (0) to ‘Server Uptime Exceeded’ (188)
foreach ($Uptime in $Uptimestring)
{
Get-SCOMAlert -Criteria “ResolutionState = ‘0’ AND Name = ‘$Uptime’” | Set-SCOMAlert -ResolutionState 188 -Comment “Alert Resolution State flipped from New (0) to -Server Uptime Exceeded- (188) by PS script.”
}

#End of script