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.
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âŚ
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