2016-03-24 02:33:22 +01:00
|
|
|
#!/bin/bash
|
2016-03-24 02:42:47 +01:00
|
|
|
|
|
|
|
: << =cut
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
Plugin to monitor error.log from apache server
|
|
|
|
|
|
|
|
=head1 CONFIGURATION
|
|
|
|
|
2016-04-04 18:17:51 +02:00
|
|
|
[php_errors_newsite]
|
2016-03-24 02:42:47 +01:00
|
|
|
user www-data
|
|
|
|
env.logfile /home/newsite/logs/errors.log /var/log/php/otherlog.log
|
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
Raphaël Droz <raphael.droz+floss@gmail.com>
|
|
|
|
|
|
|
|
Revision 0.2 2016/03/23 22:00:00 Raphaël Droz
|
|
|
|
Revision 0.1 2011/06/17 12:00:00 Ulrich Lusseau
|
|
|
|
|
|
|
|
=head1 MAGICK MARKERS
|
|
|
|
|
|
|
|
#%# family=auto
|
|
|
|
#%# capabilities=autoconf
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
|
|
. $MUNIN_LIBDIR/plugins/plugin.sh
|
|
|
|
|
2016-03-24 02:33:22 +01:00
|
|
|
LOGS=${logfile:-/var/log/apache2/error.log}
|
2013-11-14 23:09:44 +01:00
|
|
|
|
|
|
|
|
2016-03-24 02:42:47 +01:00
|
|
|
if [[ $1 == autoconf ]]; then
|
2016-03-24 02:33:22 +01:00
|
|
|
for LOG in $LOGS; do
|
|
|
|
if [[ ! -r $LOGS ]]; then
|
|
|
|
echo no
|
|
|
|
exit 1
|
2013-11-14 23:09:44 +01:00
|
|
|
fi
|
2016-03-24 02:33:22 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
echo yes
|
|
|
|
exit 0
|
2013-11-14 23:09:44 +01:00
|
|
|
fi
|
|
|
|
|
2016-03-24 02:42:47 +01:00
|
|
|
if [[ $1 == config ]]; then
|
2016-03-24 02:33:22 +01:00
|
|
|
echo 'graph_title PHP Errors from ' $LOGS
|
2013-11-14 23:09:44 +01:00
|
|
|
echo 'graph_args --base 1000 -l 0'
|
2017-02-21 18:24:41 +01:00
|
|
|
echo 'graph_category webserver'
|
2013-11-14 23:09:44 +01:00
|
|
|
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
|
2016-03-24 02:42:47 +01:00
|
|
|
|
|
|
|
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
|