Recently we added a global customer to our owns. It spans 6 time zones with several sites and branch offices. This moved our monitoring scenarios one step further and sadly rised what I see as a major lack in OpsMgr. The first thing our support people asked me was: I need to know when this has happened in local time, it’s ok to have alerts in my local time but I need to know when this happened in agent local time. Easy I though, I could remember from MOM 2005 times the alert table had a local time raised field… alas this is no more the case with OpsMgr.
We needed a solution so I started drilling into the alert exposed fields. First there’s no help in the extended alert properties as they’re visible in console, they all just report the alert time in console local time.
I took a closer look at the database table and I confirmed there’s no direct or indirect reference at the alert local agent time, but things were not so bad at least the alert context had all the data I needed.
From my research *almost* every alert has a context (there are exception for rollup generated alerts) and in the alert context there’s always the time property referring to the agent local time.
So it was time to bring this piece of information in console and the natural way to do so is via an alert targeted task. The logic is very simple in powershell:
# Get the named parameters
#let’s register the opsmgr snapin
#required error checking is missing
$Setup =Get-Item -Path “HKLM:\Software\Microsoft\Microsoft Operations Manager\3.0\Setup”
$dir = $setup.GetValue(“InstallDirectory”)
$alert = Get-Alert -id:$alertGUID
if($alert -ne $null)
if ($alert.context -ne $null -and $alert.context -ne “”)
$c = [xml] $alert.context
$localtime = [datetime] $c.DataItem.Time.Substring(0,19)
$localtime = “unknown”
$message = ($alert.Name) + “`nLocal Agent Time Raised: ” + $localtime + “`nUTC Time Raised: ” + ($alert.TimeRaised) `
+ “`nUTC Time Last Modified: ” + ($alert.LastModified)
$message = “alert not found”
#finally return the raw message
The net result is not elegant but it works:
This is an internal tool so it lacks error checking and a proper installation procedure. To have a better interface I could have written a small managed code utility with a few lines of OpsMgr SDK and some UI, but it was out of scope at this time. Maybe in the future if more data is needed.
To make the while thing work you have to:
- Copy the powershell script in the OpsMgr installation directory on every console computer
- Import the attached management pack
Hope this help.
You can find the attachments here: Get Alert local time
This posting is provided “AS IS” with no warranties, and confers no rights.