ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

Ping with latency alarm?

(1/2) > >>

timmy2:
I am looking for a program that can ping an address every 2 seconds and play a sound when the return time exceeds a certain value. It needs to display a timestamp and return time for every ping so I can capture this output to a text file, which I'll then import into Excel.

IainB:
The simplest way to do this might be to write/use a PowerShell script.
You could set the alarm value as a variable for testing with an IF statement, or just dump all the pin responses into (say) an Excel spreadsheet or Access database for analysis.
Refer for example: https://www.checkyourlogs.net/ping-sweep-using-powershell-quick-and-dirty-powershell-mvphour/

mouser:
Seems like a good idea for a coding snack.

4wd:
Someone will come up with something fancier but it gave me something to do  :)

It's only requirement is PowerShell 7 or higher, (I no longer use earlier versions).

Doesn't write to console, just directly to the output file.


--- Code: PowerShell ---<#  pinger.ps1   Run: pwsh -F path\to\pinger.ps1#> $ip = "8.8.8.8"       # IP/site to ping$file = "R:\ping.csv" # Output file, (will be output as CSV)$maxlag = 40          # Latency above which to go beep # If it ain't PowerShell 7+ we don't want to know about it.if ($PSVersionTable.PSVersion.Major -lt 7) {  "Requires PowerShell 7" | Out-Host  Start-Sleep 10} else {  While ($true) {  # Loop-de-loop    # Ping a site once and select latency    $lag = (Test-Connection -ComputerName $ip -Count 1 -Ping -IPv4 -DontFragment | Select-Object Latency)    # Format file output and append latest to file (date time,ip,latency,exceeds max)    "$(Get-Date -Format 'yyyy/MM/dd HH:mm:ss'),$($ip),$($lag.Latency),$($lag.Latency -gt $maxlag)" | Out-File $file -Append    # If latency is above maximum allowed value ...    if ($lag.Latency -gt $maxlag) {      # Go beep      [console]::beep(1000,500)    }    # Sleep, restful sleep ... for all of 2 seconds >:|    Start-Sleep -Seconds 2  }}

File output is in CSV format:

--- Code: Text ---2021/05/17 22:22:35,8.8.8.8,6,False2021/05/17 22:22:37,8.8.8.8,17,False2021/05/17 22:22:39,8.8.8.8,41,True2021/05/17 22:22:42,8.8.8.8,32,False2021/05/17 22:22:44,8.8.8.8,32,False2021/05/17 22:22:46,8.8.8.8,41,True2021/05/17 22:22:48,8.8.8.8,33,False2021/05/17 22:22:51,8.8.8.8,44,True2021/05/17 22:22:53,8.8.8.8,43,True

GrumpyCoder:
I didn't realize how old this thread is before I started working on a solution. In any case, it's already done, so here it is anyway.
I believe this should do what you wanted, but do note that I whipped it up in a couple of hours, so it's definitely not perfect.
PS: The "csv" file is saved right next to the executable.

Ping with latency alarm?

Navigation

[0] Message Index

[#] Next page

Go to full version