処理時間を監視するmuninプラグイン

Apacheのアクセスログで処理時間を記録する

httpd.confを編集する。

 LogFormat "%t %D \"%r\"" exectime
 CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/www/exectime_log.%Y%m%d 86400 540" exectime

muninのプラグインを作成する

以下のファイルをmuninのpluginsディレクトリへ設置する。

 #!/bin/sh
 
 do_ () {
     logfile/var/log/www/exectime_log.$(date +%Y%m%d)
     buffer=1000
     command="tail -n $buffer $logfile | awk '{sum=sum+\$3} END {print \"exec_time.value \"(sum/$buffer)/1000000}'"
     eval $command
     exit 0
 }
 
 do_config () {
     echo "graph_title Average page execution time"
     echo "graph_vlabel Seconds"
     echo "graph_category apache"
     echo "graph_args --base 1000 -l 0"
     echo "graph_info Average page execution time"
 
     echo "exec_time.label Execution time"
     echo "exec_time.type GAUGE"
 }
 
 case $1 in
     config|'')
         eval do_$1
 esac
 
 exit $?

参考

http://returnfoo.com/2012/03/average-time-taken-to-serve-a-request-graph-in-munin-using-awk-and-apaches-access-logs/


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2013-02-06 (水) 05:27:21