LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-01-2003, 11:26 AM   #1
wkm001
LQ Newbie
 
Registered: Jul 2003
Location: Virginia
Distribution: Red Hat 7.3, 8, 9
Posts: 23

Rep: Reputation: 15
Want to log traceroute or ping times


I want to log traceroute activity or ping times to a file. I would like for the output to be a line by line text file with each line having a date/time stamp along with time in milliseconds. I have looked at MTR but I don't think it will give me the timestamps. Any help or getting pointed in the right direction will be greatly appreciated.

Casey
 
Old 08-01-2003, 01:16 PM   #2
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 683

Rep: Reputation: 63
dunno if this would help of not but here's something I just made up to do it...
Create a file call it pingtest or whatever you want... Contents of the file:
#/bin/bash
date > /tmp/junk123
ping -c 3 -q IP_YOU_WANT_TO_PING | tail -1 > /tmp/junk124
paste /tmp/junk123 /tmp/junk124 >> /home/foo/pingtimes
sleep 1
rm /tmp/junk123 /tmp/junk124

Then I created a cron job
* * * * * /home/foo/pingtest


Output: (cat /home/foo/pingtimes)
Fri Aug 1 12:03:49 MDT 2003 rtt min/avg/max/mdev = 0.910/0.946/1.010/0.057 ms
Fri Aug 1 12:05:00 MDT 2003 rtt min/avg/max/mdev = 0.923/0.947/0.971/0.019 ms
Fri Aug 1 12:06:00 MDT 2003 rtt min/avg/max/mdev = 0.750/0.864/0.967/0.092 ms
Fri Aug 1 12:07:00 MDT 2003 rtt min/avg/max/mdev = 0.860/0.948/0.995/0.072 ms
Fri Aug 1 12:08:00 MDT 2003 rtt min/avg/max/mdev = 0.788/0.863/0.930/0.058 ms
Fri Aug 1 12:09:00 MDT 2003 rtt min/avg/max/mdev = 0.792/0.857/0.905/0.058 ms
Fri Aug 1 12:10:00 MDT 2003 rtt min/avg/max/mdev = 0.794/0.857/0.931/0.061 ms
Fri Aug 1 12:11:00 MDT 2003 rtt min/avg/max/mdev = 0.831/0.897/0.943/0.059 ms
Fri Aug 1 12:12:00 MDT 2003 rtt min/avg/max/mdev = 0.799/0.908/1.075/0.124 ms
Fri Aug 1 12:13:00 MDT 2003 rtt min/avg/max/mdev = 0.742/0.820/0.873/0.056 ms

Hope that helps
 
Old 08-01-2003, 02:23 PM   #3
wkm001
LQ Newbie
 
Registered: Jul 2003
Location: Virginia
Distribution: Red Hat 7.3, 8, 9
Posts: 23

Original Poster
Rep: Reputation: 15
WOW!!!!!!!!

That is exactly what I was looking for.
Thank you very much.
At first I thought it wasn't working but then I remembered I had ping going in and out disabled in iptables. Damn iptables will get you everytime.

This is also my first posted question about Linux and the result was fantastic.

Casey
 
Old 08-01-2003, 02:37 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
You could aso just use one line in your crontab:
* * * * * date +"%D %r `ping -c 1 SOME_ADDRESS | tail -1`" >> /var/log/ping.log

Last edited by david_ross; 08-01-2003 at 02:38 PM.
 
Old 10-22-2011, 06:27 AM   #5
InAweOfLinux
LQ Newbie
 
Registered: Oct 2011
Posts: 1

Rep: Reputation: Disabled
With VOIP this seems an increasingly enduring issue

In these times of VOIP the need for continuous Internet service is of growing importance.

In appreciation of this {old!} thread and Linux in general I've been evolving a similar thing (having largely started with this thread) for a cable connection that degrades following a number of months of stability. It then has micro outages. Catching the data is essential to support the case to the ISP to fix the issue, instead of the first level support saying well your modem's up now so the problem's probably fixed...!

I logged pings for some time, of course the logs grow quite rapidly when one does a ping to the ISP every minute... and a large log file is produced where one has to find the needles in the hay stack... I looked into using a date time stamp with a searchable message... e.g. "Ping Failure" however having spent quite a few hours on this I've come to realise all that I need to log is ping failures. I now use cronttab to run the file cronping.sh every minute, thus:

#/bin/bash
#if ping -c 1 {ISP or other Ping target} | tail -1 >> /var/log/ping.log; then #I think this failed...

if ping -c 1 {ISP or other Ping target}; then

#date +"%D %r Ping Success" >> /var/log/ping.log
#date +"%D %r Ping Success" >> /var/www/ping.log

else

date +"%D %r Ping Failure" >> /var/log/ping.log
date +"%D %r Ping Failure" >> /var/www/ping.log

fi
[/end of file]

The use of the apache root directory allows a quick browse of any network failures from any browser on the LAN. The option to record successful pings can be uncommented. Yes I probably could just log to one place, its a reflection of how the code evolved.

Possible Evolution: I might look into some sort of notification, email comes to mind however that is only going to work when I am back on line. Suggestions? I might also add traceroute, thinking about where the codes now got to that would probably be easy to add in. Comments or improvements welcomed.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ping vs traceroute shesundar Linux - Networking 1 11-30-2005 04:33 AM
traceroute times out Furlinastis Linux - Networking 2 09-14-2005 03:39 PM
users can't use ping traceroute ... kvtournh Mandriva 1 11-16-2004 06:43 AM
network programming (esp. ping/traceroute) in Python Ikana Programming 1 08-31-2004 08:35 PM
traceroute times out centr0 Linux - Networking 4 04-22-2004 04:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration