Skip to main content Logo

Quis custodiet ipsos custodes?
Home | About | All pages | Cluster Status | RSS Feed | Gopher

tping - ping with a timestamp

Published: 03-09-2018 | Author: Remy van Elst | Text only version of this article

❗ This post is over three years old. It may no longer be up to date. Opinions may have changed.

Table of Contents

tping is a bash alias I once got from an old co-worker. It's ping, but with a timestamp. Instead of looking at the increased icmp_seq number you now have a timestamp. Here's how it looks like:

$ tping
09:31:55: PING ( 56(84) bytes of data.
09:31:55: 64 bytes from ( icmp_seq=30 ttl=63 time=0.399 ms
09:31:56: 64 bytes from ( icmp_seq=31 ttl=63 time=0.530 ms
09:31:57: 64 bytes from ( icmp_seq=32 ttl=63 time=0.412 ms
09:31:58: 64 bytes from ( icmp_seq=33 ttl=63 time=0.469 ms
09:31:59: 64 bytes from ( icmp_seq=34 ttl=63 time=0.383 ms
09:32:00: 64 bytes from ( icmp_seq=35 ttl=63 time=0.402 ms
09:32:01: 64 bytes from ( icmp_seq=36 ttl=63 time=0.483 ms
09:32:02: 64 bytes from ( icmp_seq=37 ttl=63 time=0.409 ms
09:32:03: 64 bytes from ( icmp_seq=38 ttl=63 time=0.346 ms

09:36:20: 64 bytes from ( icmp_seq=289 ttl=63 time=1.51 ms
09:36:21: 64 bytes from ( icmp_seq=290 ttl=63 time=0.474 ms
09:36:22: 64 bytes from ( icmp_seq=291 ttl=63 time=0.698 ms
09:36:23: 64 bytes from ( icmp_seq=292 ttl=63 time=0.483 ms
09:36:24: 64 bytes from ( icmp_seq=293 ttl=63 time=0.482 ms
09:36:25: 64 bytes from ( icmp_seq=294 ttl=63 time=0.619 ms
09:36:26: 64 bytes from ( icmp_seq=295 ttl=63 time=0.498 ms
09:36:27: 64 bytes from ( icmp_seq=296 ttl=63 time=0.491 ms

The host went down on 09:32 and was back up on 09:36. This was a scheduled reboot.

Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.

You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $100 credit for 60 days.

.bashrc function

The shell code for in your .bashrc file:

tping() {
    ping $@ | while read pong; do 
        echo "$(date +"%T"): $pong"; 
alias tping=tping

Start a new shell our source .bashrc after you added this function.


Another tool to get more visual information from ping is prettyping. It's open source on github and looks like this:

The red exclamation marks in the image represent a reboot of that server.

Tags: bash , monitoring , ping , shell , snippets , tping