Add LinkPerformance functions
This commit is contained in:
Родитель
066f0a85ee
Коммит
2ac9f4abd5
|
@ -0,0 +1,348 @@
|
|||
function Get-LinkPerformance {
|
||||
# 1. Evaluate and Set input parameters
|
||||
# 2. Initialize
|
||||
# 3. Clear old run files
|
||||
# 4. Validate iPerf3 connectivity (two ping)Error Stop
|
||||
# 5. Validate PSPing connectivity (two ping)Error Stop
|
||||
# 6. Main Test Loop
|
||||
# 6.1 Start iPerf job if required
|
||||
# 6.2 Start PSPing job
|
||||
# 6.3 Wait for jobs to finish
|
||||
# 7. Parse each job file for data
|
||||
# 7.1 iPerf3 log file line loop
|
||||
# 7.2 PSPing log file line loop
|
||||
# 7.3 Get Percentile values
|
||||
# 7.4 Add results to object array
|
||||
# 8. Output results
|
||||
|
||||
|
||||
# File links
|
||||
# https://live.sysinternals.com/psping.exe
|
||||
# https://iperf.fr/download/windows/iperf-3.1.3-win64.zip
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Run a series of iPerf load tests and PSPing TCP pings concurrently between a local source and a remote host
|
||||
running iPerf3 in server mode. Seven tests of increasing load are performed and results are output at the
|
||||
conclusion of the test.
|
||||
|
||||
.DESCRIPTION
|
||||
Run a series of iPerf load tests and PSPing TCP pings concurrently between a local source and a remote host
|
||||
running iPerf3 in server mode. Seven tests of increasing load are performed and results are output at the
|
||||
conclusion of the test.
|
||||
|
||||
The remote server must be running iPerf3 in server mode; e.g iPerf3 -s
|
||||
|
||||
On the local server from which this function is run, vaious parameters can be used to affect the testing.
|
||||
The output is a combination of both the load test and the latency test while the perf test is running.
|
||||
Each row of output represtents the summation of a given test, the follow test conditions are run:
|
||||
- No load, a PSPing TCP test without iPerf3 running, a pure latency test
|
||||
- 1 Session, a PSPIing TCP test with iPerf3 running a single thread of load
|
||||
- 6 Sessions, a PSPing TCP test with iPerf3 running a six thread load test
|
||||
- 16 Sessions, a PSPing TCP test with iPerf3 running a 16 thread load test
|
||||
- 16 Sessions with 1Mb window, a PSPing TCP test with iPerf3 running a 16 thread load test with a 1Mb window
|
||||
- 32 Sessions, a PSPing TCP test with iPerf3 running a 32 thread load test
|
||||
|
||||
For each test iPerf is kicked off and allowed to run for 10 seconds to establish the load and allow it to level
|
||||
Then PSPing is kicked off to record latency during the load test.
|
||||
Results from each test are stored in a text file in user profile directory ($env:USERPROFILE)
|
||||
|
||||
Output for each test is displayed in a table with the following columns:
|
||||
- Name: The name of the test for these values, eg No load, 1 session, etc
|
||||
- Bandwidth: The average bandwidth achieved by iPerf for the given test
|
||||
- Loss: percentage of packet lost during the PSPing test
|
||||
- P50 Latency: the 50th percentile of latency seen during the test
|
||||
|
||||
If the Verbose option (-Verbose) is used:
|
||||
- P90 Latency: the 90th percentile of latency seen during the test
|
||||
- P95 Latency: the 95th percentile of latency seen during the test
|
||||
- Min Latency: the minumum TCP ping latency seen during the test
|
||||
- Max Latency: the maximum TCP ping latency seen during the test
|
||||
|
||||
.PARAMETER RemoteHost
|
||||
This parameter is required and is the Remote Host IP Address. This host must be running iPerf3 in server mode and
|
||||
be listening on either port 22 (SSH) for Linux hosts or 3389 (RDP) for Windows hosts.
|
||||
|
||||
.PARAMETER HostType
|
||||
This optional parameter signifies the operating system of the REMOTE host. Valid values are "Windows" or "Linux".
|
||||
It is assumed that if the remote host is Linux that port 22 is open for the PSPing, if Windows PSPing will use
|
||||
the RDP port 3389
|
||||
|
||||
.PARAMETER TestSeconds
|
||||
This optional parameter signifies the duration of PSPing test in seconds. It is an integer value (whole number).
|
||||
The range of valid values is 60 - 3600 seconds (1 minute - 1 hour). The default value is 60.
|
||||
|
||||
.EXAMPLE
|
||||
Get-LinkPerformance -RemoteHost 10.0.0.1
|
||||
|
||||
# Get network performance stats from a windows server at 10.0.0.1 for 6 one minute tests (default host type
|
||||
(Windows) and test duration (60 seconds) )
|
||||
|
||||
.EXAMPLE
|
||||
Get-LinkPerformance -RemoteHost 10.0.0.1 -HostType Linux -TestSeconds 3600
|
||||
|
||||
# Get network performance stats from a Linux server at 10.0.0.1 for 6 one-hour tests (3600 seconds)
|
||||
|
||||
.EXAMPLE
|
||||
(Get-AzureVM -ServiceName 'myServiceName' -Name 'myVMName').IpAddress | Get-LinkPerformance
|
||||
|
||||
# Pull VNet IP address from a VM in Azure and pipe it to the Get-AzureNetworkAvailability cmdlet
|
||||
|
||||
.LINK
|
||||
https://github.com/Azure/NetworkMonitoring
|
||||
|
||||
.NOTES
|
||||
This script will run against a remote server that must be running iPerf3 in server mode with firewall ports
|
||||
open to allow iPerf and the approprate PSPing port (22 or 3389). If the remote server is a windows machine
|
||||
an easy way to ensure proper configuration is to install the LinkPerformance tool on that remote machine and
|
||||
then run iPerf3 in server mode (iperf3 -s)
|
||||
More information can be found at https://github.com/Azure/NetworkMonitoring
|
||||
|
||||
#>
|
||||
|
||||
# 1. Evaluate and Set input parameters
|
||||
[cmdletBinding()]
|
||||
Param(
|
||||
[Parameter(ValueFromPipeline=$true,
|
||||
Mandatory=$true,
|
||||
HelpMessage='Enter IP Address of Remote Host')]
|
||||
[ipaddress]$RemoteHost,
|
||||
[ValidateSet(“Windows”,”Linux”)]
|
||||
[string]$RemoteHostOS="Windows",
|
||||
[ValidateRange(10,3600)]
|
||||
[int]$TestSeconds=60,
|
||||
[switch]$DetailedOutput=$false
|
||||
)
|
||||
|
||||
# 2. Initialize
|
||||
$WebSource = "https://github.com/Azure/NetworkMonitoring"
|
||||
#$Verbose = $VerbosePreference -ne [System.Management.Automation.ActionPreference]::SilentlyContinue
|
||||
$FileArray = "P00", "P01", "P06", "P16", "P17", "P32"
|
||||
$PingDuration = $TestSeconds
|
||||
$LoadDuration = $TestSeconds + 10
|
||||
If ($RemoteHostOS="Windows") {$PingPort="3389"} Else {$PingPort="22"}
|
||||
[String]$HostPort = [string]$RemoteHost + ":" + [String]$PingPort
|
||||
|
||||
#$FileArray = "P01"
|
||||
|
||||
# 3. Clear old run files
|
||||
Remove-Job -Name ACT.LinkPerf -Force -ErrorAction SilentlyContinue
|
||||
If (Test-Path "$env:USERPROFILE\TestPing.log"){Remove-Item "$env:USERPROFILE\TestPing.log"}
|
||||
If (Test-Path "$env:USERPROFILE\TestPerf.log"){Remove-Item "$env:USERPROFILE\TestPerf.log"}
|
||||
If (Test-Path "$env:USERPROFILE\P*ping.log"){Remove-Item "$env:USERPROFILE\P*ping.log"}
|
||||
If (Test-Path "$env:USERPROFILE\P*perf.log"){Remove-Item "$env:USERPROFILE\P*perf.log"}
|
||||
|
||||
# 4. Validate iPerf3 connectivity (two ping)Error Stop
|
||||
$FileName=$env:USERPROFILE+"\TestPerf.log"
|
||||
$iPerfJob = Start-Job -ScriptBlock {C:\ACTTools\iperf3.exe -c $args[0] -t 2 -i 0 -P 1 --logfile $args[1]} -Name 'ACT.LinkPerf' -ArgumentList "$RemoteHost", "$FileName"
|
||||
Wait-Job -Name "ACT.LinkPerf" | Out-Null
|
||||
# Line Loop
|
||||
$TPut = "Error"
|
||||
Try {
|
||||
$Lines = Get-Content $FileName -ErrorAction Stop
|
||||
ForEach ($Line in $Lines) {
|
||||
If (($Line -like "*receiver*")) {$TPut = $Line.Substring(38,17).Trim()} # End If
|
||||
} # End For
|
||||
} # End Try
|
||||
Catch {}
|
||||
If ($TPut -eq "Error") {
|
||||
Write-Host
|
||||
Write-Warning "Unable to start iPerf session.
|
||||
|
||||
Things to check:
|
||||
- Ensure iPerf is running in server mode (iperf3 -s) on the remote server at $RemoteHost
|
||||
- Ensure remote iPerf server is listening on the default port 5201
|
||||
- Check host and network firewalls to ensure this port is open on both hosts and any network devices between them
|
||||
- Ensure iPerf files are installed in C:\ACTTools, if not rerun the Install-LinkPerformance.ps1
|
||||
- Ensure remote iPerf version is compatible with local version
|
||||
|
||||
See $WebSource for more information."
|
||||
Return } # End If
|
||||
|
||||
# 5. Validate PSPing connectivity (two ping)Error Stop
|
||||
$FileName=$env:USERPROFILE+"\TestPing.log"
|
||||
$iPerfJob = Start-Job -ScriptBlock {C:\ACTTools\psping.exe -n 2 -4 $args[0] -nobanner > $args[1]} -Name 'ACT.LinkPerf' -ArgumentList "$HostPort", "$FileName"
|
||||
Wait-Job -Name "ACT.LinkPerf" | Out-Null
|
||||
# Line Loop
|
||||
$Loss = "Error"
|
||||
Try {
|
||||
$Lines = Get-Content $FileName -ErrorAction Stop
|
||||
ForEach ($Line in $Lines) {
|
||||
If ($Line -like "*Sent*") {
|
||||
$Loss = $Line.Substring($Line.IndexOf("(",0)+1,$Line.IndexOf(")",0)-$Line.IndexOf("(",0)-1)
|
||||
} # End If
|
||||
} # End For
|
||||
} # End Try
|
||||
Catch {}
|
||||
If ($Loss -eq "100% loss" -or $Loss -eq "Error") {
|
||||
Write-Host
|
||||
Write-Warning "Unable to TCP ping remote machine.
|
||||
|
||||
Things to check:
|
||||
- Ensure $HostPort is listening and reachable from this machine.
|
||||
- Ensure remote OS attribute setting is correct, it's currently set to ""$RemoteHostOS""
|
||||
- Check host and network firewalls to ensure this port is open
|
||||
- Ensure PSPing.exe is installed in C:\ACTTools, if not rerun the Install-LinkPerformance.ps1
|
||||
|
||||
See $WebSource for more information."
|
||||
Return
|
||||
} # End If
|
||||
|
||||
|
||||
# 6. Main Test Loop
|
||||
ForEach ($FilePrefix in $FileArray) {
|
||||
switch($FilePrefix) {
|
||||
"P00" {$Threads = 00; $TestName = "Stage 1 of 6: No Load Ping Test..."}
|
||||
"P01" {$Threads = 01; $TestName = "Stage 2 of 6: Single Thread Test..."}
|
||||
"P06" {$Threads = 06; $TestName = "Stage 3 of 6: 6 Thread Test..."}
|
||||
"P16" {$Threads = 16; $TestName = "Stage 4 of 6: 16 Thread Test..."}
|
||||
"P17" {$Threads = 16; $TestName = "Stage 5 of 6: 16 Thread Test with 1Mb window..."}
|
||||
"P32" {$Threads = 32; $TestName = "Stage 6 of 6: 32 Thread Test..."}
|
||||
default {Write-Error "Invalid FilePrefix, execution stopping!"; Return}
|
||||
} # End Switch
|
||||
|
||||
# Decalare Test Starting
|
||||
Write-Host (Get-Date)' - ' -NoNewline
|
||||
Write-Host $TestName -ForegroundColor Cyan
|
||||
|
||||
# 6.1 Start iPerf job if required
|
||||
$FileName=$env:USERPROFILE+"\"+$FilePrefix+"perf.log"
|
||||
Switch($FilePrefix) {
|
||||
"P00" {}
|
||||
"P17" {
|
||||
$iPerfJob = Start-Job -ScriptBlock {C:\ACTTools\iperf3.exe -c $args[0] -t $args[1] -i 0 -P $args[2] -w1M --logfile $args[3]} -Name 'ACT.LinkPerf' -ArgumentList "$RemoteHost", "$LoadDuration", "$Threads", "$FileName"
|
||||
Sleep -Seconds 5}
|
||||
default {
|
||||
$iPerfJob = Start-Job -ScriptBlock {C:\ACTTools\iperf3.exe -c $args[0] -t $args[1] -i 0 -P $args[2] --logfile $args[3]} -Name 'ACT.LinkPerf' -ArgumentList "$RemoteHost", "$LoadDuration", "$Threads", "$FileName"
|
||||
Sleep -Seconds 5}
|
||||
} # End Switch
|
||||
|
||||
# 6.2 Start PSPing job
|
||||
$FileName=$env:USERPROFILE+"\"+$FilePrefix+"ping.log"
|
||||
[string]$StringDuration = $PingDuration.ToString() + "s"
|
||||
$iPerfJob = Start-Job -ScriptBlock {C:\ACTTools\psping.exe -n $args[0] -4 $args[1] -nobanner > $args[2]} -Name 'ACT.LinkPerf' -ArgumentList "$StringDuration", "$HostPort", "$FileName"
|
||||
|
||||
# 6.3 Wait for jobs to finish
|
||||
If ($FilePrefix -eq "P00") {$time = $PingDuration + 2}
|
||||
Else {$time = $LoadDuration + 1} # End If
|
||||
foreach($i in (1..$time)) {
|
||||
$percentage = $i / $time
|
||||
$remaining = New-TimeSpan -Seconds ($time - $i)
|
||||
$message = "{0:p0} complete, remaining time {1}" -f $percentage, $remaining
|
||||
Write-Progress -Activity $message -PercentComplete ($percentage * 100) -CurrentOperation $TestName
|
||||
Start-Sleep 1
|
||||
} # End Foreach
|
||||
While ((Get-Job -Name 'ACT.LinkPerf' -ErrorAction SilentlyContinue | Where State -eq 'Running').Count -gt 0) {
|
||||
Write-Verbose "Waiting for job threads to finish..."
|
||||
Sleep 2
|
||||
} # End While
|
||||
} # End For
|
||||
|
||||
Write-Host "All Done!" -ForegroundColor Cyan
|
||||
Write-Verbose "All Done!"
|
||||
|
||||
# 7. Parse each job file for data
|
||||
$TestResults=@()
|
||||
# File Loop
|
||||
ForEach ($FilePrefix in $FileArray) {
|
||||
switch($FilePrefix) {
|
||||
"P00" {$TestName = "No Load"}
|
||||
"P01" {$TestName = "1 Session"}
|
||||
"P06" {$TestName = "6 Sessions"}
|
||||
"P16" {$TestName = "16 Sessions"}
|
||||
"P17" {$TestName = "16 Sessions with 1Mb window"}
|
||||
"P32" {$TestName = "32 Sessions"}
|
||||
default {}
|
||||
} # End Switch
|
||||
|
||||
# 7.1 iPerf3 log file line loop
|
||||
$FileName = $env:USERPROFILE + "\" + $FilePrefix + "perf.log"
|
||||
$TPut = "Error"
|
||||
If ($FilePrefix -eq "P00") {
|
||||
$TPut = "N/A"}
|
||||
Else {
|
||||
Try {
|
||||
$Lines = Get-Content $FileName -ErrorAction Stop
|
||||
ForEach ($Line in $Lines) {
|
||||
If ($FilePrefix -eq "P01") {If (($Line -like "*receiver*")) {$TPut = $Line.Substring(38,17).Trim()} #End If
|
||||
}
|
||||
Else {
|
||||
If (($Line -like "*SUM*" -and $Line -like "*receiver*")) {$TPut = $Line.Substring(38,17).Trim()} #End If
|
||||
} # End Else
|
||||
} # End For
|
||||
} # End Try
|
||||
Catch {Write-Warning "Error reading or processing file: $FileName"}
|
||||
} # End If
|
||||
|
||||
|
||||
# 7.2 PSPing log file line loop
|
||||
$FileName = $env:USERPROFILE + "\" + $FilePrefix + "ping.log"
|
||||
$PingArray = New-Object System.Collections.Generic.List[System.Object]
|
||||
$PingLoss = "Error"
|
||||
$PingSent = "Error"
|
||||
$PingP50 = "Error"
|
||||
$PingP90 = "Error"
|
||||
$PingP95 = "Error"
|
||||
$PingMin = "Error"
|
||||
$PingMax = "Error"
|
||||
$PingAvg = "Error"
|
||||
Try {
|
||||
$Lines = Get-Content $FileName -ErrorAction Stop
|
||||
ForEach ($Line in $Lines) {
|
||||
If ($Line.Contains("Connecting")) {
|
||||
$Step1 = (($Line -split ':')[4])
|
||||
$Step2 = $Step1.Trim()
|
||||
[Decimal]$Step3 = $Step2.TrimEnd("ms")
|
||||
$PingArray.Add($Step3)
|
||||
} # EndIf
|
||||
If ($Line -like "*Sent*") {
|
||||
$PingSent = $Line.Substring($Line.IndexOf("=", $Line.IndexOf("Sent",0))+2, $Line.IndexOf(",", $Line.IndexOf("Sent",0))-$Line.IndexOf("=", $Line.IndexOf("Sent",0))-2)
|
||||
$PingLoss = $Line.Substring($Line.IndexOf("(",0)+1,$Line.IndexOf(")",0)-$Line.IndexOf("(",0)-1)
|
||||
} # End If
|
||||
If ($Line -like "*Minimum*") {
|
||||
$PingMin = $Line.Substring($Line.IndexOf("=", $Line.IndexOf("Minimum",0))+2, $Line.IndexOf(",", $Line.IndexOf("Minimum",0))-$Line.IndexOf("=", $Line.IndexOf("Minimum",0))-2)
|
||||
$PingMax = $Line.Substring($Line.IndexOf("=", $Line.IndexOf("Maximum",0))+2, $Line.IndexOf(",", $Line.IndexOf("Maximum",0))-$Line.IndexOf("=", $Line.IndexOf("Maximum",0))-2)
|
||||
$PingAvg = $Line.Substring($Line.IndexOf("=", $Line.IndexOf("Average",0))+2)
|
||||
} # End If
|
||||
} # End For
|
||||
} # End Try
|
||||
Catch {Write-Warning "Error reading or processing file: $FileName"}
|
||||
|
||||
# 7.3 Get Percentile values
|
||||
# Remove the warm up ping and sort the arrary
|
||||
$PingArray.RemoveAt(0)
|
||||
$SortedArrary = $PingArray | Sort-Object
|
||||
# http://www.dummies.com/education/math/statistics/how-to-calculate-percentiles-in-statistics/
|
||||
# Pick 50th Percentile
|
||||
If ($SortedArrary.count%.5) {$PingP50 = $SortedArrary[[math]::Ceiling($SortedArrary.count*.5)-1]}
|
||||
Else {$PingP50 = ($SortedArrary[$SortedArrary.Count*.5] + $SortedArrary[$SortedArrary.count*.5-1])/2}
|
||||
# Pick 90th Percentile
|
||||
If ($SortedArrary.count%.9) {$PingP90 = $SortedArrary[[math]::Ceiling($SortedArrary.count*.9)-1]}
|
||||
Else {$PingP90 = ($SortedArrary[$SortedArrary.Count*.9] + $SortedArrary[$SortedArrary.count*.9-1])/2}
|
||||
# Pick 95th Percentile
|
||||
If ($SortedArrary.count%.95) {$PingP95 = $SortedArrary[[math]::Ceiling($SortedArrary.count*.95)-1]}
|
||||
Else {$PingP95 = ($SortedArrary[$SortedArrary.Count*.95] + $SortedArrary[$SortedArrary.count*.95-1])/2}
|
||||
|
||||
# 7.4 Add results to object array
|
||||
$Test = New-Object -TypeName PSObject
|
||||
$Test | Add-Member -Name 'Name' -MemberType NoteProperty -Value $TestName
|
||||
$Test | Add-Member -Name 'Bandwidth' -MemberType NoteProperty -Value $TPut
|
||||
$Test | Add-Member -Name 'Count' -MemberType NoteProperty -Value $PingSent
|
||||
$Test | Add-Member -Name 'Loss' -MemberType NoteProperty -Value $PingLoss
|
||||
$Test | Add-Member -Name 'P50' -MemberType NoteProperty -Value $PingP50'ms'
|
||||
$Test | Add-Member -Name 'P90' -MemberType NoteProperty -Value $PingP90'ms'
|
||||
$Test | Add-Member -Name 'P95' -MemberType NoteProperty -Value $PingP95'ms'
|
||||
$Test | Add-Member -Name 'Avg' -MemberType NoteProperty -Value $PingAvg
|
||||
$Test | Add-Member -Name 'Min' -MemberType NoteProperty -Value $PingMin
|
||||
$Test | Add-Member -Name 'Max' -MemberType NoteProperty -Value $PingMax
|
||||
|
||||
$TestResults += $Test
|
||||
} # End Foreach
|
||||
|
||||
# 8. Output results
|
||||
If ($DetailedOutput) {Write-Output $TestResults | ft}
|
||||
Else {Write-Output $TestResults | Select Name, Bandwidth, Loss, P50 | ft}
|
||||
|
||||
} # End Function
|
||||
|
||||
Get-LinkPerformance -RemoteHost 127.0.0.1 -TestSeconds 10 -DetailedOutput -Verbose
|
|
@ -0,0 +1,154 @@
|
|||
function Install-LinkPerformance{
|
||||
# 1. Warning check
|
||||
# 2. Initialize
|
||||
# 3. Create C:\ACTTools dir
|
||||
# 4. Check for iPerf files
|
||||
# 4.1 If either are needed, download, extract
|
||||
# 5. Check for PSPing
|
||||
# 5.1 If needed, download
|
||||
# 6. Check other files
|
||||
# 7. Pull from GitHub if needed
|
||||
# 8. Kill PSPing popup
|
||||
# 9. Open Firewall rules
|
||||
|
||||
Param([switch]$Force=$false)
|
||||
|
||||
# 1. Warning check
|
||||
If (-not $Force) {
|
||||
Write-Host
|
||||
Write-Host " " -BackgroundColor Black
|
||||
Write-Host " *************************** " -ForegroundColor Red -BackgroundColor Black
|
||||
Write-Host " *** *** " -ForegroundColor Red -BackgroundColor Black
|
||||
Write-Host " ***" -ForegroundColor Red -BackgroundColor Black -NoNewline
|
||||
Write-Host " !!!Warning!!! " -ForegroundColor Yellow -BackgroundColor Black -NoNewline
|
||||
Write-host "*** " -ForegroundColor Red -BackgroundColor Black
|
||||
Write-Host " *** *** " -ForegroundColor Red -BackgroundColor Black
|
||||
Write-Host " *************************** " -ForegroundColor Red -BackgroundColor Black
|
||||
Write-Host " " -BackgroundColor Black
|
||||
Write-Host
|
||||
Write-Host " This script will install 3rd party products: iPerf3 and PSPing" -ForegroundColor Cyan
|
||||
Write-Host " As well as open firewall port 5201 and allow ICMPv4" -ForegroundColor Cyan
|
||||
Write-Host
|
||||
$foo = Read-Host -Prompt "Are you sure you wish to continue? [y]"
|
||||
If ($foo -ne "y" -and $foo -ne "") {Return}
|
||||
|
||||
} # End If
|
||||
|
||||
|
||||
# 2. Initialize
|
||||
$ToolPath = "C:\ACTTools\"
|
||||
|
||||
# 3. Create C:\ACTTools dir
|
||||
If (-Not (Test-Path $ToolPath)){New-Item -ItemType Directory -Force -Path $ToolPath | Out-Null}
|
||||
|
||||
|
||||
# 4. Check for iPerf files
|
||||
# Yes I know I should make the file pull (and other things) a callable function, but lazy is ok sometimes
|
||||
If (-Not (Test-Path $ToolPath"iperf3.exe") -or -Not (Test-Path $ToolPath"cygwin1.dll")){
|
||||
# 4.1 If either are needed, download, extract
|
||||
$File = $ToolPath + "iperf-3.1.3-win64.zip"
|
||||
Try {
|
||||
$webClient = new-object System.Net.WebClient
|
||||
$webClient.DownloadFile('https://iperf.fr/download/windows/iperf-3.1.3-win64.zip', $File)
|
||||
}
|
||||
Catch {
|
||||
Write-Host
|
||||
Write-Warning "Something bad happened with the iPerf download. Most likely either files are missing at the source or this host doesn't have internet access."
|
||||
Write-Host
|
||||
Write-Host "You can manually add the files and rerun this Install script."
|
||||
Write-Host "To manually install iPerf3:"
|
||||
Write-Host " 1. Download files from https://iperf.fr/download/windows/iperf-3.1.3-win64.zip"
|
||||
Write-Host " 2. Extract zipped files (iPerf3.exe and cygwin1.dll) to $ToolPath"
|
||||
Write-Host " 3. With those files in place, rerun this install script."
|
||||
Write-Host
|
||||
Return
|
||||
} # End Try
|
||||
|
||||
Try {
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($File, $ToolPath)
|
||||
move-item -path ($ToolPath + "iperf-3.1.3-win64\*.*") -destination $ToolPath -Force
|
||||
Remove-Item -Path ($ToolPath + "iperf-3.1.3-win64\") -Force
|
||||
Remove-Item -Path $File -Force
|
||||
}
|
||||
Catch {
|
||||
Write-Host
|
||||
Write-Warning "Something bad happened Unzipping and moving the iPerf files. Most likely .Net or other required subsystem files are not loaded."
|
||||
Write-Host
|
||||
Write-Host "You can manually add the files and rerun this Install script."
|
||||
Write-Host "To manually install iPerf3:"
|
||||
Write-Host " 1. Find $File"
|
||||
Write-Host " 2. Extract zipped files (iPerf3.exe and cygwin1.dll) to $ToolPath (not a subdirectory!)"
|
||||
Write-Host " 3. With those files in place, rerun this install script."
|
||||
Write-Host
|
||||
Return
|
||||
} # End Try
|
||||
|
||||
} # End If
|
||||
|
||||
|
||||
# 5. Check for PSPing
|
||||
If (-Not (Test-Path $ToolPath"psping.exe")){
|
||||
# 5.1 If needed, download
|
||||
$File = $ToolPath + "psping.exe"
|
||||
Try {
|
||||
$webClient = new-object System.Net.WebClient
|
||||
$webClient.DownloadFile('https://live.sysinternals.com/psping.exe', $File)
|
||||
}
|
||||
Catch {
|
||||
Write-Host
|
||||
Write-Warning "Something bad happened with the PSPing download. Most likely either files are missing at the source or this host doesn't have internet access."
|
||||
Write-Host
|
||||
Write-Host "You can manually add the file and rerun this Install script."
|
||||
Write-Host "To manually install PSPing:"
|
||||
Write-Host " 1. Download the file from https://live.sysinternals.com/psping.exe"
|
||||
Write-Host " 2. Move the psping.exe file to the $ToolPath directory."
|
||||
Write-Host " 3. With psping.exe in place, rerun this install script."
|
||||
Write-Host
|
||||
Return
|
||||
} # End Try
|
||||
} # End If
|
||||
|
||||
# 6. Check other files
|
||||
# Do I need to download the Install and Get .ps1 files if they are installed in the module?
|
||||
$FileName = @()
|
||||
If (-Not (Test-Path ($ToolPath + "Install-LinkPerformance.ps1"))){$FileName += 'Install-LinkPerformance.ps1'}
|
||||
If (-Not (Test-Path ($ToolPath + "Get-LinkPerformance.ps1"))){$FileName += 'Get-LinkPerformance.ps1'}
|
||||
If (-Not (Test-Path ($ToolPath + "Set-iPerfFirewallRules.ps1"))){$FileName += 'Set-iPerfFirewallRules.ps1'}
|
||||
If (-Not (Test-Path ($ToolPath + "README.md"))){$FileName += 'README.md'}
|
||||
|
||||
# 7. Pull from GitHub if needed
|
||||
If ($FileName.Count -gt 0) {
|
||||
Try {
|
||||
$uri = 'https://raw.githubusercontent.com/tracsman/1DayLab/DontLook/PerfTest/'
|
||||
ForEach ($File in $FileName) {
|
||||
$webClient = new-object System.Net.WebClient
|
||||
$webClient.DownloadFile( $uri + $File, $ToolPath + $File )
|
||||
} #End ForEach
|
||||
}
|
||||
Catch {
|
||||
Write-Host
|
||||
Write-Warning "Something bad happened pulling files from GitHub. Most likely either files are missing at the source or this host doesn't have internet access."
|
||||
Write-Host
|
||||
Write-Host "You can manually add the four files and rerun this Install script."
|
||||
Write-Host "To manually install the files:"
|
||||
Write-Host " 1. Go to https://github.com/tracsman/1DayLab/tree/DontLook/PerfTest"
|
||||
Write-Host " 2. Download the files in that directory to the local $ToolPath directory."
|
||||
Write-Host " 3. With these files in place, rerun this install script."
|
||||
Write-Host
|
||||
Return
|
||||
} # End Try
|
||||
} # End If
|
||||
|
||||
# 8. Kill PSPing popup
|
||||
$cmd = $ToolPath + "psping.exe -accepteula | Out-Null"
|
||||
Invoke-Expression -Command $cmd
|
||||
|
||||
# 9. Open Firewall rules
|
||||
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
|
||||
{Start-Process powershell -Verb runAs -ArgumentList ($ToolPath + "Set-iPerfFirewallRules.ps1")}
|
||||
Else {Invoke-Expression -Command ($ToolPath + "Set-iPerfFirewallRules.ps1")}
|
||||
|
||||
} # End Function
|
||||
|
||||
Install-LinkPerformance -Force
|
|
@ -0,0 +1,3 @@
|
|||
# README File for the LinkPerformance functions
|
||||
|
||||
Description goes here
|
|
@ -0,0 +1,9 @@
|
|||
# Must be run as admin
|
||||
|
||||
# Turn On ICMPv4
|
||||
Try {Get-NetFirewallRule -Name Allow_ICMPv4_in -ErrorAction Stop | Out-Null}
|
||||
Catch {New-NetFirewallRule -DisplayName "Allow ICMPv4" -Name Allow_ICMPv4_in -Action Allow -Enabled True -Profile Any -Protocol ICMPv4 | Out-Null}
|
||||
|
||||
# Turn On iPerf3
|
||||
Try {Get-NetFirewallRule -Name Allow_iPerf3_in -ErrorAction Stop | Out-Null}
|
||||
Catch {New-NetFirewallRule -DisplayName "Allow iPerf3" -Name Allow_iPerf3_in -Action Allow -Enabled True -Profile Any -Protocol TCP -LocalPort 5201 | Out-Null}
|
Загрузка…
Ссылка в новой задаче