@@ -60,44 +60,44 @@ Advanced Examples
6060
6161* read from STDIN and print out the length of each line _ (to illustrate -e option)_
6262
63- $ ntail -e '{ |line| puts line. size } '
63+ $ ntail -e 'puts size'
6464
6565* read from STDIN but only print out non-empty lines _ (to illustrate -f option)_
6666
67- $ ntail -f '{ |line| line. size $ 0 } '
67+ $ ntail -f 'size != 0 '
6868
6969* the following invocations behave exactly the same _ (to illustrate -e and -f options)_
7070
7171 $ ntail
72- $ ntail -f '{ |line| true } ' -e '{ |line| puts line } '
72+ $ ntail -f 'true' -e 'puts self '
7373
7474* print out all HTTP requests that are coming from a given IP address
7575
76- $ ntail -f '{ |line| line. remote_address == "208.67.222.222" } ' /var/log/nginx/access.log
76+ $ ntail -f 'remote_address == "208.67.222.222"' /var/log/nginx/access.log
7777
7878* find all HTTP requests that resulted in a '5xx' HTTP error/status code _ (e.g. Rails 500 errors)_
7979
80- $ gunzip -S .gz -c access.log-20101216.gz | ntail -f '{ |line| line. server_error_status? } '
80+ $ gunzip -S .gz -c access.log-20101216.gz | ntail -f 'server_error_status?'
8181
8282* generate a summary report of HTTP status codes, for all non-200 HTTP requests
8383
84- $ ntail -f '{ |line| line. status != "200" } ' -e '{ |line| puts line. status } ' access.log | sort | uniq -c
84+ $ ntail -f 'status != "200"' -e 'puts status' access.log | sort | uniq -c
8585 76 301
8686 16 302
8787 2 304
8888 1 406
8989
9090* print out GeoIP country and city information for each HTTP request _ (depends on the optional ` geoip ` gem)_
9191
92- $ ntail -e '{ |line| puts [line. to_country_s, line. to_city_s].join("\t") } ' /var/log/nginx/access.log
92+ $ ntail -e 'puts [to_country_s, to_city_s].join("\t")' /var/log/nginx/access.log
9393 United States Los Angeles
9494 United States Houston
9595 Germany Berlin
9696 United Kingdom London
9797
9898* print out the IP address and the corresponding host name for each HTTP request _ (slows things down considerably, due to ` nslookup ` call)_
9999
100- $ ntail -e '{ |line| puts [line. remote_address, line.to_host_name ].join("\t") } ' /var/log/nginx/access.log
100+ $ ntail -e 'puts [remote_address, to_host_s ].join("\t")' /var/log/nginx/access.log
101101 66.249.72.196 crawl-66-249-72-196.googlebot.com
102102 67.192.120.134 s402.pingdom.com
103103 75.31.109.144 adsl-75-31-109-144.dsl.irvnca.sbcglobal.net
0 commit comments