2013-02-20 17:29:21 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Copyright (C) 2013 Alexandru Iacob
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
######################################################################################################
|
|
|
|
# The plugin will generate a graph that displays the page load time
|
|
|
|
# We need to add our custom log format into Apache config.
|
|
|
|
# The plugin was tested on Ubuntu Server 12.04.02 LTS
|
|
|
|
#
|
|
|
|
# apache2.conf
|
|
|
|
# LogFormat "%h %l %u %t \"%r\" %>s %O %b %D \"%{Referer}i\" \"%{User-Agent}i\"" custom
|
2018-08-02 02:03:42 +02:00
|
|
|
#
|
2014-12-05 00:37:42 +01:00
|
|
|
# According to : http://httpd.apache.org/docs/2.2/mod/mod_log_config.html
|
2013-02-20 17:29:21 +01:00
|
|
|
# %D The time taken to serve the request, in microseconds.
|
|
|
|
# In our case %D -> 9
|
2018-08-02 02:03:42 +02:00
|
|
|
######################################################################################################
|
2013-02-20 17:29:21 +01:00
|
|
|
# GLOBALS
|
|
|
|
LOGFILE="/var/log/apache2/access.log"
|
|
|
|
BUFFER_SIZE=500
|
|
|
|
|
|
|
|
######################################################################################################
|
|
|
|
|
2018-08-02 02:03:42 +02:00
|
|
|
|
2013-02-20 17:29:21 +01:00
|
|
|
do_ () {
|
|
|
|
command="tail -n $BUFFER_SIZE $LOGFILE | awk '{sum=sum+\$9} END {print \"exec_time.value \"(sum/$BUFFER_SIZE)/1000000}'"
|
|
|
|
eval $command
|
|
|
|
exit 0
|
|
|
|
}
|
2018-08-02 02:03:42 +02:00
|
|
|
|
2013-02-20 17:29:21 +01:00
|
|
|
do_config () {
|
|
|
|
echo "graph_title Average page execution time"
|
|
|
|
echo "graph_vlabel Seconds"
|
2017-02-21 17:11:23 +01:00
|
|
|
echo "graph_category webserver"
|
2013-02-20 17:29:21 +01:00
|
|
|
echo "graph_args --base 1000 -l 0"
|
|
|
|
echo "graph_info Average page execution time"
|
2018-08-02 02:03:42 +02:00
|
|
|
|
2013-02-20 17:29:21 +01:00
|
|
|
echo "exec_time.label Execution time"
|
|
|
|
echo "exec_time.type GAUGE"
|
|
|
|
}
|
2018-08-02 02:03:42 +02:00
|
|
|
|
2013-02-20 17:29:21 +01:00
|
|
|
case $1 in
|
|
|
|
config|'')
|
|
|
|
eval do_$1
|
|
|
|
esac
|
2018-08-02 02:03:42 +02:00
|
|
|
|
2017-02-21 17:11:23 +01:00
|
|
|
exit $?
|