Projet

Général

Profil

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

root / plugins / php / php_errors_ @ 17f78427

Historique | Voir | Annoter | Télécharger (1,41 ko)

1
#!/bin/bash
2

    
3
: << =cut
4

    
5
=head1 NAME
6

    
7
Plugin to monitor error.log from apache server
8

    
9
=head1 CONFIGURATION
10

    
11
[php_errors_newsite]
12
	user www-data
13
	env.logfile /home/newsite/logs/errors.log /var/log/php/otherlog.log
14

    
15
=head1 AUTHOR
16

    
17
Raphaël Droz <raphael.droz+floss@gmail.com>
18

    
19
Revision 0.2  2016/03/23 22:00:00  Raphaël Droz
20
Revision 0.1  2011/06/17 12:00:00  Ulrich Lusseau
21

    
22
=head1 MAGICK MARKERS
23

    
24
 #%# family=auto
25
 #%# capabilities=autoconf
26

    
27
=cut
28

    
29

    
30
. $MUNIN_LIBDIR/plugins/plugin.sh
31

    
32
LOGS=${logfile:-/var/log/apache2/error.log}
33

    
34

    
35
if [[ $1 == autoconf ]]; then
36
    for LOG in $LOGS; do
37
	if [[ ! -r $LOGS ]]; then
38
            echo no
39
            exit 1
40
        fi
41
    done
42

    
43
    echo yes
44
    exit 0
45
fi
46

    
47
if [[ $1 == config ]]; then
48
        echo 'graph_title PHP Errors from ' $LOGS
49
        echo 'graph_args --base 1000 -l 0'
50
        echo 'graph_category webserver'
51
        echo 'graph_vlabel Errors'
52
        echo 'LogWarning.label PHP Warning errors'
53
        echo 'LogNotice.label PHP Notice errors'
54
        echo 'LogFatal.label PHP Fatal errors'
55
        echo 'LogFile.label File does not exist errors'
56
        exit 0
57
fi
58

    
59
awk -f - $LOGS <<EOF
60
BEGIN { c["LogWarning"]=0; c["LogNotice"]=0; c["LogFatal"]=0; c["LogFile"]=0; }
61
/PHP Warning/{         c["LogWarning"]++ }
62
/PHP Notice/{          c["LogNotice"]++  }
63
/PHP Fatal error/{     c["LogFatal"]++   }
64
/File does not exist/{ c["LogFile"]++    }
65

    
66
END{ for(i in c) { print i".value " c[i] } }
67
EOF