Repository
Munin (contrib)
Last change
2020-10-04
Graph Categories
Family
auto
Capabilities
Keywords
Language
Bash
Authors

php_errors_

Name

php_errors - Plugin to monitor error.log from apache server

Configuration

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

Author

Copyright (C) 2011 Ulrich Lusseau

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

Magick Markers

#%# family=auto
#%# capabilities=autoconf
#!/bin/bash

: << =cut

=head1 NAME

php_errors - Plugin to monitor error.log from apache server

=head1 CONFIGURATION

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


=head1 AUTHOR

Copyright (C) 2011 Ulrich Lusseau

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


=head1 MAGICK MARKERS

 #%# family=auto
 #%# capabilities=autoconf

=cut


. $MUNIN_LIBDIR/plugins/plugin.sh

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


if [[ $1 == autoconf ]]; then
    for LOG in $LOGS; do
        if [[ ! -r $LOG ]]; then
            echo "no (cannot read '$LOG')"
            exit 0
        fi
    done

    echo yes
    exit 0
fi

if [[ $1 == config ]]; then
        echo 'graph_title PHP Errors from ' $LOGS
        echo 'graph_args --base 1000 -l 0'
        echo 'graph_category webserver'
        echo 'graph_vlabel Errors'
        echo 'LogWarning.label PHP Warning errors'
        echo 'LogNotice.label PHP Notice errors'
        echo 'LogFatal.label PHP Fatal errors'
        echo 'LogFile.label File does not exist errors'
        exit 0
fi

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

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