Results 1 to 5 of 5

Thread: bash script to check ISP uptime

  1. #1
    Join Date
    Mar 2008
    Location
    Copenhagen Denmark
    Beans
    722
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    bash script to check ISP uptime

    Hello, would it be possible, and reliable to make a bash script for checking the reliability of the ISP?

    I live in a dormitary, and I really hate my ISP, but I read that they have committed themself for a 99,5% uptime, I think they are braking this promise, as the connection is pretty unstable, so I want to take it to the test and make a bash script to test it, but I need help to do so.

    Would it be sufficient and possible to get a boolean result from "ping www.google.com", insert it in a log file together with a time stamp, and make it run every minute or so, and somehow calculate the percentage of the boolean values?
    Last edited by jakupl; June 7th, 2009 at 07:37 PM.
    Ubuntu 10.10 Maverick | ASUS A6Rp | Intel(R) Celeron(R) M CPU 420 @ 1.60GHz | 4 GB ram |
    Graphic Card: ATI Technologies inc RC410 [Radeon Xpress 200M]

  2. #2
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    5,490
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: bash script to check ISP uptime

    It's certainly possible. Use the command crontab -e and add a line like this to the file:
    Code:
    * * * * * ping -c 5 www.google.com ; echo $? $(date) >> ~/pings.log
    This will do a ping once a minute. It will write a line with a 1 (success) or 0 (failed) followed by the time.

    Whether is is sufficient - what for? I doubt it's enough to hold up in court. How would you prove it's not an outage at Google? Good enough for getting a good "feel" for the actual availability figure.

  3. #3
    Join Date
    Mar 2008
    Location
    Copenhagen Denmark
    Beans
    722
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: bash script to check ISP uptime

    Quote Originally Posted by The Cog View Post
    It's certainly possible. Use the command crontab -e and add a line like this to the file:
    Code:
    * * * * * ping -c 5 www.google.com ; echo $? $(date) >> ~/pings.log
    This will do a ping once a minute. It will write a line with a 1 (success) or 0 (failed) followed by the time.

    Whether is is sufficient - what for? I doubt it's enough to hold up in court. How would you prove it's not an outage at Google? Good enough for getting a good "feel" for the actual availability figure.
    thankyou very much, I tested it and when the internet works, It outputs "0" and when i turn off the router, it outputs "2", so what does that mean?

    Hehe, I don't think I will take it to court, but it is pretty nice to have some hard statistics when my dorm has meetings and such... I reeealy want to change isp. They have blocked all peer-to-peer activity, they have censored many websites eg. thepiratebay and many others, and it is unstable and expensive. They don't even respond to emails, even though our special agreement clearly states that they are required to do individual support.
    Ubuntu 10.10 Maverick | ASUS A6Rp | Intel(R) Celeron(R) M CPU 420 @ 1.60GHz | 4 GB ram |
    Graphic Card: ATI Technologies inc RC410 [Radeon Xpress 200M]

  4. #4
    Join Date
    Nov 2007
    Location
    London, England
    Beans
    5,490
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: bash script to check ISP uptime

    Quote Originally Posted by jakupl View Post
    thankyou very much, I tested it and when the internet works, It outputs "0" and when i turn off the router, it outputs "2", so what does that mean?

    Hehe, I don't think I will take it to court, but it is pretty nice to have some hard statistics when my dorm has meetings and such... I reeealy want to change isp. They have blocked all peer-to-peer activity, they have censored many websites eg. thepiratebay and many others, and it is unstable and expensive. They don't even respond to emails, even though our special agreement clearly states that they are required to do individual support.
    It means I told you wrong. It is actually printing the error number or status number the ping returns. 0 means the ping succeeded. By trial and error, 1 means it couldn't get a response from the destination. I get a 2 if it couldn't look up the hostname to an IP address. You can try it by hand to discover when you get different error codes:
    ping -c 3 www.google.com
    echo $?
    ping -c 3 1.1.1.1
    echo $?
    ping -c 3 foo.bar
    echo $?

  5. #5
    Join Date
    Mar 2008
    Location
    Copenhagen Denmark
    Beans
    722
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: bash script to check ISP uptime

    ok great. thank you very much.
    Ubuntu 10.10 Maverick | ASUS A6Rp | Intel(R) Celeron(R) M CPU 420 @ 1.60GHz | 4 GB ram |
    Graphic Card: ATI Technologies inc RC410 [Radeon Xpress 200M]

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •