Script help for awk and timing commands
I am trying to do a DNS query and find out how long the query took. I'm currently using:
[root@as1 ~]# time dig yahoo.com
Which gives the following results:
; <<>> DiG 9.3.1 <<>> yahoo.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17255
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;yahoo.com. IN A
;; ANSWER SECTION:
yahoo.com. 258 IN A 216.109.112.135
yahoo.com. 258 IN A 66.94.234.13
;; Query time: 2 msec
;; SERVER: 216.55.144.5#53(216.55.144.5)
;; WHEN: Wed Dec 13 21:35:33 2006
;; MSG SIZE rcvd: 59
real 0m0.011s
user 0m0.008s
sys 0m0.004s
But the ONLY part I care about is the real time (0m0.011s). Even then, I'm really only concerned with the integer (0.011), since I'll be using this to compare against another number. You can probably see where I'm going with this. Anyway, I CAN write the data to a test file and grep it out, but am a little fuddled on how to go about it. Does anyone have any suggestions, or a better idea for this? I'm sure awk is what I want for this, but I'm not that awk-savvy.
Any help is greatly appreciated!
|