Projet

Général

Profil

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

root / plugins / php / php_time_execution @ 17f78427

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

1 5b9a5884 metfan
#!/bin/sh
2
#
3
# Plugin to monitor execution time of PHP with access.log from apache server.
4
# Need to use apache module mod_log_config and have  set logformat like this:
5
# LogFormat "%h %l %u %T/%D %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" time_combined
6
#
7
# Min, Max and Avg are calculated on number of page, default 10. On high traffic site, increase this value and you get a better
8
# stat, on low traffic site keep small value, it's must be avg number of page every 5 minutes.
9
#
10
# Require read permitions for $LOG
11
#  (set in /etc/munin/plugin-conf.d/munin-node on debian)
12
# On busy servers you can change value type to COUNTER and set min to 0 to avoid minus peaks at logrotate
13
#
14
# $Log$
15
# Revision 0.1  2012/04/05 12:00:00  Ulrich Lusseau
16
# Initial revision
17
#
18
# Parameters:
19
#
20
#       config   (required)
21
#       autoconf (optional - used by munin-config)
22
#
23
# Magick markers (optional):
24
#%# family=auto
25
#%# capabilities=autoconf
26
#
27
# config example for /etc/munin/plugin-conf.d/munin-node
28
#[apache_generate_time]
29
#user root
30
#env.logfile /home/newsite/logs/access.log
31
#env.sitename mon-code
32
#env.nbrpage 10
33
#
34 17f78427 Lars Kruse
35 5b9a5884 metfan
LOG=${logfile:-/var/log/apache2/access.log}
36
NAME=${sitename:undefined}
37
NBRPAGE=${nbrpage}
38 17f78427 Lars Kruse
39
40 5b9a5884 metfan
if [ "$1" = "autoconf" ]; then
41
        if [ -r "$LOG" ]; then
42
                echo yes
43
                exit 0
44
        else
45
                echo no
46
                exit 1
47
        fi
48
fi
49 17f78427 Lars Kruse
50 5b9a5884 metfan
if [ "$1" = "config" ]; then
51 17f78427 Lars Kruse
52 5b9a5884 metfan
        echo 'graph_title Time to generate PHP page ' $NAME 'v2'
53
        echo 'graph_args --base 1000 -l 0'
54
        echo 'graph_vlabel Time in microsecond'
55 17f78427 Lars Kruse
56 65652aa0 dipohl
        echo "graph_category webserver"
57 5b9a5884 metfan
        echo "graph_info This graph shows load time in ms of $target"
58
        echo "minloadtime.label Min time"
59
        echo "minloadtime.info Min time"
60
        echo "avgloadtime.label Avg time"
61
        echo "avgloadtime.info Avg time"
62
        echo "maxloadtime.label Max time"
63
        echo "maxloadtime.info Max time"
64 17f78427 Lars Kruse
65 5b9a5884 metfan
        exit 0
66
fi
67 17f78427 Lars Kruse
68 5b9a5884 metfan
 awk '($4 ~ /[0-9]+\/[0-9]+/ && $8 !~ /\.(jpg|JPG|jpeg|JPEG|gif|GIF|png|PNG|txt|TXT|css|CSS|js|JS|zip|ZIP|bmp|BMP)$/)' $LOG     | sed -e :a -e '$q;N;'$NBRPAGE',$D;ba' | awk '{print $4}' | awk -F\/ ' MIN=="" || $2 < MIN {MIN=$2}  MAX=="" || $2 > MAX {MAX=$2}  {SUM += $2} END {print  "minloadtime.value ",MIN/1000,"\navgloadtime.value ",SUM/(NR*1000),"\nmaxloadtime.value ",MAX/1000}'