Announcement

Collapse
No announcement yet.

Time Stamp on Ping log

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Time Stamp on Ping log

    Here is what I have

    @ echo off
    :START
    date/t && time/t && ping 192.168.12.2 >> c:\ping.txt
    sleep 5
    goto START

    I get the time stamp but it doesn't show if the ping was successful or not successful. Any ideas?

  • #2
    Re: Time Stamp on Ping log

    Quote from http://www.ss64.com/nt/ping.html:
    A successful PING does NOT always return an %errorlevel% == 0
    Therefore to reliably detect a successful ping - pipe the output into FIND and look for the text "TTL"
    I hope this is what you were looking for. Good luck.

    Sorin Solomon

    »»»»»
    In order to succeed, your desire for success should be greater than your fear of failure.
    -
    «««««

    Comment


    • #3
      Re: Time Stamp on Ping log

      Your link is broken. However that is not what I am looking for.

      Comment


      • #4
        Re: Time Stamp on Ping log

        Somehow the colon ( : ) got mixed into the link. The link should be http://www.ss64.com/nt/ping.html .
        it doesn't show if the ping was successful or not
        Since the PING command is problematic when talking about errorlevels, the method described here is the way (one of them, anyway) to check if there was a response or not.
        I understand from your first post that you do get the time stamp. So, if this is not what you were looking for, could you please reformulate your question?

        Sorin Solomon

        »»»»»
        In order to succeed, your desire for success should be greater than your fear of failure.
        -
        «««««

        Comment


        • #5
          Re: Time Stamp on Ping log

          Originally posted by sorinso View Post
          Somehow the colon ( : ) got mixed into the link. The link should be http://www.ss64.com/nt/ping.html .

          Since the PING command is problematic when talking about errorlevels, the method described here is the way (one of them, anyway) to check if there was a response or not.
          I understand from your first post that you do get the time stamp. So, if this is not what you were looking for, could you please reformulate your question?
          Thanks for your help, I think I am having a little trouble explaining lol. Ok let me try ig again. When I use this code:

          @ echo off
          :START
          echo %date% >> c:\ping.txt
          echo %time% >> c:\ping.txt
          ping 192.168.12.1 -t >> c:\ping.txt
          sleep 5
          goto START
          I get one time stamp and then in the command window I get "This file can not be processed it is being used by another process". So that is my first problem.

          Secondly I do not see "Reply from 192.168.12.1 ......"

          Now when I use the following command:

          ping -t 192.168.12.1 >> c:\ping.txt
          I get this ........

          Pinging 192.168.12.1 with 32 bytes of data:

          Reply from 192.168.12.1: bytes=32 time=3ms TTL=64

          Reply from 192.168.12.1: bytes=32 time=3ms TTL=64

          Reply from 192.168.12.1: bytes=32 time=3ms TTL=64

          Reply from 192.168.12.1: bytes=32 time=3ms TTL=64

          Reply from 192.168.12.1: bytes=32 time=3ms TTL=64
          Now what I want to accomplish here is a combined output like the time stamps along with the "Reply from 192.168.12.1: bytes ..............."

          I hope I explained it correctly any more questions let me know I'll try my best to answer them correctly. Thank you so much again.

          Comment


          • #6
            Re: Time Stamp on Ping log

            I tinkered with your code a bit but then remembered Performance Pinging, this is not the answer to your post but may help you anyway.
            "...if I turn out to be particularly clear, you've probably misunderstood what I've said” - Alan Greenspan

            Comment


            • #7
              Re: Time Stamp on Ping log

              Writing to a textfile takes time. The batch doesn't wait for the file to finish, it will already process the next command after the file from the previous command was opened but not when it is written and closed properly.

              Can you tell us how or for what purpose you want to use this batch?
              Here is a batch you can schedule every day at several times (autorun) if that is what you want?:
              Code:
              :: "Set Variables"
              @Set $IP=127.0.0.1
              @Set OutputFile=c:\PingResults.log
              
              :: "Set Time stamp"
              @FOR /F "tokens=*" %%* IN ('date/t') Do @(set $dt=%%*)
              @FOR /F "tokens=*" %%* IN ('time/t') Do @(set $tm=%%*)
              
              :: "Ping Computer"
              @Set tmpFile=%temp%\ping.txt
              @start/b/w PING -a %$IP% -n 2 -w 750>"%tmpFile%"
              @FOR /F "tokens=2,3 delims= " %%A IN (%tmpFile%) DO @IF "%%B"=="[%$IP%]" SET $PC=%%A ||@rem
              
              :: "Get Status"
              @Set $Status=Off-Line
              @IF EXIST "%tmpFile%" @GoTo READSTATUS
              @Set $Status=Ping-Error
              @GoTo RESULTS
              :READSTATUS
              @Set errorlevel=
              @Type "%tmpFile%" | Find "TTL=" >nul
              @IF Not errorlevel = 1 @Set $Status=On-Line
              @DEL %tmpFile%
              
              :RESULTS
              @echo results: %$dt% %$tm% %$PC%[%$IP%] ^= %$Status% >>"%OutputFile%"
              @ECHO Press Enter to continue . . .&@SET /P =
              The pinging is started with Start/w. This way the batch wait with processing the next line untill the last command is returned back (slash /b is preventing opening a second dosbox)

              Line 12 (is optional it determines the name of the remote computer):
              FOR /F "tokens=2,3 delims= " %%A IN (%tmpFile%) DO ......
              The tokens=2,3 are for the 2nd- and third- word of each line of the ping-output. In the first line on English OperatingSystems (and maybe other languages too) these words are Computername and Ipaddres. If I would run this script from one of my Dutch clients I must read the 3rd and 4th words ( tokens=3,4) for the same results. Count the the Words of the first results-line if you run the batch from a computer in an other language, and set the tokens write.

              I used a tempfile here just because I used two commandlines seaching the pingresults, now I dont have to perfom multiple pings for the same computer. If you are not intreseted in the name of the computer, only the 'status', then it is not realy nessesary to create a tempfile.

              On the line: @Set $IP=127.0.0.1
              type the ip-addres of the remote computer. It is also possible to enter %1 here so you can enter the ipaddress on the command-line as a parameter.

              If you planned to autorun this batch, then comment the last line.


              \Rems
              Last edited by Rems; 14th October 2007, 22:47.

              This posting is provided "AS IS" with no warranties, and confers no rights.

              __________________

              ** Remember to give credit where credit's due **
              and leave Reputation Points for meaningful posts

              Comment


              • #8
                Re: Time Stamp on Ping log

                Thank you again for your replies. I like the program I downloaded it and it works pretty well. I also copied the code but didn't get a chance to test it out yet.

                Now why I want to do this.... Well basically I have a client that is constantly complaining about being slow and internet not working etc. They are pointing fingers are our data center now here is the thing we have like 45 sites and no one else has issues with our data center but this site.

                I am positive that the issue is the way they are setup. They have a single T1 line and they are using 768 for Voice and 768 for Data. I told them to separate their data and voice, get point to point T1 for their voice and use cable to access our data center like many other sites are doing and they have no issues.

                Unfortunately my company is not providing me any kind of tool or enterprise application to monitor their bandwidth usage and to find out where exactly are they using their 768Kbps data. So I am basically trying to figure out some way of doing this.

                Thanks again...

                Comment


                • #9
                  Re: Time Stamp on Ping log

                  Sounds more like you want to remotely manage any routers they have, enabling detailed router logging and sending it to a syslog server of some sort.

                  That would show you not only what was going on through the router, but (optimally) *who* on their end is going where, and if the level of info is detailed enough, who is actually hogging the BW....

                  Of course, this is moot if the problem is not on their end, but somewhere in the virtual connection from them to you....
                  sigpic

                  Comment


                  • #10
                    Re: Time Stamp on Ping log

                    I found an application that will enable us to do that now getting my company to buy it is another story. It is really awesome and can give you nice reports on the BW usage and which application is using how much etc. Plus it does a lot more than that. I'm hoping that I can get my company to buy it.

                    Comment

                    Working...
                    X