Hi All,
there is a lot of challenge, when we are doing HP hardware monitoring by Solarwinds, many time we are not getting alert and it leads the problem and question for solarwinds which are not able to monitor the h/w component
So i have come in one next steps for monitoring of HP hardware by Powershell script.
I installed the below HPILO CMD let into one DEV machine.
Download and install HPiLOCmdlets-x64.msi
Cmdlet Get-HPiLOHealthSummary
Post installation i ran the below PS script to get the out put of HP hardware with status.
--------------------
$ErrorActionPreference= 'silentlycontinue'
$Username="Administrator"
$Password="XYZ"
$path = "C:\HPiLOCmdlets\Samples\test.csv"
$csv = Import-Csv $path
$data=foreach ($thisILO in $csv){
Get-HPiLOHealthSummary -server $thisILO.ILOIPv4Address -username $Username -password $Password|Select-Object @{N="ILOIPv4Address";E={$thisILO.ILOIPv4Address}},`
@{N="BATTERY_STATUS";E={$_.BATTERY_STATUS}},@{N="BIOS_HARDWARE_STATUS";E={$_.BIOS_HARDWARE_STATUS}},@{N="FANS_STATUS";E={$_.FANS.STATUS[0]}},@{N="FANS_REDUNDANCY";E={$_.FANS.REDUNDANCY[1]}},`
@{N="MEMORY_STATUS";E={$_.MEMORY_STATUS}},@{N="NETWORK_STATUS";E={$_.NETWORK_STATUS}},@{N="POWER_SUPPLIES_STATUS";E={$_.POWER_SUPPLIES.STATUS[0]}},@{N="POWER_SUPPLIES_REDUNDANCY";E={$_.POWER_SUPPLIES.REDUNDANCY[1]}},`
@{N="PROCESSOR_STATUS";E={$_.PROCESSOR_STATUS}},@{N="STORAGE_STATUS";E={$_.STORAGE_STATUS}},@{N="TEMPERATURE_STATUS";E={$_.TEMPERATURE_STATUS}},@{N="HOSTNAME";E={$thisILO.HostName}},`
@{N="CLUSTERNAME";E={$thisILO.Cluster}},@{N="DATACENTERNAME";E={$thisILO.Datacenter}}
}
$data|export-csv -NoTypeInformation -path "C:\HPiLOCmdlets\Samples\result.csv"
$Hostname = "nodename"
$Date = Get-Date
$Email_To="your email address"
$Email_From = "Email address"
$Prioritystate="Low"
$Email_Header = ""
$SMTPSRV = "IP address" #"SMTP address"
$Email_Subject = "HPE ILO Status as of $Date"
$Email_Body = ""
$Email_Body += $Email_Header
$Email_Footer = "`n `nBest regards, `n$Hostname"
$header = @"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>HPE ILO Status Report</title>
<style type="text/css">
<!--
body {
background-color: peachpuff;
font-family: sans-serif;
font-size:7pt;
}
TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}
TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}
}
-->
</style>
$body = @"
<h1>HPE ILO Status</h1>
<p>The following report was run on $(get-date).</p>
"@ # + ($csvHTML[5..($csvHTML.length-2)] | Out-String)
#how-to-replace-multiple-strings-in-a-file-using-powershell One option is to chain the -replace operations together. The ` at the end of each line escapes the newline, causing PowerShell to continue parsing the expression on the next line
$csvHTML = Import-Csv C:\HPiLOCmdlets\Samples\result.csv | ConvertTo-Html -head $header -body $body |foreach {
$PSItem -replace "<td>Degraded</td>", "<td style='background-color:#FF8080'>Degraded</td>" `
-replace "<td>Unkown</td>", "<td style='background-color:#FF8080'>Unknown</td>" `
-replace "<td>Other</td>", "<td style='background-color:#FF8080'>Other</td>" `
-replace "<td>Failed</td>", "<td style='background-color:#FF8080'>Failed</td>"
#
#$prioritystate="High"
} #| Out-File C:\HPiLOCmdlets\Samples\result.html
$Email_Body +=$csvHTML
$Email_Body += $Email_Footer
if ($Flag_Send_Email -eq 0) {
echo $Email_Body
}
else {
send-Mailmessage -To $Email_To -From $Email_From -Subject $Email_Subject -SmtpServer $SMTPSRV -Bodyashtml $Email_Body -Priority $Prioritystate
}
------------------------------------------
However I need your help to create a SAM template, so by SAM template PS script will run and check the h/w status and return result with error if found any failed in h/w.
Provide your suggestion, So we can achieve this.