My first though was ... "WebConsole can't do the job ..."
So i remembered that PS1 could save my day!
Cons:
- SCOM Web Console too slow;
- You need IE;
- ... and silverlight;
Solution :
- Created a PS1 that for every different group i want gets latest 24h alerts (Warn/Crit);
- Foreach group i create an HTML file and put it on my favourite Web-Server;
- Created a Runbook that for a 90 seconds schedule runs the PS1;
- You can also have a Scheduled Task for the Job;
- HTML has a meta tag that makes HTML refresh every 30 seconds;
Import-Module OperationsManager
New-SCOMManagementGroupConnection -ComputerName "SCOMSERVER_GOES_HERE"
$MyGroups = @()
Foreach ($item in Get-Content C:\OpsMgr\WebAlertViews\conf\Groups.conf ) { # Dont Forget to change this!
$MyGroups += Get-SCOMGroup -DisplayName $item
}
$newTime = (Get-Date).AddHours(-24)
$Criteria = New-Object Microsoft.EnterpriseManagement.Monitoring.MonitoringAlertCriteria("ResolutionState = 0 AND Severity >= 1 AND TimeRaised > `'$newTime`'")
$TransversalDepth = [Microsoft.EnterpriseManagement.Common.TraversalDepth]::Recursive
Foreach ( $Group in $MyGroups ) {
$Head = "<meta http-equiv='refresh' content='30'>"
$Head +="<style>"
$Head +="BODY{background-color:White;font-family:Verdana,sans-serif; font-size: x-small;}"
$Head +="TABLE{font-family: verdana,arial,sans-serif; font-size:12px; color:#333333; border-width: 1px; border-color: #666666; border-collapse: collapse;}"
$Head +="TH{border-width: 1px; padding: 8px; border-style: solid; border-color: #666666; background-color: #dedede;}"
$Head +="TD{border-width: 1px; padding: 8px; border-style: solid; width:auto;}"
$Head +="</style>"
$Body = "<br><br>"
$Body += "<img src='.\images\nos_logo_detail.png' height='12%' width='12%'>"
$Body += "<center><h1 style=color:#999999>.: Relatório SCOM - Alert View | $(($Group).DisplayName) :.</center>"
$Body += "<center><table>"
$Body += "<tr>"
$Body += "<td>Severity</td>"
$Body += "<td>Time Raised</td>"
$Body += "<td>Path</td>"
$Body += "<td>Name</td>"
$Body += "<td>DisplayName</td>"
$Body += "<td>Description</td>"
$Body += "</tr>"
$Alerts = $Group.GetMonitoringAlerts( $Criteria, $TransversalDepth )
Foreach ($Alert in $Alerts ) {
If ($Alert.Severity -eq 2) { $image = 'critical.png' } # You need this files
If ($Alert.Severity -eq 1) { $image = 'warning.png' }
$Body += "<tr>"
$Body += "<center><td><img src='.\images\$Image' height='25px' width='25px'></td></center>"
$Body += "<td>$(($alert).TimeRaised)</td>"
$Body += "<td>$(($alert).MonitoringObjectPath)</td>"
$Body += "<td>$(($alert).Name)</td>"
$Body += "<td>$(($alert).MonitoringObjectDisplayName)</td>"
$Body += "<td>$(($alert).Description)</td>"
$Body += "</tr>"
}
$Body += "</table></center>"
# I got the above replace because of "Unix/Linux Group!"
$HTMLFileName = (($Group.DisplayName -replace '/','_') -replace ' ','') + '.html'
$HTML = ConvertTo-Html -Head $head -Body $Body
$HTML > \\MyWebServer\SiteName\AlertViews\AlertView_$HTMLFileName
}
No comments:
Post a Comment