Skip to content

Instantly share code, notes, and snippets.

@canujohann
Last active October 15, 2015 08:24
Show Gist options
  • Save canujohann/406faf43d51e95e5e42b to your computer and use it in GitHub Desktop.
Save canujohann/406faf43d51e95e5e42b to your computer and use it in GitHub Desktop.
tomcat・apache:アクセス計測

tomcat・apache:アクセス計測

bashの基本コマンドで日付順でリストアップして、ユニックでまとめる:

awk '{print $4}' /your_log_file.log | cut -d: -f1 | sort | uniq -c | tr -d "["

crontabに入れて、自動的に送りましょう:

0 0 */5 * *   awk '{print $4}' /your_log_file.log | cut -d: -f1 | sort | uniq -c | tr -d "[" | mail -s "access for your site these 5 days" [email protected]

rogRotateの場合は適当にスクリプトを作ります ↓

#!/bin/bash
cd /var/logs/apache/
for f in `find . -name "your_file_pattern*"`
do
  number=`cat $f | wc -l`
  echo "$f : $n
done

専門じゃないので、いろいろ改善できると思いますが、今日はここまで・・

以上

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment