Daily Health Check Scripting - Powershell

kk2491
Posts: 169
Joined: Fri Dec 05, 2014 6:42 am

Daily Health Check Scripting - Powershell

Post by kk2491 »

Hi All,

Good day.

I want to create a script for Daily health of the 3PAR storage array using Powershell toolkit.

It should include Storage system status, PD status, Node status, Port status and any new alerts found in the array.

But i am able to find only cmdlet related to PD and ports only. Is there any other command or combination of command available?

Thanks in advance.

Regards,
KK
walter_white
Posts: 42
Joined: Wed Nov 08, 2017 8:57 am

Re: Daily Health Check Scripting - Powershell

Post by walter_white »

kk2491 wrote:Hi All,

Good day.

I want to create a script for Daily health of the 3PAR storage array using Powershell toolkit.

It should include Storage system status, PD status, Node status, Port status and any new alerts found in the array.

But i am able to find only cmdlet related to PD and ports only. Is there any other command or combination of command available?

Thanks in advance.

Regards,
KK


Ever figure this out?
PJJJK
Posts: 5
Joined: Wed Nov 14, 2018 7:31 am

Re: Daily Health Check Scripting - Powershell

Post by PJJJK »

Hi,

I have wrote a daily health script in powershell.

It uses the plink program to access the 3PAR hosts and retrieves various reports that I then format into HTML and email it to the server team.

If you want a copy of my script let me know.
walter_white
Posts: 42
Joined: Wed Nov 08, 2017 8:57 am

Re: Daily Health Check Scripting - Powershell

Post by walter_white »

PJJJK wrote:Hi,

I have wrote a daily health script in powershell.

It uses the plink program to access the 3PAR hosts and retrieves various reports that I then format into HTML and email it to the server team.

If you want a copy of my script let me know.


I would love to see it. Thanks
natekippen
Posts: 72
Joined: Sun Dec 21, 2014 3:05 pm

Re: Daily Health Check Scripting - Powershell

Post by natekippen »

Me too.
PJJJK
Posts: 5
Joined: Wed Nov 14, 2018 7:31 am

Re: Daily Health Check Scripting - Powershell

Post by PJJJK »

Code: Select all

# Setup variables for the script
$curdir = "c:\powershell\3par\scheduled"
$Outname_adam = "$curdir\rcopystatus_adam.txt"
$OutnameDisk_adam = "$curdir\diskstatus_adam.txt"
$report_body = @()

$report = "$curdir\3par_status.html"
$err_count = 0
$color='#00FF00'

# Create a new output file and overwrite the existing file
New-Item -type file -force $Outname_adam > $null
New-Item -type file -force $OutnameDisk_adam > $null
New-Item -type file -force $report > $null

# Setup HTML report
$report_body += "<html>"
$report_body += "<head>"
$report_body += "<title>3PAR HTML Daily Report</title>"
$report_body += "<style>"
$report_body += "td {"
$report_body += "font-family: Tahoma;"
$report_body += "font-size: 11px;"
$report_body += "border-top: 1px solid #999999;"
$report_body += "border-right: 1px solid #999999;"
$report_body += "border-bottom: 1px solid #999999;"
$report_body += "border-left: 1px solid #999999;"
$report_body += "padding-top: 0px;"
$report_body += "padding-right: 0px;"
$report_body += "padding-bottom: 0px;"
$report_body += "padding-left: 0px;"
$report_body += "}"
$report_body += "body {"
$report_body += "margin-left: 5px;"
$report_body += "margin-top: 5px;"
$report_body += "margin-right: 0px;"
$report_body += "margin-bottom: 10px;"
$report_body += "}"
$report_body += "table {"
$report_body += "border: thin solid #000000;"
$report_body += "}"
$report_body += "</style>"
$report_body += "</head>"
$report_body += "<body>"

# Write out the name of the 3PAR system to the report so that I can identify it later
"ADAM-3PAR-8200" | out-file $OUTNAME_adam
# Make sure that the plink.exe is somewhere within your path
# Enter the IP, username and password of your 3PAR system
$RESULTS = & plink -ssh "IP of your 3PAR system" -l "username" -pw "password" "showrcopy" | out-file $OUTNAME_adam -Append # ADAM-3PAR-8200
"ADAM-3PAR-8200" | out-file $OutnameDisk_adam
$resultsdisk = & plink -ssh "IP of your 3PAR system" -l "username" -pw "password" "showinventory" | out-file $OutnameDisk_adam -Append # ADAM-3PAR-8200

# Import the contents of the ouptput file from running the 3PAR command
# and put it into an array
$select = Get-Content $Outname_adam
$selectdisk = Get-Content $OutnameDisk_adam

# Start extracting the data from the text file and format it for a HTML report
# Start at the first line (0)
$3par_name = $select[0]
$3par_status = $select[3].Substring(8)
$3par_target_name, $3par_target_id, $3par_target_type, $3par_target_status, $3par_target_options, $3par_target_policy = $select[8] -split ' {1,}'

$report_body += "<table width='50%'>"
$report_body += "<tr bgcolor='#AAAAAA'>"
$report_body += "<td colspan='2' height='25' align='center'>"
$report_body += "<font face='tahoma' color='#003399' size='4'><strong>3PAR System: $3par_name</strong></font>"
$report_body += "</td>"
$report_body += "</tr>"
$report_body += "<tr>"
$report_body += "<td width='50%' bgcolor=white><font size='2'>Status</font></td>"
$report_body += "</tr>"
$report_body += "<tr>"
if ($3par_status.trim() -ne "Started, Normal")
{
    $color='red'
    $err_count++
}
else
{
    $color='#00FF00'
}
$report_body += "<td width='50%' bgcolor=$color><font size='2'>$3par_status</font></td>"
$report_body += "</tr>"
$report_body += "</table>"
$report_body += "<table width='50%'>"
$report_body += "<tr bgcolor='#CCCCCC'>"
$report_body += "<td colspan='6' height='25' align='center'>"
$report_body += "<font face='tahoma' color='#003399' size='4'><strong>Target Information</strong></font>"
$report_body += "</td>"
$report_body += "</tr>"
$report_body += "</table>"
$report_body += "<table width='50%'>"
$report_body += "<tr bgcolor='#EEEEEE'>"
$report_body += "<td width='16%'><font size='2'>Name</font></td>"
$report_body += "<td width='16%'><font size='2'>ID</font></td>"
$report_body += "<td width='16%'><font size='2'>Type</font></td>"
$report_body += "<td width='16%'><font size='2'>Status</font></td>"
$report_body += "<td width='16%'><font size='2'>Options</font></td>"
$report_body += "<td width='16%'><font size='2'>Policy</font></td>"
$report_body += "</tr>"
$report_body += "<tr bgcolor=white>"
$report_body += "<td width='16%'>$3par_target_name</td>"
$report_body += "<td width='16%'>$3par_target_id</td>"
$report_body += "<td width='16%'>$3par_target_type</td>"
if ($3par_target_status.trim() -ne "ready")
{
    $color='red'
    $err_count++
}
else
{
    $color='#00FF00'
}
$report_body += "<td width='16%' bgcolor=$color>$3par_target_status</td>"
$report_body += "<td width='16%'>$3par_target_options</td>"
$report_body += "<td width='16%'>$3par_target_policy</td>"
$report_body += "</tr>"
$report_body += "</table>"

$report_body += "<table width='50%'>"
$report_body += "<tr bgcolor='#CCCCCC'>"
$report_body += "<td colspan='5' height='25' align='center'>"
$report_body += "<font face='tahoma' color='#003399' size='4'><strong>Link Information</strong></font>"
$report_body += "</td>"
$report_body += "</tr>"
$report_body += "<tr bgcolor='#EEEEEE'>"
$report_body += "<td width='20%'><font size='2'>Target</font></td>"
$report_body += "<td width='20%'><font size='2'>Node</font></td>"
$report_body += "<td width='20%'><font size='2'>Address</font></td>"
$report_body += "<td width='20%'><font size='2'>Status</font></td>"
$report_body += "<td width='20%'><font size='2'>Options</font></td>"
$report_body += "</tr>"

$color='#00FF00'
# The next line identifies the next part of the report that I need to process, you will need to change based on your own 3PAR system
$startline = $select | select-string -pattern "EVE-8200 0:2:3 20230002AC01CE99"
$line = $startline.linenumber - 1
do
{
    $3par_link_target, $3par_link_node, $3par_link_address, $3par_link_status, $3par_link_options = $select[$line] -split ' {1,}'
   
    $report_body += "<tr bgcolor=white>"
    $report_body += "<td width='20%'>$3par_link_target</td>"
    $report_body += "<td width='20%'>$3par_link_node</td>"
    $report_body += "<td width='20%'>$3par_link_address</td>"
    if ($3par_link_status.trim() -ne "Up")
    {
        $color='red'
        $err_count++
    }
    else
    {
        $color='#00FF00'
    }
    $report_body += "<td width='20%' bgcolor=$color>$3par_link_status</td>"
    $report_body += "<td width='20%'>$3par_link_options</td>"
    $report_body += "</tr>"
    $line ++
}
while ($line -lt ($startline.LineNumber + 3))
$report_body += "</table>"

$report_body += "<table width='100%'>"
$report_body += "<tr bgcolor='#CCCCCC'>"
$report_body += "<td colspan='6' height='25' align='center'>"
$report_body += "<font face='tahoma' color='#003399' size='4'><strong>Group Information</strong></font>"
$report_body += "</td>"
$report_body += "</tr>"
$report_body += "<tr bgcolor='#EEEEEE'>"
$report_body += "<td width='10%'><font size='2'>Name</font></td>"
$report_body += "<td width='10%'><font size='2'>Target</font></td>"
$report_body += "<td width='10%'><font size='2'>Status</font></td>"
$report_body += "<td width='10%'><font size='2'>Role</font></td>"
$report_body += "<td width='10%'><font size='2'>Mode</font></td>"
$report_body += "<td width='10%'><font size='2'>Options</font></td>"
$report_body += "</tr>"

$color='#00FF00'
$startline = $select | select-string -Pattern "Name         "
$startline_count = $startline.count - 1
for ($counter = 0; $counter -le $startline_count; $counter ++)
{
$line1 = $startline[$counter].linenumber
$line2 = $line1 + 2

    $3par_group_name, $3par_group_target, $3par_group_status, $3par_group_role, $3par_group_mode, $3par_group_options = $select[$line1] -split ' {1,}'
    $report_body += "<tr bgcolor=white>"
    $report_body += "<td width='10%'>$3par_group_name</td>"
    $report_body += "<td width='10%'>$3par_group_target</td>"
    if ($3par_group_status.trim() -ne "Started")
    {
        $color='red'
        $err_count++
    }
    else
    {
        $color='#00FF00'
    }
    $report_body += "<td width='10%' bgcolor=$color>$3par_group_status</td>"
    $report_body += "<td width='10%'>$3par_group_role</td>"
    $report_body += "<td width='10%'>$3par_group_mode</td>"
    $report_body += "<td width='10%'>$3par_group_options</td>"
    $report_body += "</tr>"
}
$report_body += "</table>"

$report_body += "<table width='100%'>"
$report_body += "<tr bgcolor='#CCCCCC'>"
$report_body += "<td colspan='10' height='25' align='center'>"
$report_body += "<font face='tahoma' color='#003399' size='4'><strong>Disk Status</strong></font>"
$report_body += "</td>"
$report_body += "</tr>"
$report_body += "<tr bgcolor='#EEEEEE'>"
$report_body += "<td width='10%'><font size='2'>ID</font></td>"
$report_body += "<td width='10%'><font size='2'>CagePos</font></td>"
$report_body += "<td width='10%'><font size='2'>State</font></td>"
$report_body += "<td width='10%'><font size='2'>WWN</font></td>"
$report_body += "<td width='10%'><font size='2'>MFR</font></td>"
$report_body += "<td width='10%'><font size='2'>Model</font></td>"
$report_body += "<td width='10%'><font size='2'>Serial</font></td>"
$report_body += "<td width='10%'><font size='2'>FW</font></td>"
$report_body += "<td width='10%'><font size='2'>Protocol</font></td>"
$report_body += "<td width='10%'><font size='2'>MediaType</font></td>"
$report_body += "</tr>"

$color='#00FF00'
# The next line should be the same for your 3PAR system
$startline = $selectdisk | select-string -pattern "Id CagePos State  ----Node_WWN---- --MFR-- -----Model------ -Serial- -FW_Rev- Protocol MediaType"
# These lines will need to be tweaked for your system
$unitline = $selectdisk | select-string -pattern "0 0:0:0"
$tenline = $selectdisk | select-string -pattern "10 1:2:0"
$hundredline = $selectdisk | select-string -pattern "100 3:20:0"
$line = $startline.LineNumber
$endline = $selectdisk | select-string -pattern "total"
do
{
    # This part refers to the number of disks installed
    # If there are more than 100 disks installed then the $sub variable needs to start 2 characters in from the start of the line
   # I have over 100 disks installed.  If your system does not have over 100 disks then this part needs amended.
   # If you take a look at the report your 3PAR system generates then you will see it indents depending on how many disks you have installed.
    if ($line -gt $unitline.linenumber - 2){$sub=2}
    if ($line -gt $tenline.linenumber - 2){$sub=1}
    if ($line -gt $hundredline.linenumber - 2){$sub=0}
    $Disk_ID, $Disk_Cagepos, $Disk_State, $Disk_WWN, $Disk_MFR, $Disk_Model, $Disk_Serial, $Disk_FW, $Disk_Protocol, $Disk_Mediatype = $selectdisk[$line].substring($sub) -split ' {1,}'
   
    $report_body += "<tr bgcolor='#EEEEEE'>"
    $report_body += "<td width='10%'>$Disk_ID</td>"
    $report_body += "<td width='10%'>$Disk_Cagepos</td>"
    if ($Disk_State.trim() -ne "new" -and $Disk_State -ne "normal"){$color='red';$err_count++}else{$color='#00FF00'}
    $report_body += "<td width='10%' bgcolor=$color>$Disk_State</td>"
    $report_body += "<td width='10%'>$Disk_WWN</td>"
    $report_body += "<td width='10%'>$Disk_MFR</td>"
    $report_body += "<td width='10%'>$Disk_Model</td>"
    $report_body += "<td width='10%'>$Disk_Serial</td>"
    $report_body += "<td width='10%'>$Disk_FW</td>"
    $report_body += "<td width='10%'>$Disk_Protocol</td>"
    $report_body += "<td width='10%'>$Disk_Mediatype</td>"
    $report_body += "</tr>"
    $line++
}
While ($line -ne ($endline.linenumber - 2))
$report_body += "</table>"

# Finish the HTML code correctly
$report_body += "</body>"
$report_body += "</html>"
$report_body | out-file $report

if ($err_count -eq 0){$err = "All OK"}else{$err = "ALERT - Please Investigate!"}

# Email the contents of the output file to the Infrastructure Team
$body = Get-Content $report | out-string
send-Mailmessage -To "destination email address" -From "3PAR_8200.Status@domain" -Subject "3PAR 8200 System Status - $err" -SmtpServer smtpserver -bodyashtml -body $body
PJJJK
Posts: 5
Joined: Wed Nov 14, 2018 7:31 am

Re: Daily Health Check Scripting - Powershell

Post by PJJJK »

Make sure that you read the remarks and change accordingly.
chinwm
Posts: 4
Joined: Tue Jan 22, 2013 9:10 pm

Re: Daily Health Check Scripting - Powershell

Post by chinwm »

PJJJK wrote:

Code: Select all

# Setup variables for the script
$curdir = "c:\powershell\3par\scheduled"
$Outname_adam = "$curdir\rcopystatus_adam.txt"
$OutnameDisk_adam = "$curdir\diskstatus_adam.txt"
$report_body = @()

$report = "$curdir\3par_status.html"
$err_count = 0
$color='#00FF00'

# Create a new output file and overwrite the existing file
New-Item -type file -force $Outname_adam > $null
New-Item -type file -force $OutnameDisk_adam > $null
New-Item -type file -force $report > $null

# Setup HTML report
$report_body += "<html>"
$report_body += "<head>"
$report_body += "<title>3PAR HTML Daily Report</title>"
$report_body += "<style>"
$report_body += "td {"
$report_body += "font-family: Tahoma;"
$report_body += "font-size: 11px;"
$report_body += "border-top: 1px solid #999999;"
$report_body += "border-right: 1px solid #999999;"
$report_body += "border-bottom: 1px solid #999999;"
$report_body += "border-left: 1px solid #999999;"
$report_body += "padding-top: 0px;"
$report_body += "padding-right: 0px;"
$report_body += "padding-bottom: 0px;"
$report_body += "padding-left: 0px;"
$report_body += "}"
$report_body += "body {"
$report_body += "margin-left: 5px;"
$report_body += "margin-top: 5px;"
$report_body += "margin-right: 0px;"
$report_body += "margin-bottom: 10px;"
$report_body += "}"
$report_body += "table {"
$report_body += "border: thin solid #000000;"
$report_body += "}"
$report_body += "</style>"
$report_body += "</head>"
$report_body += "<body>"

# Write out the name of the 3PAR system to the report so that I can identify it later
"ADAM-3PAR-8200" | out-file $OUTNAME_adam
# Make sure that the plink.exe is somewhere within your path
# Enter the IP, username and password of your 3PAR system
$RESULTS = & plink -ssh "IP of your 3PAR system" -l "username" -pw "password" "showrcopy" | out-file $OUTNAME_adam -Append # ADAM-3PAR-8200
"ADAM-3PAR-8200" | out-file $OutnameDisk_adam
$resultsdisk = & plink -ssh "IP of your 3PAR system" -l "username" -pw "password" "showinventory" | out-file $OutnameDisk_adam -Append # ADAM-3PAR-8200

# Import the contents of the ouptput file from running the 3PAR command
# and put it into an array
$select = Get-Content $Outname_adam
$selectdisk = Get-Content $OutnameDisk_adam

# Start extracting the data from the text file and format it for a HTML report
# Start at the first line (0)
$3par_name = $select[0]
$3par_status = $select[3].Substring(8)
$3par_target_name, $3par_target_id, $3par_target_type, $3par_target_status, $3par_target_options, $3par_target_policy = $select[8] -split ' {1,}'

$report_body += "<table width='50%'>"
$report_body += "<tr bgcolor='#AAAAAA'>"
$report_body += "<td colspan='2' height='25' align='center'>"
$report_body += "<font face='tahoma' color='#003399' size='4'><strong>3PAR System: $3par_name</strong></font>"
$report_body += "</td>"
$report_body += "</tr>"
$report_body += "<tr>"
$report_body += "<td width='50%' bgcolor=white><font size='2'>Status</font></td>"
$report_body += "</tr>"
$report_body += "<tr>"
if ($3par_status.trim() -ne "Started, Normal")
{
    $color='red'
    $err_count++
}
else
{
    $color='#00FF00'
}
$report_body += "<td width='50%' bgcolor=$color><font size='2'>$3par_status</font></td>"
$report_body += "</tr>"
$report_body += "</table>"
$report_body += "<table width='50%'>"
$report_body += "<tr bgcolor='#CCCCCC'>"
$report_body += "<td colspan='6' height='25' align='center'>"
$report_body += "<font face='tahoma' color='#003399' size='4'><strong>Target Information</strong></font>"
$report_body += "</td>"
$report_body += "</tr>"
$report_body += "</table>"
$report_body += "<table width='50%'>"
$report_body += "<tr bgcolor='#EEEEEE'>"
$report_body += "<td width='16%'><font size='2'>Name</font></td>"
$report_body += "<td width='16%'><font size='2'>ID</font></td>"
$report_body += "<td width='16%'><font size='2'>Type</font></td>"
$report_body += "<td width='16%'><font size='2'>Status</font></td>"
$report_body += "<td width='16%'><font size='2'>Options</font></td>"
$report_body += "<td width='16%'><font size='2'>Policy</font></td>"
$report_body += "</tr>"
$report_body += "<tr bgcolor=white>"
$report_body += "<td width='16%'>$3par_target_name</td>"
$report_body += "<td width='16%'>$3par_target_id</td>"
$report_body += "<td width='16%'>$3par_target_type</td>"
if ($3par_target_status.trim() -ne "ready")
{
    $color='red'
    $err_count++
}
else
{
    $color='#00FF00'
}
$report_body += "<td width='16%' bgcolor=$color>$3par_target_status</td>"
$report_body += "<td width='16%'>$3par_target_options</td>"
$report_body += "<td width='16%'>$3par_target_policy</td>"
$report_body += "</tr>"
$report_body += "</table>"

$report_body += "<table width='50%'>"
$report_body += "<tr bgcolor='#CCCCCC'>"
$report_body += "<td colspan='5' height='25' align='center'>"
$report_body += "<font face='tahoma' color='#003399' size='4'><strong>Link Information</strong></font>"
$report_body += "</td>"
$report_body += "</tr>"
$report_body += "<tr bgcolor='#EEEEEE'>"
$report_body += "<td width='20%'><font size='2'>Target</font></td>"
$report_body += "<td width='20%'><font size='2'>Node</font></td>"
$report_body += "<td width='20%'><font size='2'>Address</font></td>"
$report_body += "<td width='20%'><font size='2'>Status</font></td>"
$report_body += "<td width='20%'><font size='2'>Options</font></td>"
$report_body += "</tr>"

$color='#00FF00'
# The next line identifies the next part of the report that I need to process, you will need to change based on your own 3PAR system
$startline = $select | select-string -pattern "EVE-8200 0:2:3 20230002AC01CE99"
$line = $startline.linenumber - 1
do
{
    $3par_link_target, $3par_link_node, $3par_link_address, $3par_link_status, $3par_link_options = $select[$line] -split ' {1,}'
   
    $report_body += "<tr bgcolor=white>"
    $report_body += "<td width='20%'>$3par_link_target</td>"
    $report_body += "<td width='20%'>$3par_link_node</td>"
    $report_body += "<td width='20%'>$3par_link_address</td>"
    if ($3par_link_status.trim() -ne "Up")
    {
        $color='red'
        $err_count++
    }
    else
    {
        $color='#00FF00'
    }
    $report_body += "<td width='20%' bgcolor=$color>$3par_link_status</td>"
    $report_body += "<td width='20%'>$3par_link_options</td>"
    $report_body += "</tr>"
    $line ++
}
while ($line -lt ($startline.LineNumber + 3))
$report_body += "</table>"

$report_body += "<table width='100%'>"
$report_body += "<tr bgcolor='#CCCCCC'>"
$report_body += "<td colspan='6' height='25' align='center'>"
$report_body += "<font face='tahoma' color='#003399' size='4'><strong>Group Information</strong></font>"
$report_body += "</td>"
$report_body += "</tr>"
$report_body += "<tr bgcolor='#EEEEEE'>"
$report_body += "<td width='10%'><font size='2'>Name</font></td>"
$report_body += "<td width='10%'><font size='2'>Target</font></td>"
$report_body += "<td width='10%'><font size='2'>Status</font></td>"
$report_body += "<td width='10%'><font size='2'>Role</font></td>"
$report_body += "<td width='10%'><font size='2'>Mode</font></td>"
$report_body += "<td width='10%'><font size='2'>Options</font></td>"
$report_body += "</tr>"

$color='#00FF00'
$startline = $select | select-string -Pattern "Name         "
$startline_count = $startline.count - 1
for ($counter = 0; $counter -le $startline_count; $counter ++)
{
$line1 = $startline[$counter].linenumber
$line2 = $line1 + 2

    $3par_group_name, $3par_group_target, $3par_group_status, $3par_group_role, $3par_group_mode, $3par_group_options = $select[$line1] -split ' {1,}'
    $report_body += "<tr bgcolor=white>"
    $report_body += "<td width='10%'>$3par_group_name</td>"
    $report_body += "<td width='10%'>$3par_group_target</td>"
    if ($3par_group_status.trim() -ne "Started")
    {
        $color='red'
        $err_count++
    }
    else
    {
        $color='#00FF00'
    }
    $report_body += "<td width='10%' bgcolor=$color>$3par_group_status</td>"
    $report_body += "<td width='10%'>$3par_group_role</td>"
    $report_body += "<td width='10%'>$3par_group_mode</td>"
    $report_body += "<td width='10%'>$3par_group_options</td>"
    $report_body += "</tr>"
}
$report_body += "</table>"

$report_body += "<table width='100%'>"
$report_body += "<tr bgcolor='#CCCCCC'>"
$report_body += "<td colspan='10' height='25' align='center'>"
$report_body += "<font face='tahoma' color='#003399' size='4'><strong>Disk Status</strong></font>"
$report_body += "</td>"
$report_body += "</tr>"
$report_body += "<tr bgcolor='#EEEEEE'>"
$report_body += "<td width='10%'><font size='2'>ID</font></td>"
$report_body += "<td width='10%'><font size='2'>CagePos</font></td>"
$report_body += "<td width='10%'><font size='2'>State</font></td>"
$report_body += "<td width='10%'><font size='2'>WWN</font></td>"
$report_body += "<td width='10%'><font size='2'>MFR</font></td>"
$report_body += "<td width='10%'><font size='2'>Model</font></td>"
$report_body += "<td width='10%'><font size='2'>Serial</font></td>"
$report_body += "<td width='10%'><font size='2'>FW</font></td>"
$report_body += "<td width='10%'><font size='2'>Protocol</font></td>"
$report_body += "<td width='10%'><font size='2'>MediaType</font></td>"
$report_body += "</tr>"

$color='#00FF00'
# The next line should be the same for your 3PAR system
$startline = $selectdisk | select-string -pattern "Id CagePos State  ----Node_WWN---- --MFR-- -----Model------ -Serial- -FW_Rev- Protocol MediaType"
# These lines will need to be tweaked for your system
$unitline = $selectdisk | select-string -pattern "0 0:0:0"
$tenline = $selectdisk | select-string -pattern "10 1:2:0"
$hundredline = $selectdisk | select-string -pattern "100 3:20:0"
$line = $startline.LineNumber
$endline = $selectdisk | select-string -pattern "total"
do
{
    # This part refers to the number of disks installed
    # If there are more than 100 disks installed then the $sub variable needs to start 2 characters in from the start of the line
   # I have over 100 disks installed.  If your system does not have over 100 disks then this part needs amended.
   # If you take a look at the report your 3PAR system generates then you will see it indents depending on how many disks you have installed.
    if ($line -gt $unitline.linenumber - 2){$sub=2}
    if ($line -gt $tenline.linenumber - 2){$sub=1}
    if ($line -gt $hundredline.linenumber - 2){$sub=0}
    $Disk_ID, $Disk_Cagepos, $Disk_State, $Disk_WWN, $Disk_MFR, $Disk_Model, $Disk_Serial, $Disk_FW, $Disk_Protocol, $Disk_Mediatype = $selectdisk[$line].substring($sub) -split ' {1,}'
   
    $report_body += "<tr bgcolor='#EEEEEE'>"
    $report_body += "<td width='10%'>$Disk_ID</td>"
    $report_body += "<td width='10%'>$Disk_Cagepos</td>"
    if ($Disk_State.trim() -ne "new" -and $Disk_State -ne "normal"){$color='red';$err_count++}else{$color='#00FF00'}
    $report_body += "<td width='10%' bgcolor=$color>$Disk_State</td>"
    $report_body += "<td width='10%'>$Disk_WWN</td>"
    $report_body += "<td width='10%'>$Disk_MFR</td>"
    $report_body += "<td width='10%'>$Disk_Model</td>"
    $report_body += "<td width='10%'>$Disk_Serial</td>"
    $report_body += "<td width='10%'>$Disk_FW</td>"
    $report_body += "<td width='10%'>$Disk_Protocol</td>"
    $report_body += "<td width='10%'>$Disk_Mediatype</td>"
    $report_body += "</tr>"
    $line++
}
While ($line -ne ($endline.linenumber - 2))
$report_body += "</table>"

# Finish the HTML code correctly
$report_body += "</body>"
$report_body += "</html>"
$report_body | out-file $report

if ($err_count -eq 0){$err = "All OK"}else{$err = "ALERT - Please Investigate!"}

# Email the contents of the output file to the Infrastructure Team
$body = Get-Content $report | out-string
send-Mailmessage -To "destination email address" -From "3PAR_8200.Status@domain" -Subject "3PAR 8200 System Status - $err" -SmtpServer smtpserver -bodyashtml -body $body



what is this line pointing to?
$startline = $select | select-string -pattern "EVE-8200 0:2:3 20230002AC01CE99"
PJJJK
Posts: 5
Joined: Wed Nov 14, 2018 7:31 am

Re: Daily Health Check Scripting - Powershell

Post by PJJJK »

The script gets a showrcopy report from the 3PAR system using SSH and then takes information from this report, formats it and emails to whoever you define.

That particular line is from my own report, you will need to change it for your report. That line points to the 'Link Information' part of the showrcopy report.

Instead of the script reading the full showrcopy report, I have defined lines that tell the script to jump to that part of the report.
bezzat
Posts: 1
Joined: Tue Feb 25, 2020 4:47 am

Re: Daily Health Check Scripting - Powershell

Post by bezzat »

hi
Excellent script - thank you very much
I tried a bit to fix the script for myself and unfortunately I couldn't
I would like to download the Disk Status and Link Information table and leave only the Group Information

How to do it?
Thanks
Post Reply