Announcement

Collapse
No announcement yet.

How do you monitor your internet connection?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How do you monitor your internet connection?

    We have an internet connection that is very unstable at times and I would like to document this.

    I have a PC that is on all the time, and would like a tip about a small program that I can run to log the network connection.

    If there is a program that could ping a few addresses every couple of minutes and write an entry in a log if it is not reached, and then a new entry when it is back, it would solve my problem. Then I could present this list to the ISP and demand a refund for the down time (they actually accept it).

    I need to be able to ping at least 5 or more addresses. Preferrably up to 10 addresses.
    Regards,
    Oceanwatcher
    Blog: http://www.wisnaes.com/
    Pictures: http://www.oceanwatcher.com/
    Software tips (in Norwegian): http://www.datahverdag.com/

    #2
    Re: How do you monitor your internet connection?

    you could write a script that does the following

    pings an ip and > log file. i would make a cron job for it and then just make it change the file name each run (ie tell it $filename=pinglog$runtime). im not up on my scripting to much (yet, don't have to write many)but here is some psudocode for your script

    Code:
    $addy[10]= list of address you want to ping
    for(i=0;i<10;i++){
    cout<< "enter an ip to ping";
    cin>> addy[i];
    }//or just hard code addy[i] for no prompts
    $results;
    $time = current time
    for (i=0;i<10;i++)
    {
    $results = $results + '/n' ping addy[i];
    }
    results > pinglog$time
    again thats only psudocode(a little c ish) but it would be something like that.then once your script is working correctly you should add it to cron as a user run job. save the results some where and give em to your isp. (my example uses /home/urlogin_name/log/ so you can find them easily.

    i hope that this help you.
    Mark Your Solved Issues [SOLVED]
    (top of thread: thread tools)

    Comment


      #3
      Re: How do you monitor your internet connection?

      Originally posted by sithlord48
      you could write a script that does the following
      Yes, I was thinking about that as I was writing the mail, but I am really far from being able to do that, so I should probably have mentioned that in the OP.

      I guess some kind of application that do this and output a nicely formatted textfile would be more my style. And it does not have to have a GUI (although I consider it a plus) as long as there is a configuration file that is easy to understand.

      Will keep searching, and if nothing turns up, I will try to find someone that can help me with a script like that. Thank you for the tip!
      Regards,
      Oceanwatcher
      Blog: http://www.wisnaes.com/
      Pictures: http://www.oceanwatcher.com/
      Software tips (in Norwegian): http://www.datahverdag.com/

      Comment


        #4
        Re: How do you monitor your internet connection?

        I use nagios for monitoring networks, but it is probably more than you want for this application, although it did work very well for me when I had a flaky cable connection. Nagios uses plugins and one of them is check_ping. I have attached the executable here, renamed with .png. You can put it somewhere and run it with no parameters for a usage message or use a command line like
        Code:
        ./check_ping -H 192.168.0.100 -w 5000,100% -c 5000,100% -p 1 -4
        which returns
        PING OK - Packet loss = 0%, RTA = 1.54 ms|rta=1.536000ms;5000.000000;5000.000000;0.000000 pl=0%;100;100;0

        Combine that with sithlords suggestion of cron and you should have something. I would suggest that you append to the same file rather than creating a new file each time (>> netlog).

        This plugin is part of nagios-plugins-basic if you are interested.

        Attached Files

        Comment


          #5
          Re: How do you monitor your internet connection?

          That program works like a charm :-)

          Would you mind telling me what the different switches are doing?
          I guess it will be ok to run it against different IP addresses and append to the same file?

          The only problem with this method, is that it actually writes to the file every time it pings. And over some months, this log will be very big - 10 IP addresses every 2 minutes...

          What I am most interested in is a log that shows

          Date Time IP address Not reached
          Date Time IP address Reachable

          etc.

          This way there would only be two lines for each IP address for each blackout. No need to add anything to the log if all is ok.
          Regards,
          Oceanwatcher
          Blog: http://www.wisnaes.com/
          Pictures: http://www.oceanwatcher.com/
          Software tips (in Norwegian): http://www.datahverdag.com/

          Comment


            #6
            Re: How do you monitor your internet connection?

            There are a couple of ways you could deal with this. Depending on what you are testing and how many hosts you ping you could ping a different one every 2 minutes, rather than all of them every 2 minutes, and use one file per host. That would test the main connection every 2 minutes but each host once every 20 minutes.

            I always like to have the entry, even if it is good, so that I know it did not fail. You will probably find that the situation is not just, It worked or it didn't work. There will be packets lost, a few of which you can live with but too many and it is a significant problem. The other is round trip times that will be high and inconsistent. I would suggest that you keep all entries and use grep to find the places of interest to you. You might also want to call
            Code:
            date
            every couple hours to establish the times.

            The parameters deal with what is a OK,warning, or critical response.
            -w 5000,100% says warn if RTA is more than 5000 ms or all packets are lost
            -c 5000,100% critical is the same as warn.

            You might want to adjust these to allow you to grep for different results. Where it now says PING OK it could say PING WARN or PING CRITICAL.
            -p 1 says send only one packet. More packets might be better for you.
            -4 is the timeout in seconds.

            Comment


              #7
              Re: How do you monitor your internet connection?

              Here is a little perl script to do what you want.
              ************************************************** **********
              #! /usr/bin/perl -w
              # Ping and write if not OK
              $CP = "/home/oceanwatcher/netlog/check_ping";
              $hostname = shift;
              $return = `$CP -H $hostname -w 50,5% -c 90,40% -p 4 -4`;
              open(OUT,'>>',"$hostname.log") || die "Can't open $hostname.log";
              if ($return =~ /WARN|CRITICAL/) {
              $ts = `date`;
              chomp $ts;
              print OUT "$ts $return\n";
              }
              close(OUT);
              ************************************************** *************************
              Save to a file and make it executable. It takes one argument, a hostname or ip address. You can edit the check_ping option to your needs. It will write to hostname.log in the directory that contains check_ping if it gets a WARN or CRITICAL response.

              Comment

              Working...
              X