Friends,
I just want to share one script I have created recently, not quite interesting but obviously played its significance to my case.
This script report and alert any hardware issue with UCS server environment, which was quite easy to report it through UCS central or UCSM environment however it is tough to identify the real hardware issue segregated from thousands of auto alert generated from system.
Below script work in conjunction with powertool to generated inoperable or error events across all UCSM and UCS blades with in your network
You may include Import-Module “C:\Program Files (x86)\Cisco\Cisco UCS Manager PowerTool\Modules\CiscoUcsPS\CiscoUcsPS.dll” if you are not running on powertool or schedule as a job, to import the module on powershell.
$body= “<p><u><b><span style=’font-size:10.0pt;font-family:Century Gothic’>UCS Server Issue reported </span></b></u> </p>
<table border=’1′ bgcolor=’#ffffff’>
<tr>
<th>UCS</th>
<th>Issue Server</th>
<th>Server location</th>
<th>Serial Number</th>
<th>Models</th>
<th>Operational State</th>
<th>Description</th>
</tr>”$ucsms = @(“USCM1”, “USCM2”, “USCM3”, “USCM4”, “USCM5”)
$ucscred = get-credential
foreach ($ucsm in $ucsms){
Connect-Ucs $ucsm -Credential $ucscred
$chassiss = Get-UcsChassisforeach ($chassis in $chassiss){
$decrucs = @()
$chassisname = $chassis.Rn
$ChassisSl = $chassis.Serial
$chassisOperState = $chassis.OperState
$chassisModel = $chassis.Model$chassis| get-ucsfault |?{$_.Descr -like “*inoperable*” -or $_.Descr -like “*FAILED*”-and $_.Descr -notlike “*server*”}| %{
$decrucs = $_.Descr
$body += ”
<tr>
<td>$ucsm</td>
<td>$chassisname</td>
<td>$chassisname</td>
<td>$ChassisSl</td>
<td>$chassisModel</td>
<td>$chassisOperState</td>
<td>$decrucs</td>
</tr>”
}
}
$servers = Get-UcsServer
foreach ($server in $servers)
{
$decr = @()
$ucs = $server.Ucs
$serverSl = $server.Serial
$UcsDn = $server.Dn
$serverOperState = $server.OperState
$ServerModel = $server.Model
$ServerName = $server.AssignedToDn
$ServerName = $ServerName.trim(“org-root/ls-“)#$server | get-ucsfault |? {$_.Descr -like “*inoperable*”} | Select Descr
$server | get-ucsfault |? {$_.Descr -like “*inoperable*”} | %{
$decr = $_.Descr
$body += ”
<tr>
<td>$ucs</td>
<td>$ServerName</td>
<td>$UcsDn</td>
<td>$serverSl</td>
<td>$ServerModel</td>
<td>$serverOperState</td>
<td>$decr</td>
</tr>”
}
$decr
}
Disconnect-Ucs
}
$body += “</table>”$rec = “MyMail@domain.com”, “MyGroupmail@domain.com”
Send-MailMessage -Body $body -To $rec -From “UCSAlerts@domain.com” -Subject “UCS Hardware alerts” -SmtpServer Smpt@domain.com-BodyAsHtml -priority High