traceroute output with timestamp on each line

shubhankaar

New Member
Joined
Aug 29, 2020
Messages
1
Reaction score
0
Credits
17
Hi All,

I want a script, which will give me an output of traceroute with a timestamp in front of each line.

for. e.g.

$traceroute 216.244.116.54

--> I want output like this

20200828 100622 traceroute to 216.244.116.54 (216.244.116.54), 30 hops max, 60 byte packets
20200828 100622 1 * cswj-sh90-0001-vlan443.us.netdevices.ubs.net (10.33.7.1) 9.355 ms 8.397 ms
20200828 100622 2 cfwj-sh90-0011-itr1-t-t021-gibp-reth0-3022.us.netdevices.ubs.net (172.27.20.15) 0.366 ms 0.358 ms 0.334 ms
20200828 100622 3 cfwj-sh90-5013-gpa1-d-t232-dgpa-reth1-4007.us.netdevices.ubs.net (172.27.20.91) 0.780 ms 0.775 ms 0.796 ms
20200828 100622 4 172.27.20.76 (172.27.20.76) 3.283 ms 4.565 ms 5.849 ms
20200828 100623 5 172.27.21.200 (172.27.21.200) 1.689 ms 1.454 ms 1.519 ms
20200828 100623 6 100.65.0.13 (100.65.0.13) 13.971 ms 25.346 ms *
20200828 100623 7 * * *
20200828 100623 8 * * *
20200828 100623 9 * * *
20200828 100623 10 * * *
 


Don't think you're going to get it. The traceroute command does not support this and I can't think of a way to 'wrap' the command to get this. Their may be other commands that will do what traceroute does that support this, but I've never heard of one.

keith
 
I’m pretty certain this could be done.
You could pipe the output of traceroute to a function/routine, or perhaps even a loop - that will pre-pend a time-stamp to each line of output.

You could use the date command to generate the string for the time-stamp for each line of output.

Unfortunately, I’m on my phone atm and don’t have time to knock up an example.
 
You could use the date command to generate the string for the time-stamp for each line of output.

traceroute gogle.com
traceroute to gogle.com (x.x.x.x), 30 hops max, 60 byte packets
1 _gateway (x.x.x.x) 0.228 ms 25.259 ms 25.251 ms
2 x.x.x.x (96.120.60.33) 10.695 ms 16.875 ms 16.862 ms
3 xe-9-1-1-sur03.someplace.comcast.net (x.x.x.x) 16.985 ms 17.086 ms 17.002 ms
4 ae-2-rur02.anotherplace.comcast.net (x.x.x.x) 17.103 ms 17.199 ms 17.145 ms
5 ae-51-ar01.troutdale.or.bverton.comcast.net (68.87.216.105) 18.191 ms 24.917 ms 24.857 ms
6 be-33490-cr01.seattle.wa.ibone.comcast.net (68.86.92.217) 29.634 ms 17.819 ms 18.042 ms
7 be-2211-pe11.seattle.wa.ibone.comcast.net (96.110.32.230) 22.855 ms 22.910 ms 22.803 ms
8 50.208.232.246 (50.208.232.246) 22.690 ms 22.720 ms *
9 * 74.125.243.177 (74.125.243.177) 24.042 ms 29.979 ms
10 209.85.254.247 (209.85.254.247) 29.873 ms 29.913 ms 209.85.254.236 (209.85.254.236) 29.068 ms
11 sea30s02-in-f4.1e100.net (172.217.14.228) 28.930 ms 17.217 ms 23.363 ms

That is what I was thinking, a little hacky, but probably close enough.

AA=`date | cut -f5 -d' '`
BB=`traceroute google.com| cut -f12-13 -d' '`

Then loop through the values of BB and incrementally add them to AA.

The tricky part is the seconds. When the total value of the milliseconds exceeds 1000
add a second to your date. In an extreme case (it has happened) where this exceeds 60 seconds
you would have add a minute to your date.
 
Ah....well, I stand corrected, although making this work is very 'hacky'. You'll have fun calculating ms times and deciding on rounding and such. And there's the question of how actually accurate it will all be in the end. I guess you COULD get your date and time stamps though :cool:
Have fun....

keith
 

Members online


Top