Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: >>RealTime.txt added to this to log actual pings for 60 sec  (Read 6622 times)

0 Members and 1 Guest are viewing this topic.

DaveLembke

    Topic Starter


    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
>>RealTime.txt added to this to log actual pings for 60 sec
« on: March 17, 2009, 10:58:01 AM »
Tried to add an >>RealTime.txt statement to this batch to record also to log the actual pinged responses for the 60 sec interval that writes to the .CSV and having a hard time adding this write to file statement for each ping for the 60 sec intervals. Any suggestions on placement of the >>RealTime.txt logging of the echo'd persistent ping information?

I get this error:

C:\>network_logger_rev2.bat
>> was unexpected at this time.
C:\>


Below is the working batch without the >>RealTime.txt logging feature of the persistent ping echo to show the working batch without me fouling it up..ha ha

Any suggestions on how to add this and its placement and proper execution? I attempted to add the echo out of the ping to write to file within the FOR statement and it didnt like it.

FYI: Sleep.exe is required for proper execution in root of batch execution folder. For anyone who may try this out and see it crash... it requires Sleep.exe which if you dont already have you can get here at computerhope at:
http://www.computerhope.com/dutil.htm


Code: [Select]
@echo off
setlocal enabledelayedexpansion

set ip=192.168.2.231
set delay=60
set logfile=TestLog.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

devcom



    Apprentice

    Thanked: 37
    Re: >>RealTime.txt added to this to log actual pings for 60 sec
    « Reply #1 on: March 17, 2009, 11:47:38 AM »
    try this:
    Code: [Select]
    echo %string% >>%logfile%yes i've just added space but try this  ;D
    Download: Choice.exe

    Dias de verano

    • Guest
    Re: >>RealTime.txt added to this to log actual pings for 60 sec
    « Reply #2 on: March 17, 2009, 12:42:16 PM »
    Could you be a bit clearer about what you are trying to achieve? You have got a loop where you are dismantling the output line of ping (which happens once every 60 seconds) which contains the max min and average times, so what else are you hoping to echo to realtime.txt?

    DaveLembke

      Topic Starter


      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: >>RealTime.txt added to this to log actual pings for 60 sec
    « Reply #3 on: March 17, 2009, 01:36:19 PM »
    Hello and thanks for the responses. In addition to exporting the information to CSV as say:

    "Tue 03/17/2009","15:15:08.08","192.168.2.231",46,193,83

    every 60 seconds...I was wondering if there was a way to write every ping that composed that 60 second interval to  RealTime.txt so I would have my CSV with the information like above + information like below in RealTime.txt to look at the intervals more closely to look for patterns etc to the response times vs only having the resolution of 1 minute intervals with the Minimum, Maximum, and Average.

    To match up 60 second intervals a start and stop %date% %time% is added at the beginning of the interval and end of the interval so each ping is 1 second in resolution to that 60 second interval written to the CSV. So if anything looks ugly like a 600ms response time I would know in a finer resolution down to the second or seconds at which it stayed at 600ms  or around there and can then look at other data on hand to try to figure out what is going on.

    Opening RealTime.txt would show the following if possible: ( This is beyond my batch coding abilities but it should be able to happen although I am unsure as to if the actual ping can be written to the RealTime.txt file while it is already performing the FOR argument for the write to the CSV for every 60 sec interval.)

    *Note: There are not 60 pings here to save from the scrolling madness and this output below was fabricated and I dont have code yet that does this that works with the original batch! Also the extra steps may offset the CSV by 1 sec or so between readings in which actual recorded intervals are 61 or 62 seconds as it performs the extra write to files every second.


    ...............Started at  Tue 03/17/2009 at 15:29:14.19
    Reply from 192.168.2.231: bytes=32 time=6ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=6ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=9ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=12ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=6ms TTL=122
    ...............60 second Interval at  Tue 03/17/2009 at 15:30:14.19
    ...............Started at  Tue 03/17/2009 at 15:30:14.20

    Reply from 192.168.2.231: bytes=32 time=6ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=6ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=9ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=12ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122
    Reply from 192.168.2.231: bytes=32 time=6ms TTL=122
    ...............60 second Interval at  Tue 03/17/2009 at 15:31:14.19

    Dias de verano

    • Guest
    Re: >>RealTime.txt added to this to log actual pings for 60 sec
    « Reply #4 on: March 17, 2009, 01:49:17 PM »
    But your code is not continually pinging; it executes Ping once,

    like this

    Code: [Select]
    Pinging 69.72.169.241 with 32 bytes of data:

    Reply from 69.72.169.241: bytes=32 time=100ms TTL=52
    Reply from 69.72.169.241: bytes=32 time=100ms TTL=52
    Reply from 69.72.169.241: bytes=32 time=99ms TTL=52
    Reply from 69.72.169.241: bytes=32 time=122ms TTL=52

    Ping statistics for 69.72.169.241:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 99ms, Maximum = 122ms, Average = 105ms

    This takes about 2 seconds. You are filtering everything out except the line starting "Minimum", which you then process.

    Then the code just waits 60 seconds, (that's what 'sleep' does) then it does it all over  again and again continually

    It is doing nothing in those 60 or so seconds. (Except waiting for them to pass) There are no pings happening during that time.

    Quote
    a way to write every ping that composed that 60 second interval

    There aren't any.
    « Last Edit: March 17, 2009, 02:01:33 PM by Dias de verano »

    DaveLembke

      Topic Starter


      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: >>RealTime.txt added to this to log actual pings for 60 sec
    « Reply #5 on: March 17, 2009, 04:27:43 PM »
    Ok many thanks for clarifying, and now that I look at it you are correct about it running the ping and sleeping. I forgot about that and it should have stuck out when looking through the code.

    DaveLembke

      Topic Starter


      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: >>RealTime.txt added to this to log actual pings for 60 sec
    « Reply #6 on: March 17, 2009, 04:43:54 PM »
    I guess I will just use this for the Ping Logging with Date / Time Recorded as a way of testing now that I am clear on my original batch.


    Code: [Select]
    :start
    @echo...........>>PingLogger.txt
    @echo...........>>PingLogger.txt
    @echo. 60 Ping Interval Marker %date% at %time%>>PingLogger.txt
    @echo...........>>PingLogger.txt
    @echo...........>>PingLogger.txt
    ping 192.168.2.231 -n 60 >>PingLogger.txt
    goto start


    To end up with this that will work for my testing in PingLogger.txt
    ..........
    ..........
     60 Ping Interval Marker Tue 03/17/2009 at 18:40:02.95
    ..........
    ..........


    Pinging 192.168.2.231 with 32 bytes of data:



    Request timed out.

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=9ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122



    Ping statistics for 192.168.2.231:

        Packets: Sent = 60, Received = 59, Lost = 1 (1% loss),

    Approximate round trip times in milli-seconds:

        Minimum = 7ms, Maximum = 9ms, Average = 7ms

    ..........
    ..........
     60 Ping Interval Marker Tue 03/17/2009 at 18:41:08.33
    ..........
    ..........


    Pinging 192.168.2.231 with 32 bytes of data:



    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=6ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=7ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122

    Reply from 192.168.2.231: bytes=32 time=8ms TTL=122