How to Log Continuous Ping Results to a Text File

When it comes to troubleshooting a network or internet connection there are several possible ways to do it. One of the simplest is to use the built-in Windows Ping utility to ping another computer because it can quickly help determine if there is a connection between the host and a remote computer. Not only can the Ping command help you identify local network issues, but it can also be used to test the uptime of a remote IP address, server or website.

Ping does the job it's designed for and is run from the command line or batch scripts, so you have to supply a few arguments to tailor it to your needs. Although it's powerful enough for most uses, one option missing from the Ping tool is the ability to include a time and date so you can see the exact point in time the ping response was received. That's useful if you want to continuously ping over a period of time.

Windows ping 1

In addition to a timestamp, it's also useful to be able to continuously ping for reliability over a period of time and optionally send the results to a text file for logging purposes. Here we show you 7 ways to timestamp pings as well as sending a continuous set of ping results to a text file. Make sure to run Command Prompt or batch files as Administrator to avoid issues as some tools require it.

1. hrPing

hrPing is by cFos Software who also develop the cFosSpeed internet accelerator application. The hrPing tool itself is one of the most advanced of its type and allows you to configure just about anything you want with regards to what you ping, how often you ping it and when. There are around 40 different command line arguments available so reading the documentation is recommended for more advanced usage.

Luckily you only need a few of the available arguments to ping with a timestamp and optionally send the results to a text file. Use -t to loop the ping until you manually stop it, -T adds the time and date stamp while -F [filename] allows saving the output to a text file (include -q to output only to file).

hrping -t -T -F D:\pingtest.txt raymond.cc

Hrping graph

To ping a specific number of times instead of continuously, substitute -t for -n [number]. Also, you can use -s [milliseconds] to reduce the ping frequency from half a second to something a bit slower. An additional argument of -gg will open a separate window with a small graph of ping response times (pictured above), useful if you have a particular interest in the speed of the ping responses.

Download hrPING


2. PingWiz

For ease of use, it doesn't get much simpler than PingWiz because it's like a cut-down version of the Windows ping command that timestamps each ping request automatically without additional arguments.

Simply use pingwiz [hostname] and it will add the time and date with pinging the host four times. Adding /t will loop the pings continuously until you press Ctrl+C or /n:[number] will ping the specified number of times. A manual redirection to an output file is required if you want to send the ping results to a log file.

pingwiz raymond.cc /t >C:\pingtest.txt

Pingwiz 1

There are only two other commands available in PingWiz in addition to those above, the ping timeout in seconds (/w) and the number of bytes to send (/b). Unlike hrPING, this tool will not show ping results in the console window and redirect to a file at the same time.

Download PingWiz


3. PingInfoView

PingInfoView by Nirsoft is a little different to the other tools because it works from a graphical user interface. This makes it easy to spot ping errors more quickly if you are actively monitoring and watching for issues because they will show up in the user interface as red entries. PingInfoView does have some command line options but they are to control ping rates and file saving in the user interface.

Pinginfoview 1

On launch, PingInfoView will popup a window where you can add one or a number of addresses to monitor, the ping timeout and the repeat rate (default is to ping every 5 seconds). Press OK and the main window will appear. The upper pane is the monitored hosts list with statistics about the ping results like success/fail rates, min/max/average times and succeed/fail times.

Click on a host in the upper pane to show the individual time stamped ping results at the bottom as they come in. When you have finished monitoring press the Stop button on the toolbar. The lower pane results can be saved to a text file, click on any entry and press Ctrl+A to highlight everything, right click and choose "Save Selected Items", then save as a tabbed text, delimited text or HTML file.

Download PingInfoView


4. PowerPing

PowerPing is an open source tool hosted on GitHub. What sets this tool apart from other command line programs is there's a splash of color in the ping results so you can more easily spot successes and failures. There are also around 40 commands available to control the pinging process and perform a few extra functions.

Typing PowerPing and using just the hostname will perform a standard five pings, including –t will make it continuous. The all important timestamp option is added with –ts which will put the time at the end of the line. There is no date in PowerPing's timestamp so you may have to try another tool if that is something you need. To adjust the ping interval, use –in [milliseconds].

PowerPing –t –ts –in 2000 raymond.cc

Powerping

If you want a more visual display, PowerPing has a graph option (–g) that will show in the console window instead of the text. There's also a few general network features such as getting the location for an address, a whois lookup for an address and a whoami for the current host. You can also turn the colors off or enable a beep for timeouts. To send the output to a file, use the standard redirection method of >filename.

Download PowerPing


5. Bping

By default, Bping will give an audible beep or play a custom WAV file every time it pings and receives a reply. However, this option can be changed so Bping only beeps on a failure. If the Bping output is being redirected to a file, it can be left to beep or you can turn it off. It can also scan for and show other computers on the network with the option to show freely available IP addresses.

To add a timestamp to the command use the -u argument, -q will completely disable the beep if you find it annoying. Pinging will be continuous by default unless you use -n=number. Bping will ping Google DNS (8.8.8.8) if you don't supply an address or hostname. As there is no command to output to file, redirect the results using >filename or >>filename to append to an existing file.

bping raymond.cc -u -q >C:\pingtest.text

Bping 1

Some other useful commands are -d which will only beep if the ping fails, -s which will scan the local network for devices, -a will show all available addresses on the network, and -c will add a count number to each ping. If you don't use the number option the Bping command will have to be exited from the command line with Ctrl+C because it will continuously ping until you exit the program.

Download Bping


6. Windows Ping Command

Although the Windows Ping command has no built-in function to date and timestamp the result of each ping, with a bit of effort you can get it to do that. It's quite useful if you specifically need to use the Windows Ping command. The following was found on StackOverflow and looks complicated but seems to work quite well.

ping -t raymond.cc|cmd /q /v /c "(pause&pause)>nul & for /l %a in () do (set /p "data=" && echo(!date! !time! !data!)&ping -n 2 raymond.cc>nul" >C:\pingtest.txt

Command prompt ping timestamp

The above will continuously ping the address with a time and date and an output log file, press Ctrl+C to end the session. If you wish to add the line to a batch script substitute the "%a" for "%%a" in the middle of the command. There are of course variations of inserting the time and date into the Windows Ping, feel free to share them in the comments. Remove the redirection to an output file if you want to show the results in the console window.


7. Ping From PowerShell

There are some dedicated PowerShell commands for pinging remote computers like Test-Connection and Test-NetConnection, but the standard Ping command also works as normal. As with Command Prompt, PowerShell requires you to manually insert a timestamp.

Test-Connection -count 999999999 -delay 2 raymond.cc | select @{n='Date/Time';e={Get-Date}},Address , IPv4Address ,ResponseTime >C:\pingtest.txt

Powershell test connection

As Test-Connection does not have an infinite loop switch we have to set a large count time. An optional delay of two seconds between pings helps extend the time even further. For using the Ping command:

Ping.exe -t raymond.cc | ForEach {"{0} – {1}" -f (Get-Date),$_} >C:\pingtest.txt

Powershell ping

The above does pretty much the same as Ping from Command Prompt in method six. One of the advantages PowerShell has over Command Prompt is the ability to send the output in two different directions at once. That gives you the option to view the ping results in the console window and output to a file at the same time.

Ping.exe -t raymond.cc | ForEach {"{0} – {1}" -f (Get-Date),$_} | Tee C:\pingtest.txt

Powershell ping tee

All you have to do is replace the redirect arrow with a pipe "|" and the Tee (or Tee-Object) command. This also works with other commands in PowerShell and is useful if you want to log and view console output at the same time.

delfabbrotheraideban.blogspot.com

Source: https://www.raymond.cc/blog/timestamp-ping-with-hrping/

0 Response to "How to Log Continuous Ping Results to a Text File"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel