root / plugins / php / php_errors_ @ aa3ee6dc
Historique | Voir | Annoter | Télécharger (1,41 ko)
| 1 | c3cf6b45 | Raphaël Droz | #!/bin/bash |
|---|---|---|---|
| 2 | c324c34e | Raphaël Droz | |
| 3 | : << =cut |
||
| 4 | |||
| 5 | =head1 NAME |
||
| 6 | |||
| 7 | aa3ee6dc | Lars Kruse | php_errors - Plugin to monitor error.log from apache server |
| 8 | c324c34e | Raphaël Droz | |
| 9 | =head1 CONFIGURATION |
||
| 10 | |||
| 11 | aa3ee6dc | Lars Kruse | [php_errors_newsite] |
| 12 | user www-data |
||
| 13 | env.logfile /home/newsite/logs/errors.log /var/log/php/otherlog.log |
||
| 14 | |||
| 15 | c324c34e | Raphaël Droz | |
| 16 | =head1 AUTHOR |
||
| 17 | |||
| 18 | aa3ee6dc | Lars Kruse | Copyright (C) 2011 Ulrich Lusseau |
| 19 | |||
| 20 | Copyright (C) 2016 Raphaël Droz <raphael.droz+floss@gmail.com> |
||
| 21 | c324c34e | Raphaël Droz | |
| 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 | c3cf6b45 | Raphaël Droz | LOGS=${logfile:-/var/log/apache2/error.log}
|
| 34 | 17f78427 | Lars Kruse | |
| 35 | |||
| 36 | c324c34e | Raphaël Droz | if [[ $1 == autoconf ]]; then |
| 37 | c3cf6b45 | Raphaël Droz | for LOG in $LOGS; do |
| 38 | 2ec4e4c1 | Lars Kruse | if [[ ! -r $LOG ]]; then |
| 39 | echo "no (cannot read '$LOG')" |
||
| 40 | exit 0 |
||
| 41 | 7f0db9e8 | metfan | fi |
| 42 | c3cf6b45 | Raphaël Droz | done |
| 43 | |||
| 44 | echo yes |
||
| 45 | exit 0 |
||
| 46 | 7f0db9e8 | metfan | fi |
| 47 | 17f78427 | Lars Kruse | |
| 48 | c324c34e | Raphaël Droz | if [[ $1 == config ]]; then |
| 49 | c3cf6b45 | Raphaël Droz | echo 'graph_title PHP Errors from ' $LOGS |
| 50 | 7f0db9e8 | metfan | echo 'graph_args --base 1000 -l 0' |
| 51 | b19b3a81 | dipohl | echo 'graph_category webserver' |
| 52 | 7f0db9e8 | metfan | 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 | c324c34e | Raphaël Droz | |
| 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 |
