1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 14:16:00 +00:00

php_errors: coding-style/bash

This commit is contained in:
Raphaël Droz 2016-03-23 22:42:47 -03:00
parent c3cf6b45d3
commit c324c34ea7

View file

@ -1,28 +1,38 @@
#!/bin/bash #!/bin/bash
#
# Plugin to monitor error.log from apache server. : << =cut
# Revision 0.1 2011/06/17 12:00:00 Ulrich Lusseau
# Initial revision =head1 NAME
#
# Parameters: Plugin to monitor error.log from apache server
#
# config (required) =head1 CONFIGURATION
# autoconf (optional - used by munin-config)
# [apache_log]
# Magick markers (optional): 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 #%# family=auto
#%# capabilities=autoconf #%# capabilities=autoconf
# config example for /etc/munin/plugin-conf.d/munin-node
#[apache_log]
#user www-data
#env.logfile /home/newsite/logs/errors.log /var/log/php/otherlog.log
#
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
LOGS=${logfile:-/var/log/apache2/error.log} LOGS=${logfile:-/var/log/apache2/error.log}
if [ "$1" = "autoconf" ]; then if [[ $1 == autoconf ]]; then
for LOG in $LOGS; do for LOG in $LOGS; do
if [[ ! -r $LOGS ]]; then if [[ ! -r $LOGS ]]; then
echo no echo no
@ -34,7 +44,7 @@ if [ "$1" = "autoconf" ]; then
exit 0 exit 0
fi fi
if [ "$1" = "config" ]; then if [[ $1 == config ]]; then
echo 'graph_title PHP Errors from ' $LOGS echo 'graph_title PHP Errors from ' $LOGS
echo 'graph_args --base 1000 -l 0' echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel Errors' echo 'graph_vlabel Errors'
@ -45,9 +55,12 @@ if [ "$1" = "config" ]; then
exit 0 exit 0
fi fi
awk 'BEGIN{c["LogWarning"]=0;c["LogNotice"]=0;c["LogFatal"]=0;c["LogFile"]=0; } awk -f - $LOGS <<EOF
BEGIN { c["LogWarning"]=0; c["LogNotice"]=0; c["LogFatal"]=0; c["LogFile"]=0; }
/PHP Warning/{ c["LogWarning"]++ } /PHP Warning/{ c["LogWarning"]++ }
/PHP Notice/{ c["LogNotice"]++ } /PHP Notice/{ c["LogNotice"]++ }
/PHP Fatal error/{ c["LogFatal"]++ } /PHP Fatal error/{ c["LogFatal"]++ }
/File does not exist/{ c["LogFile"]++ } /File does not exist/{ c["LogFile"]++ }
END{for(i in c){print i".value " c[i]} }' $LOGS
END{ for(i in c) { print i".value " c[i] } }
EOF