LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   monitor internet connectivity (https://www.linuxquestions.org/questions/linux-newbie-8/monitor-internet-connectivity-944823/)

sumeet inani 05-14-2012 01:56 AM

monitor internet connectivity
 
Hi ,
I want to measure the time for which my internet connection works during whole day . Is there a software that logs the time for which internet was not accessible .
I can write a script & put it in cron to check every minute . But , for that what will be parameter to check net access .

I tried to ping www.google.com but did not got any reply . Though surfing was fine .
Code:

ping www.google.com
PING www.l.google.com (74.125.236.17) 56(84) bytes of data.
^X
--- www.l.google.com ping statistics ---
192 packets transmitted, 0 received, 100% packet loss, time 190999ms

Also my interface is
Code:

$ /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 70:71:BC:CB:DE:47 
          inet addr:192.168.2.100  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::7271:bcff:fecb:de47/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:821 errors:0 dropped:0 overruns:0 frame:0
          TX packets:742 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:120822 (117.9 KiB)  TX bytes:59717 (58.3 KiB)
          Interrupt:58

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4115 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4115 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:8029660 (7.6 MiB)  TX bytes:8029660 (7.6 MiB)


zXi 05-14-2012 02:40 AM

Cacti and squid might be useful in this case. In Cacti, you must be able to interpret the graph of usage. To do so, start downloading any torrent which might take a whole day and start cacti to monitor the usage, wherever you see a drop or red spikes, internet is down.

Do make sure that your firewall is allowed for ICMP [ping ] packets to go through. When you are able to ping google,
using ping will also work, provided you write a small script leading to:

ping -c 2 www.google.com
if [$? != 0] then
echo `date +%F%T` >> /tmp/loggingfile
echo \e "\nnet is down\n------\n" >> /tmp/loggingfile
fi
elsif sleep 30
Reiterate the script for every 30 secs. I forgot shell scripting long back. But I hope you get the idea.


All times are GMT -5. The time now is 03:01 PM.