Computer Hope

Microsoft => Microsoft DOS => Topic started by: DaveLembke on August 22, 2008, 07:11:39 PM

Title: Echo to txt file Ping string
Post by: DaveLembke on August 22, 2008, 07:11:39 PM
Looking for a way to echo out the PING command to create a Log File with Date/time and Ping output, so that I can look back at the ping history and look for issues.. Anyone know how this could be done...maybe even post the batch to make it happen.


Thanks for your help in advance...

Looking for a way to Record the Response times of a Triangulated with routers network that we have to prove that we need to set up a priority of service between sites for specific communications over others, and also looking for hot spots where maybe an automated routine can be changed  so that bandwidth saturation can be avoided since our VoIP phones degrade badly at these times.

In order to get the money to prove that this is a problem, I have to show real data, and a ping log will do just that.

Thanks
Title: Re: Echo to txt file Ping string
Post by: fireballs on August 22, 2008, 07:19:53 PM
try:

Code: [Select]
echo %date% %time%>>log.txt
ping *ip adress* >>log.txt

FB
Title: Re: Echo to txt file Ping string
Post by: Dias de verano on August 23, 2008, 01:25:45 AM
A quick hack, just a skeleton. Obviously the IP address (Google) in the script is an example. Many refinements are possible, e.g. set ip=%1, set logfile=%ip%-Pinglog.csv etc and then you can pass the IP as a parameter when you start (or call) the batch and also have logfiles with the IP being pinged in the filename. CSV files are readable by MS Excel so you can present it nicely, create charts etc, or you could change the extension to .txt if you prefer.

A possible issue:

The means of generating a delay I have used is sleep.exe which you may have already and which is part of the (free) Windows Server 2003 Resource Kit.

http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

A method often suggested of generating a delay in a batch script is to ping some IP adress or other, which personally I think is a kludge, especially given that you already have (or suspect you have) network congestion issues, and no delay at all is going to generate lots and lots of ping traffic, and make huge log files.

Code: [Select]
@echo off
setlocal enabledelayedexpansion

set ip=66.249.91.147
set delay=60
set logfile=Pinglog.csv

echo "Date","Time","IP Address","Min","Max","Ave">%logfile%

:loop

for /f "tokens=1-26 delims= " %%A in ('ping %ip% ^| find "Minimum"') do (
set min=%%C
set max=%%F
set ave=%%I
set min=!min:ms=!
set max=!max:ms=!
set ave=!ave:ms=!
set string="%date%","%time%","%ip%",!min!!max!!ave!
)

echo %string%
echo %string%>>%logfile%
sleep %delay%

goto loop

Code: [Select]
"Date","Time","IP Address","Min","Max","Ave"
"23/08/2008"," 8:06:48.15","66.249.91.147",22,27,24
"23/08/2008"," 8:07:51.34","66.249.91.147",23,29,25
"23/08/2008"," 8:08:54.52","66.249.91.147",23,25,23
"23/08/2008"," 8:09:57.76","66.249.91.147",23,24,23
"23/08/2008"," 8:11:00.93","66.249.91.147",24,26,24
"23/08/2008"," 8:12:04.16","66.249.91.147",23,24,23
"23/08/2008"," 8:13:07.40","66.249.91.147",22,25,23
"23/08/2008"," 8:14:10.68","66.249.91.147",23,24,23
"23/08/2008"," 8:15:13.87","66.249.91.147",23,25,23
"23/08/2008"," 8:16:17.10","66.249.91.147",22,27,24
"23/08/2008"," 8:17:20.30","66.249.91.147",22,22,22
"23/08/2008"," 8:18:23.54","66.249.91.147",23,24,23
"23/08/2008"," 8:19:26.74","66.249.91.147",23,26,25
"23/08/2008"," 8:20:29.98","66.249.91.147",22,24,23
"23/08/2008"," 8:21:33.15","66.249.91.147",24,26,24
"23/08/2008"," 8:22:36.41","66.249.91.147",23,25,23
"23/08/2008"," 8:23:39.60","66.249.91.147",22,23,22

Title: Re: Echo to txt file Ping string
Post by: DaveLembke on August 25, 2008, 03:36:54 PM
Thanks for the infomation from the both of you and code to make it work...

The version that "Dias de verano" created however looks to be more of what I need a date/time stamp to tag with each recording as shown below:

The response times to this idle network device should be far better than the ms recordings shown below since we have a T1 connections between sites. I hope to roll this out to a number of systems in our triangulated network of 3 large main sites and find the bottlenecks.

One question I have with the data recorded to make sure I fully understand it is that it is recording 3 pings per recorded interval? .... so as seen below the pings of 105, 158, and 127 are the ms response times in that order followed by the next line of 63,163, and 109... so it would be if looking linear at the data like so in ping order ?

105 ms
158 ms
127 ms
63 ms
163 ms
109 ms

------------------------------Data Collected below in pinglog.csv ---------------

"Date","Time","IP Address","Min","Max","Ave"
"Mon 08/25/2008","17:16:29.81","192.168.1.125",105,158,127
"Mon 08/25/2008","17:16:33.03","192.168.1.125",63,163,109
"Mon 08/25/2008","17:16:36.23","192.168.1.125",100,138,118
"Mon 08/25/2008","17:16:39.47","192.168.1.125",97,166,133
"Mon 08/25/2008","17:16:42.70","192.168.1.125",44,91,75
"Mon 08/25/2008","17:16:45.92","192.168.1.125",125,180,147
"Mon 08/25/2008","17:16:49.18","192.168.1.125",77,113,101
"Mon 08/25/2008","17:16:52.40","192.168.1.125",36,125,69
"Mon 08/25/2008","17:16:55.57","192.168.1.125",16,188,106
"Mon 08/25/2008","17:16:58.75","192.168.1.125",75,149,104
"Mon 08/25/2008","17:17:02.00","192.168.1.125",79,152,100
"Mon 08/25/2008","17:17:05.18","192.168.1.125",16,140,100
"Mon 08/25/2008","17:17:08.43","192.168.1.125",71,123,100

Title: Re: Echo to txt file Ping string
Post by: fireballs on August 25, 2008, 03:44:00 PM
If i understand you right you've got the wrong idea. As the titles suggest the three numbers are min, max and average. ping takes four readings as standard.

As usual i bow to Dias de verano's superier knowledge.

FB
Title: Re: Echo to txt file Ping string
Post by: Dias de verano on August 25, 2008, 03:49:52 PM
Each line in the log file contains the time data from one of these:

Code: [Select]
C:\>ping 66.249.91.147

Pinging 66.249.91.147 with 32 bytes of data:

Reply from 66.249.91.147: bytes=32 time=27ms TTL=243
Reply from 66.249.91.147: bytes=32 time=35ms TTL=243
Reply from 66.249.91.147: bytes=32 time=23ms TTL=243
Reply from 66.249.91.147: bytes=32 time=26ms TTL=243

Ping statistics for 66.249.91.147:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 23ms, Maximum = 35ms, Average = 27ms <------------TIMES ARE FROM HERE-----------<

Title: Re: Echo to txt file Ping string
Post by: DaveLembke on August 25, 2008, 04:12:16 PM
Thanks for clearing that up so quickly... This all makes sense now and will work out perfect for my application.

Greatly Appreciated!!

Dave
Title: Re: Echo to txt file Ping string
Post by: DaveLembke on June 18, 2018, 02:10:40 PM
Just wanted to say thank you for not purging this from the website. Almost 10 years later and found a need for it again and it was right here to use again.  ;D

Dealing with DSL Internet service provider issue where an old Westell Model 6100 modem is suspect - or - the line coming in to the building. They have done a loop back and said all is well, but when they run their loopback all is well because it is during that time only. They stated they needed proof that its the modem to replace it. So going to use this to log latency and connectivity outages with the ISP.

Just needed to add sleep.exe to the Windows 7 system. Got it from Windows Server 2003 Resource Kit. https://www.microsoft.com/en-us/download/details.aspx?id=17657
Title: Re: Echo to txt file Ping string
Post by: patio on June 18, 2018, 04:23:41 PM
Quit necromancing old Posts...this is your 2nd warning...


 8)
Title: Re: Echo to txt file Ping string
Post by: DaveLembke on June 18, 2018, 06:40:45 PM
 ;D LOL and final one. jk  :P
Title: Re: Echo to txt file Ping string
Post by: Squashman on June 18, 2018, 10:42:52 PM
Just needed to add sleep.exe to the Windows 7 system. Got it from Windows Server 2003 Resource Kit. https://www.microsoft.com/en-us/download/details.aspx?id=17657
Why wouldn't you just use the TIMEOUT command that is already part of the OS?
Title: Re: Echo to txt file Ping string
Post by: DaveLembke on June 19, 2018, 11:55:53 PM
Didnt know that command existed. Very Cool!!! Thanks for sharing Squashman.

http://www.robvanderwoude.com/wait.php#TIMEOUT
Title: Re: Echo to txt file Ping string
Post by: Salmon Trout on June 20, 2018, 02:53:16 AM
... and I was Dias de Version back then
Title: Re: Echo to txt file Ping string
Post by: DaveLembke on June 20, 2018, 07:42:40 AM
 ;D Very Cool Salmon  8) ... Much appreciated in creating that batch for me 10 years ago. It still has a purpose.  :)

Now I gathered up plenty of data into a csv and will walk into the DSL provider later today with laptop and show the outage issues with them as its in a nice Excel spreadsheet with a graph showing outage frequency and durations as well as another graph of latency going crazy.

Its crazy that they wont just give a newer DSL modem out knowing this one has been in operation for about 8 or 9 years and looks to have had better days. All the many storms its made it through and power outages and brown outs, I think it is starting to show its battle scars and needs to be replaced. Router has no issues and so its the modem or the copper pair.  The fun with ISP Providers at times and the finger pointing of their issue vs mine ::)
Title: Re: Echo to txt file Ping string
Post by: Salmon Trout on June 20, 2018, 11:29:40 AM
After 10 years the Reskit link still works!