Ping + timestamp + selected response


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Ping + timestamp + selected response
# 1  
Old 11-29-2012
Ping + timestamp + selected response

Hello All,

i would like to start ping command and the result should contain also Timestate.

this i'm able to do with following command :
Code:
ping HOSTNAME | perl -nle 'print scalar(localtime), " ", $_'

or
Code:
ping HOSTNAME | awk '/time\=([0-9]+\.[0-9]{2}) ms /^[0-9]+ bytes from / { "date" | getline pong; close("date"); print pong":",$0; }'

but how can i select that it should write to file only responses where response time is bigger than for example 0.5ms.

everything under 0.5ms can be ignored.

Can you please help me Smilie

Thank you

Last edited by Scott; 11-29-2012 at 08:24 AM.. Reason: Please use code tags
# 2  
Old 11-29-2012
How about awk:-
Code:
ping -c 5 HOSTNAME | awk -F= 'NR>1 && /bytes/ { gsub("ms","",$NF); if($NF>0.5) print $0 } '

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Ping test sends mail when ping fails

help with bash script! im am working on this script to make sure my server will stay online, so i made this script.. HOSTS="192.168.138.155" COUNT=4 pingtest(){ for myhost in "$@" do ping -c "$COUNT" "$myhost" &&return 1 done return 0 } if pingtest $HOSTS #100% failed... (4 Replies)
Discussion started by: mort3924
4 Replies

2. Shell Programming and Scripting

AIX : Need to convert UNIX Timestamp to normal timestamp

Hello , I am working on AIX. I have to convert Unix timestamp to normal timestamp. Below is the file. The Unix timestamp will always be preceded by EFFECTIVE_TIME as first field as shown and there could be multiple EFFECTIVE_TIME in the file : 3.txt Contents of... (6 Replies)
Discussion started by: rahul2662
6 Replies

3. Shell Programming and Scripting

To check timestamp in logfile and display lines upto 3 hours before current timestamp

Hi Friends, I have the following logfile. Currently time in india is 07/31/2014 12:33:34 and i have the following content in logfile. I want to display only those entries which contain string 'Exception' within last 3 hours. In this case, it would be the last line only I can get the... (12 Replies)
Discussion started by: srkmish
12 Replies

4. Shell Programming and Scripting

Ping Response from the host name

Hi All, I have the requirement where am pinging the server and matching the IP address with the existing IP address. Below code is returning me the IP address and my requirement is i have to see that also whether it is pinging or not PING useipapd01 (172.22.32.87) 56(84) bytes of data. 64... (1 Reply)
Discussion started by: sharsour
1 Replies

5. UNIX for Dummies Questions & Answers

How to compare a file by its timestamp and store in a different location whenever timestamp changes?

Hi All, I am new to unix programming. I am trying for a requirement and the requirement goes like this..... I have a test folder. Which tracks log files. After certain time, the log file is getting overwritten by another file (randomly as the time interval is not periodic). I need to preserve... (2 Replies)
Discussion started by: mailsara
2 Replies

6. Solaris

Ping with timestamp

Hi, Is there any way to use a ping utility in Solaris with timestamp is printed? I've found a few tools on windows where we can ping with timestamp, but I'm not sure with Solaris. http://2.bp.blogspot.com/_AamnZyf3C_A/TUI_xKIJAYI/AAAAAAAAAbY/Izwlouf7vaQ/s1600/fping.png ... (4 Replies)
Discussion started by: type8code0
4 Replies

7. AIX

Ping response

:confused:Hi, In linux if ping to a system from a linux server it shows ping time=0.120ms how we can achive this in aix. i need this for a latency check. Thanks in advance. (5 Replies)
Discussion started by: vjm
5 Replies

8. Shell Programming and Scripting

trying to print selected fields of selected lines by AWK

I am trying to print 1st, 2nd, 13th and 14th fields of a file of line numbers from 29 to 10029. I dont know how to put this in one code. Currently I am removing the selected lines by awk 'NR==29,NR==10029' File1 > File2 and then doing awk '{print $1, $2, $13, $14}' File2 > File3 Can... (3 Replies)
Discussion started by: ananyob
3 Replies

9. Shell Programming and Scripting

testing ping response

Hi! I'm trying to create a script for seeing if a host is alive, and depending on the ammount of packet loss, send an mail+sms to warn if the host seems to be dead. The script i'm trying to use is: pinger () { ping_stat=`ping -c 4 host.name | grep loss | awk '{print $7}'` echo "Packet... (18 Replies)
Discussion started by: noratx
18 Replies
Login or Register to Ask a Question