Webサーバのrpsを出力する

ApacheとかNginxとかで、簡易的にスループットを知りたいときによく使うawkスクリプト。

tail -f /var/log/httpd/access_log | awk 'BEGIN{N=10000; p=systime()} {n++; t=systime(); if(n % N == 0) {printf "%s | %s\n", strftime("%X"), N / (t - p); p = t} }'


15:15:29 | 1250
15:15:36 | 1428.57
15:15:43 | 1428.57
15:15:50 | 1428.57
15:15:58 | 1250
15:16:05 | 1428.57
15:16:12 | 1428.57