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

Author Topic: Continuously ping script  (Read 53196 times)

0 Members and 1 Guest are viewing this topic.

Apexi

    Topic Starter


    Rookie

    Continuously ping script
    « on: October 31, 2011, 02:53:26 PM »
    To mention it, i'm not looking for an DDOS script.
    I have problem with my internet connection and my ISP want believe me since they only use the ping command prompt, and that only pings four times.
    So i need a script that pings a host for like an hour and make an log in a .txt file, and with timestamps on every ping would be great.
    « Last Edit: October 31, 2011, 03:51:31 PM by Apexi »

    DaveLembke



      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Continuously ping script
    « Reply #1 on: October 31, 2011, 06:40:56 PM »
    Quote
    i'm not looking for an DDOS script
    ((Your not looking for a script???)) yet what I have below is the best method I can come up with, and it requires a batch script unless of course you want to hand key it to execute it manually, but the goto routine I dont think you could run unless you create a single lined concatenated batch file...lol

    Best solution I can suggest is a goto loop in a batch file that writes the output to a text file. I would also add Date/Time Stamp to it in between each write of ping results so that when you have issues, you will have a somewhat good idea as to when it happened and for how long.

    Code: [Select]
    @echo OFF
    :REPEAT
    @echo. %date% at %time% >>PingLog.txt
    ping www.google.com >>PingLog.txt
    goto REPEAT

    I used a batch similar to this a while back for issues, but got further info from traceroutes where my ISP had a bad DNS path due to them buying up cheap and not so reliable taps to the Internet Backbone. The engineer at my ISP who took quite a few on hold phone hops to get to found it rather embarrasing that a home user was able to find this issue through a batch file and traceroutes, while most people would just accept poor performance or blame their home hardware.

    If you are having strange issues with DNS being resolved, manually change your DNS to an IP from another DNS provider like OpenDNS and see if you get different results. Maybe you too will find out your ISP has junky DNS paths to the Internet.

    *Also this batch is very crude, in that you could make it better to strip it of everything but the ping results to be written to file if you want something clean with date/time and ping response times. Also you can change your ping path etc. I used Google since it is usually the best indicator of ISP issues since you should have pings less than 80ms, with 30-40ms being the best I have seen from my location. Also you may see the IP's change from where Google resolves as it is handled by the many Points of Presence that Google has for their search engine. Last time I checked I think the count was like 14 different IPs that www.google.com resolves at.

    Also you can alter the ping www.google.com to ping www.google.com -n 60 >>PingLog.txt if you want say 60 pings per date/time stamped interval, using the -n followed by the ping-count of times to ping as shown.

    Apexi

      Topic Starter


      Rookie

      Re: Continuously ping script
      « Reply #2 on: November 01, 2011, 06:27:24 AM »
      Thanks. It looks so simple when someone else write it  :) Dont know if i had brainfreeze yesterday.
      I added -t after ping and now it works as i wanted.

      Salmon Trout

      • Guest
      Re: Continuously ping script
      « Reply #3 on: November 01, 2011, 12:45:59 PM »
      ((Your not looking for a script???))

      He wrote "I'm not looking for a DDOS script" (note the 2 D's) A DDOS attack is a distributed denial of service attack, where many thousands of computers (usually in a botnet) ping the same host and effectively shut it down becaue it can't respond to legitimate traffic.

      It is worth noting that some hosts do not service ICMP requests (that is, they silently swallow ping requests and the remote (your) ping command times out)

      Code: [Select]
      C:\>ping www.microsoft.com

      Pinging lb1.www.ms.akadns.net [207.46.131.43] with 32 bytes of data:
      Request timed out.
      Request timed out.
      Request timed out.
      Request timed out.

      Ping statistics for 207.46.131.43:
          Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

      « Last Edit: November 01, 2011, 12:58:34 PM by Salmon Trout »

      DaveLembke



        Sage
      • Thanked: 662
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: Continuously ping script
      « Reply #4 on: November 01, 2011, 01:52:26 PM »
      If you go persistent with -T, you can run it as a single line such as:

      Code: [Select]
      ping www.google.com -t >PingLog.txt
      or if you want to append to end when restarted replace > with >> in that instruction. Guessing you will want to use > to overwrite the old data when run again since with -T you wont be getting date/time stamps to know when it cuts out. Also Salmon had a good point in regards that many shut off the ping responses and thanks for picking up on the DDOS while I took it as a typo..lol  As of writing this google still echos back ping results.

      zuc



        Starter

        • Experience: Beginner
        • OS: Unknown
        Re: Continuously ping script
        « Reply #5 on: November 15, 2011, 07:26:09 AM »
        Been looking for a way to ping internal network devices by running a batch file. 

        I need to keep an eye on 15 different network sites and have been pinging them by opening up the cmd prompt and pinging each site continuously.  My problem is that I will have to open up 15 different cmd prompts and manually type in the ping command as well as the address that I want to ping.

        My questions is how do I write a batch file to open cmd prompts, enter the address I want to ping, then open a new cmd prompt, enter the next address i want to ping, etc...Then I would like it to tile the boxes horizontally so I can keep an eye on all of them.


        I got this far but do not know how to enter the text into the cmd prompt to start the ping.

        I am very skilled in hardware troubleshooting/replacement but not so much in programming. 

        echo
           start c:/windows/system32/cmd.exe




        Any help is greatly appreciated. 

        zuc



          Starter

          • Experience: Beginner
          • OS: Unknown
          Re: Continuously ping script
          « Reply #6 on: November 15, 2011, 08:39:21 AM »
          I have searched some more and what I am trying to accomplish is probably very easy.  He is what I have so far:

          start cmd.exe
          ping xxx.xx.xx.xxx -t
          start cmd.exe
          ping xxx.xxx.xxx.xxx -t


           The first cmd prompt opens and pings the first address, however the second cmd prompt opens but does not ping the second address.   

          zuc



            Starter

            • Experience: Beginner
            • OS: Unknown
            Re: Continuously ping script
            « Reply #7 on: November 15, 2011, 10:10:43 AM »
            The problem I had was the batch file would not execute the next line of code after the ping -t command because that would not stop.

            Ended up writing 14 batch files, each one opening the next batch file before executing the ping -t command. 

            I am sure there was a easier way to do it but it works for me.

            Salmon Trout

            • Guest
            Re: Continuously ping script
            « Reply #8 on: November 15, 2011, 11:25:17 AM »
            zuc, you are not supposed to hijack another person's thread, you should have started a new one.

            You need to use start like this

            start "window title" "command"

            start "" "command"

            window title can be blank, just 2 quotes but you must not omit it.

            Example:

            Script will start each command in separate window. To terminate each click on title bar or in box and type CTRL + C or click window close icon.

            Code: [Select]
            start "yahoo" "cmd /c ping www.yahoo.com -t"
            start "google" "cmd /c ping www.google.com -t"