root / plugins / apache / page_load @ 17f78427
Historique | Voir | Annoter | Télécharger (2,09 ko)
| 1 | 1d2ba324 | Alexandru Iacob | #!/bin/sh |
|---|---|---|---|
| 2 | |||
| 3 | # Copyright (C) 2013 Alexandru Iacob |
||
| 4 | # |
||
| 5 | # This program is free software; you can redistribute it and/or modify |
||
| 6 | # it under the terms of the GNU General Public License as published by |
||
| 7 | # the Free Software Foundation; either version 2 of the License, or |
||
| 8 | # (at your option) any later version. |
||
| 9 | # |
||
| 10 | # This program is distributed in the hope that it will be useful, |
||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | # GNU General Public License for more details. |
||
| 14 | # |
||
| 15 | # You should have received a copy of the GNU General Public License along |
||
| 16 | # with this program; if not, write to the Free Software Foundation, Inc., |
||
| 17 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
| 18 | ###################################################################################################### |
||
| 19 | # The plugin will generate a graph that displays the page load time |
||
| 20 | # We need to add our custom log format into Apache config. |
||
| 21 | # The plugin was tested on Ubuntu Server 12.04.02 LTS |
||
| 22 | # |
||
| 23 | # apache2.conf |
||
| 24 | # LogFormat "%h %l %u %t \"%r\" %>s %O %b %D \"%{Referer}i\" \"%{User-Agent}i\"" custom
|
||
| 25 | 17f78427 | Lars Kruse | # |
| 26 | fba800ae | Veres Lajos | # According to : http://httpd.apache.org/docs/2.2/mod/mod_log_config.html |
| 27 | 1d2ba324 | Alexandru Iacob | # %D The time taken to serve the request, in microseconds. |
| 28 | # In our case %D -> 9 |
||
| 29 | 17f78427 | Lars Kruse | ###################################################################################################### |
| 30 | 1d2ba324 | Alexandru Iacob | # GLOBALS |
| 31 | LOGFILE="/var/log/apache2/access.log" |
||
| 32 | BUFFER_SIZE=500 |
||
| 33 | |||
| 34 | ###################################################################################################### |
||
| 35 | |||
| 36 | 17f78427 | Lars Kruse | |
| 37 | 1d2ba324 | Alexandru Iacob | do_ () {
|
| 38 | command="tail -n $BUFFER_SIZE $LOGFILE | awk '{sum=sum+\$9} END {print \"exec_time.value \"(sum/$BUFFER_SIZE)/1000000}'"
|
||
| 39 | eval $command |
||
| 40 | exit 0 |
||
| 41 | } |
||
| 42 | 17f78427 | Lars Kruse | |
| 43 | 1d2ba324 | Alexandru Iacob | do_config () {
|
| 44 | echo "graph_title Average page execution time" |
||
| 45 | echo "graph_vlabel Seconds" |
||
| 46 | 3c98d069 | dipohl | echo "graph_category webserver" |
| 47 | 1d2ba324 | Alexandru Iacob | echo "graph_args --base 1000 -l 0" |
| 48 | echo "graph_info Average page execution time" |
||
| 49 | 17f78427 | Lars Kruse | |
| 50 | 1d2ba324 | Alexandru Iacob | echo "exec_time.label Execution time" |
| 51 | echo "exec_time.type GAUGE" |
||
| 52 | } |
||
| 53 | 17f78427 | Lars Kruse | |
| 54 | 1d2ba324 | Alexandru Iacob | case $1 in |
| 55 | config|'') |
||
| 56 | eval do_$1 |
||
| 57 | esac |
||
| 58 | 17f78427 | Lars Kruse | |
| 59 | 3c98d069 | dipohl | exit $? |
