-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzeitping.sh
30 lines (29 loc) · 981 Bytes
/
zeitping.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# Umsetzung von Sebastian Boenning
# Part of https://github.com/servidge/snowflakes
# Ping mit zeitstempel
echo "$(date +%Y-%m-%d_%T) | start Ping auf $1"
alttime=0
altttl=0
altseq=0
echo "Zeitstempel | Pingoutput | Zeitvarianz zu vorher | TTL Aenderung | Pingverlust zu vorherigem "
ping -A -n $1 | while read pong; do
if [[ $pong != *"icmp_seq="* ]]; then
echo $(date +%Y-%m-%d_%T) \| $pong
else
time=`echo $pong | cut -d":" -f2 | cut -d" " -f4 | cut -d"=" -f2`
ttl=`echo $pong | cut -d":" -f2 | cut -d" " -f3 | cut -d"=" -f2`
seq=`echo $pong | cut -d":" -f2 | cut -d" " -f2 | cut -d"=" -f2`
divtime=$( echo $time-$alttime | bc)
if [[ $divtime != *"-"* ]]; then
divtime="+$divtime"
fi
divttl=$((ttl-$altttl))
divseq=$((seq-$altseq-1))
#echo $(date +%Y-%m-%d_%T) \| $pong \| $time \| $ttl \| $seq \| $divtime \| $divttl \| $divseq
echo $(date +%Y-%m-%d_%T) \| $pong \| $divttl \| $divseq \| $divtime
alttime=$time
altttl=$ttl
altseq=$seq
fi
done