Wednesday, September 10, 2014

Capture ping Latency or drops results with powershell - Part1


Powershell Ping multiple IP addresses
Capture ping Latency or drops results with powershell - Part1
Capture multiple IP Latency or drops results with powershell Test-Connection - Part 2
Schedule PowerShell (.PS1 file) script in Windows Task Scheduler - Part 3
 
Many times users reported me that they are facing slowness and lagging on the terminal servers, after analysis I didn't find any issue with CPU or Memory but sometimes Network slowness. Network is fluctuating and latency in MS has been increased. (This help when opening case with ISP vendor or contacting network team.)

To know at what time this is happening I use this script to capture the time when Latency increased above the bench-marked one. It will also store if drops has been increased.

Once you run this script, it will ask for IPaddress or ComputerName. On the second line When should it captures the ping results (if latency increases equal or more than 80, it will keep storing data in CSV file). And on the final line the path for csv file to store data.

In this Powershell script i have used Ping tool to capture in my next post I will capture same data using other Powershell command.
 ######################################################################  
 $computername = Read-Host "Ipaddress or Computername"  
 $LatencytoMonitor = Read-Host "Latency to monitor"  
 #$filename = "C:\temp\PingResult-$computername.csv"  
 $filename = Read-Host "Type path ie C:\temp\ComputerNamePingResult.csv"  
 ######################################################################  
 $x = $true  
 do  
 {  
   $Ping = Ping -n 1 $computername | Select-String -Pattern "Request", "Reply from"  
   $Pingstatus = $Ping[0]  
   $IP = $($Pingstatus -split("reply from ") -split (":"))[1]  
   if ($Pingstatus -match "Request timed out") {  
     #$Pingstatus  
     $TestResult = "" | Select-Object IPAddress, Latencyms, DateTime  
     $TestResult.IpAddress = $computername  
     $TestResult.Latencyms = "NotReachable"  
     $TestResult.DateTime = Get-Date  
     $TestResult | Export-Csv -Path $filename -Append -NoTypeInformation  
   }    
   elseif ($PingStatus -match "Reply from $IP") {  
     if (-not (Get-Variable Latencyms)) {  
       Remove-Variable -Name Latencyms -Force  
     }  
     $Latencyms = $Pingstatus -split ("time")  
     $Latencyms = $Latencyms[1].Substring(1)  
     $Latencyms = $Latencyms.Split("ms")[0]  
     if ([Int]$Latencyms -ge $LatencytoMonitor) {  
       #$Pingstatus  
       $TestResult = "" | Select-Object IPAddress, Latencyms, DateTime  
       $TestResult.IPAddress = $computername  
       $TestResult.Latencyms = $Latencyms  
       $TestResult.DateTime = Get-Date  
       $TestResult | Export-Csv -Path $filename -Append -NoTypeInformation  
     }  
       <#else {  
         "DO nothing"  
       }#>  
   }  
   else {  
     #$Pingstatus  
     $TestResult = "" | Select-Object IPAddress, Latencyms, DateTime  
     $TestResult.IPAddress = $computername  
     $TestResult.Latencyms = "GenericFailure"  
     $TestResult.DateTime = Get-Date  
     $TestResult | Export-Csv -Path $filename -Append -NoTypeInformation  
   }  
 }  
 while ($x -eq $true)  
 ###############################################################################  
 #Please test it at your own risk.  
 http://kunaludapi.blogspot.com   
 Keywords: capture ping request timed out and high latency

2 comments:

LifeVoxel.AI said...

LifeVoxel.AI has developed a Interactive Streaming and AI Platform for medical imaging using GPU clusters cloud computing. It is a leap in cloud technology platform in medical imaging that encompasses use cases in visualization, AI, image management and workflow. It’s approach is unique that it has been granted 12 International patents. LifeVoxel.AI’s platform is certified for HIPAA compliancy. LifeVoxel’s cloud addresses the Internet limitations of bandwidth, latency and scalability which are pivotal in this respect. The platform was granted an FDA 510K approval for use in diagnostic interpretation of medical images.

LifeVoxel.AI Interactive Streaming AI Platform RIS PACS server Medical Imaging

LifeVoxel.AI said...

LifeVoxel.AI platform offers a better alternative for the medical imaging community. Its unique approach is based on 14 international patents that encompass critical patient-centric delivery of care using intuitive, diagnostic and instantly accessible visualizations over the Internet. It works 100X faster and its cheaper by 50%+ than other service providers. We are so honored to be selected by Plug-and-Play from over 120 companies to become the Alliance For Covid-19 (AFC-19) company of choice when it comes to diagnostic imaging software. Our remote 4D and AI inherent capabilities of our patented cloud platform that replaces antiquated on-premises medical imaging systems has made us achieve this important feat.

RIS PACS
RIS PACS Software