我可以测量另外两台计算机之间的 PING 时间吗?

我可以测量另外两台计算机之间的 PING 时间吗?

我正在现场调查性能问题。通常情况下,带宽不足以让我的应用快速运行。通常情况下,我会请求终端(通过 VNC 或 WebEx)进入用户的机器,然后打开命令窗口并运行 PING 到服务器以查看延迟。

这个过程非常耗时(例如,有时人们甚至不在他们的办公桌旁,等等...)。

有没有一种方法可以让我无需用户参与即可从用户的机器远程运行 PING 到服务器?

或者有更好的选择吗?

答案1

我曾经使用过一个程序,叫做Desktop Central 免费。它允许您连接到远程计算机的命令提示符并运行您想要的任何内容。只要机器处于启动状态,此工具就可以提供很大帮助。它还有许多其他选项/工具,您可以从远程计算机执行这些操作,而无需其他用户输入。

答案2

如果用户的机器有一个公共 IP 地址(不在 NAT 后面),您可以从服务器 ping 他们的机器。

答案3

我更喜欢 PowerShell 的 Test-Connection

Test-Connection computerperformance.co.uk 

Source        Destination     IPV4Address      Bytes    Time(ms) 
------        -----------     -----------      -----    -------- 
WIN7          computerperf... 72.26.108.9      32       148      
WIN7          computerperf... 72.26.108.9      32       149      
WIN7          computerperf... 72.26.108.9      32       149      
WIN7          computerperf... 72.26.108.9      32       149    

当然,您可以使用 ComputerName 而不是网站。我建议使用这个解决方案,因为它提供了时间,因此可以测量延迟。

答案4

不确定 OP 是否得到了答复,因此在寻找相同答案失败后,我将提交我所开发的内容。

我使用两种不同的方法来测试 Exchange 服务器和将在 New-MailboxExportRequest -FilePath 参数中指定的服务器之间的连接。

#invoke-command (test-connection)
function Get-TestConnectionResponseTime
{
#returns a hash of min, max, avg ping times
param($Pingee,$Pinger)
$TCScript="
    `$result = Test-Connection $Pingee
    `$min=(`$result|Measure-Object -Minimum -Property responsetime).Minimum
    `$max=(`$result|Measure-Object -Maximum -Property responsetime).Maximum
    `$avg=(`$result|Measure-Object -Average -Property responsetime).Average
    @{Min=`$min;Max=`$max;Avg=`$avg}
    "

$CxtScript = $ExecutionContext.InvokeCommand.NewScriptBlock($TCScript)
try{
    Invoke-Command -ComputerName $Pinger -ScriptBlock $CxtScript -ErrorAction Stop}
catch [System.Management.Automation.RuntimeException]{
    return "Probably a firewall restriction: " + $error[0].FullyQualifiedErrorId}
catch{
    return "From catch-all error trap: " + $error[0].FullyQualifiedErrorId}
}

#start-process (psexec -> ping)
function Get-PingResponseTime
{
#uses start-process to run ping from remote to remote, returns a hash of min, max, avg ping times

# this one is slow and clunky, but psexec is allowed though some of the firewalls I contend with, 
# and invoke-command isn't. To collect the output in the script, I had to write it to a log and 
# pick it up afterwards (by watching for the last line of the output to appear in the log file)

param($Pingee,$Pinger)
$argumentlist = "$Pinger ping $Pingee"
$timestamp = Get-Date
$psexecID = Start-Process -FilePath psexec -ArgumentList ("\\" + $argumentlist) -NoNewWindow -RedirectStandardOutput \\MyComputer\c$\temp\pinglog.txt -PassThru #-Wait
Write-Host "Started process" $psexecID.Name
#wait for the remote process to finish
While(Get-Process -ComputerName $Pinger | ?{$_.Name -eq $psexecID.Name}){
    Write-Host "." -NoNewline 
    }
#wait for the completed log file on my local system
Write-Host "Waiting for $pinger to return results..."
while(!((Get-Content C:\temp\pinglog.txt) -match "Average = ")){
    Write-Host "." -NoNewline
    Start-Sleep -Seconds 1
    }
Write-Host " ah, there they are!"
#parse the ping output
$pingtimes = ((Get-Content C:\temp\pinglog.txt) -match "Average = ").trim() -split ", " | %{($_ -split " = ")[1].trim("ms")}
return @{Min=$pingtimes[0];Max=$pingtimes[1];Avg=$pingtimes[2]}
}

希望这对某人有帮助。

相关内容