Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / apache / page_load @ 17f78427

Historique | Voir | Annoter | Télécharger (2,09 ko)

1
#!/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
#
26
#		According to : http://httpd.apache.org/docs/2.2/mod/mod_log_config.html
27
#		%D 	The time taken to serve the request, in microseconds.
28
#		In our case %D -> 9
29
######################################################################################################
30
#	GLOBALS
31
LOGFILE="/var/log/apache2/access.log"
32
BUFFER_SIZE=500
33

    
34
######################################################################################################
35

    
36

    
37
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

    
43
do_config () {
44
    echo "graph_title Average page execution time"
45
    echo "graph_vlabel Seconds"
46
    echo "graph_category webserver"
47
    echo "graph_args --base 1000 -l 0"
48
    echo "graph_info Average page execution time"
49

    
50
    echo "exec_time.label Execution time"
51
    echo "exec_time.type GAUGE"
52
}
53

    
54
case $1 in
55
    config|'')
56
	eval do_$1
57
esac
58

    
59
exit $?