Projet

Général

Profil

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

root / plugins / php / php_errors_ @ aa3ee6dc

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

1
#!/bin/bash
2

    
3
: << =cut
4

    
5
=head1 NAME
6

    
7
php_errors - 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

    
16
=head1 AUTHOR
17

    
18
Copyright (C) 2011 Ulrich Lusseau
19

    
20
Copyright (C) 2016 Raphaël Droz <raphael.droz+floss@gmail.com>
21

    
22

    
23
=head1 MAGICK MARKERS
24

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

    
28
=cut
29

    
30

    
31
. $MUNIN_LIBDIR/plugins/plugin.sh
32

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

    
35

    
36
if [[ $1 == autoconf ]]; then
37
    for LOG in $LOGS; do
38
        if [[ ! -r $LOG ]]; then
39
            echo "no (cannot read '$LOG')"
40
            exit 0
41
        fi
42
    done
43

    
44
    echo yes
45
    exit 0
46
fi
47

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

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

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