Ironport Health Check

Hi Readers,

You have seen other Health check scripts from me for Exchange , AD /Microsoft products.

This time I have used PowerShell to perform health check on Cisco Product i.e. IronPort 🙂

Thanks to the Internet community from which I got the idea on how can I use PowerShell & get Health check reports out of IronPort by using XML.

Just download the zip file from below link  & change the variables in .ps1 file.

https://gallery.technet.microsoft.com/scriptcenter/Ironport-Health-Check-22daa2db

Note:- you just need a account on IronPort with guest privileges.

———————————————————————————-

$Userid = “guest”$IronPort1 = “https://Ironportname/xml/status”

$password =”Guest123″

$ramthreshold = “80”

$cputhreshold = “90”

$wqueuethreshold = “100”

$reportpath = “.\IPReport.htm”

if((test-path $reportpath) -like $false){new-item $reportpath -type file}

$smtphost = “smtpserver”

$from = “IronportStatus@labtest.com”

$to = “sukhija@labtest.com”

———————————————————————————-

Run the batch file & you will get the result in your email as shown in below screenshot.

 

############################################################################# 
#       Author: Vikas Sukhija 
#       Date: 10/13/2015 
#    Modified: 
#       Description: Ironport Health Dasboard 
############################################################################# 
 
$Userid = "guest" 
$IronPort1 = "https://Ironportname/xml/status" 
$password ="Guest123" 
$ramthreshold = "80" 
$cputhreshold = "90" 
$wqueuethreshold = "100" 
 
$reportpath = ".\IPReport.htm"  
 
if((test-path $reportpath-like $false) 
{ 
new-item $reportpath -type file 
} 
 
$smtphost = "smtpserver" 
$from = "IronportStatus@labtest.com" 
$to = "sukhija@labtest.com" 
 
 
############Call Web clientt############ 
 
$WebClient = new-object System.Net.WebClient 
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true$WebClient.Credentials = new-object System.Net.NetworkCredential($Userid$password) 
[xml]$XMLIronport1 = $webclient.DownloadString($IronPort1) 
 
$report = $reportpath 
 
Clear-Content $report  
 
Add-Content $report "<html>"  
Add-Content $report "<head>"  
Add-Content $report "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"  
Add-Content $report '<title>Ironport Health Dasboard</title>'  
add-content $report '<STYLE TYPE="text/css">'  
add-content $report  "<!--"  
add-content $report  "td {"  
add-content $report  "font-family: Tahoma;"  
add-content $report  "font-size: 11px;"  
add-content $report  "border-top: 1px solid #999999;"  
add-content $report  "border-right: 1px solid #999999;"  
add-content $report  "border-bottom: 1px solid #999999;"  
add-content $report  "border-left: 1px solid #999999;"  
add-content $report  "padding-top: 0px;"  
add-content $report  "padding-right: 0px;"  
add-content $report  "padding-bottom: 0px;"  
add-content $report  "padding-left: 0px;"  
add-content $report  "}"  
add-content $report  "body {"  
add-content $report  "margin-left: 5px;"  
add-content $report  "margin-top: 5px;"  
add-content $report  "margin-right: 0px;"  
add-content $report  "margin-bottom: 10px;"  
add-content $report  ""  
add-content $report  "table {"  
add-content $report  "border: thin solid #000000;"  
add-content $report  "}"  
add-content $report  "-->"  
add-content $report  "</style>"  
Add-Content $report "</head>"  
 
Add-Content $report "<body>"  
add-content $report  "<table width='50%'>"  
add-content $report  "<tr bgcolor='Lavender'>"  
add-content $report  "<td colspan='7' height='25' align='center'>"  
add-content $report  "<font face='tahoma' color='#003399' size='4'><strong>Ironport Device Status</strong></font>"  
add-content $report  "</td>"  
add-content $report  "</tr>"  
add-content $report  "</table>"  
  
add-content $report  "<table width='50%'>"  
Add-Content $report  "<td width='20%' align='center'><B>Identity</B></td>"  
 
 
###################################################################################### 
 
        $Identity = $XMLIronport1.status.hostname 
        $status =  $XMLIronport1.status.system.status 
        $birthtime1 = $XMLIronport1.status.birth_time 
        $birthtime = $birthtime1.timestamp  
 
         
        Add-Content $report "<td bgcolor= 'GainsBoro' align=center>  <B> $Identity</B></td>"  
        Add-Content $report "</tr>" 
 
        Add-Content $report "<tr>" 
        Add-Content $report  "<td width='20%' align='center'><B>Status</B></td>"  
        if ($status -eq "online"){Add-Content $report "<td bgcolor= 'Aquamarine' align=center>  <B>$status</B></td>" 
        }else{Add-Content $report "<td bgcolor= 'Red' align=center>  <B>$status</B></td>"} 
        Add-Content $report "</tr>" 
 
        Add-Content $report "<tr>" 
        Add-Content $report  "<td width='20%' align='center'><B>UpSince</B></td>" 
        Add-Content $report "<td bgcolor= 'GainsBoro' align=center>  <B>$birthtime</B></td>"  
        Add-Content $report "</tr>" 
 
 
############################################################################################# 
 
$gauge = $XMLIronport1.status.gauges.gauge 
$ramu = $gauge | Where{$_.name -eq "ram_utilization"$ramuc = $ramu.current 
$cpuu = $gauge | Where{$_.name -eq "cpu_utilization"$cpuc = $cpuu.current 
$worku = $gauge | Where{$_.name -eq "msgs_in_work_queue"$workc = $worku.current 
 
 
        Add-Content $report "<tr>"  
        Add-Content $report  "<td width='20%' align='center'><B>Memory Utilization</B></td>" 
        if ([int]$ramuc -le $ramthreshold){ 
                Add-Content $report "<td bgcolor= 'Aquamarine' align=center>  <B>$ramuc</B></td>"} 
               else{ 
               Add-Content $report "<td bgcolor= 'yellow' align=center>  <B>$ramuc</B></td>"} 
        Add-Content $report "</tr>" 
 
        Add-Content $report "<tr>"  
        Add-Content $report  "<td width='20%' align='center'><B>CPU Utilization</B></td>" 
        if ([int]$cpuc -le $cputhreshold){ 
                Add-Content $report "<td bgcolor= 'Aquamarine' align=center>  <B>$cpuc</B></td>"} 
               else{ 
               Add-Content $report "<td bgcolor= 'yellow' align=center>  <B>$cpuc</B></td>"} 
        Add-Content $report "</tr>" 
 
        Add-Content $report "<tr>"  
        Add-Content $report  "<td width='20%' align='center'><B>WorkQueue</B></td>" 
        if ([int]$workc -le $wqueuethreshold){ 
                Add-Content $report "<td bgcolor= 'Aquamarine' align=center>  <B>$workc</B></td>"} 
               else{Add-Content $report "<td bgcolor= 'Orange' align=center>  <B>$workc</B></td>"}     
        Add-Content $report "</tr>"  
 
 
############################################################################################## 
 
Add-content $report  "</table>"  
Add-Content $report "</body>"  
Add-Content $report "</html>" 
 
$subject = "Ironport Status Check Report"  
$body = Get-Content $reportpath 
$smtpNew-Object System.Net.Mail.SmtpClient $smtphost  
$msg = New-Object System.Net.Mail.MailMessage $from$to$subject$body  
$msg.isBodyhtml = $true  
$smtp.send($msg)  
##################################################################################################

Regards

Sukhija Vikas

http://msexchange.me

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s