HI Luc,
just thought of putting sepatate script for alarms .
this is calculting alarm at cluster level .if you cud suggest on following points.
1:will it include all alarms of all viobjects (vms.esxi.datastores)inside cluster ??
2.can you modify it so that cluster name part has different color everytime it loops.
$path1 = 'D:\hc'
$path = "D:\hc\data-$(Get-Date -Format 'yyyyMMdd-HHmm').html"
$head = @'
<style>
body { background-color:#dddddd;
font-family:Tahoma;
font-size:12pt; }
td, th { border:1px solid black;
border-collapse:collapse; }
th { color:white;
background-color:black; }
table, tr, td, th { padding: 2px; margin: 0px }
table { margin-left:50px; }
</style>
'@
$fragments = @()
$clusters=get-cluster
foreach ($line in $clusters) {
$cluster = Get-Cluster -name $line
foreach ($triggered in $cluster.ExtensionData.TriggeredAlarmState)
{
If ($triggered.OverallStatus -like "red" -or $triggered.OverallStatus -like "yellow" )
{
#Write-Host "check alarm on " $e.Name -ForegroundColor Yellow
$lineitem = { } | Select Name, AlarmInfo
$alarmDef = Get-View -Id $triggered.Alarm
$lineitem.Name = $e.Name
$lineitem.AlarmInfo = $alarmDef.Info.Name
$Report += $lineitem
}
}
$fragments += $cluster|select name | Convertto-html -property name -precontent '<h2>clustername</h2>'|out-string
$fragments += $report |
ConvertTo-Html -PreContent '<h2>clusteralarm</h2>' |
Out-String
}
ConvertTo-HTML -head $head -PostContent $fragments |Out-String | Out-File -FilePath $path