Skip to content

Commit

Permalink
[http_load_] Use perldoc
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Mehani <shtrom@ssji.net>
  • Loading branch information
shtrom committed Jul 23, 2017
1 parent ece1c2b commit f4e73b8
Showing 1 changed file with 109 additions and 101 deletions.
210 changes: 109 additions & 101 deletions plugins/http/http_load_
Original file line number Diff line number Diff line change
@@ -1,106 +1,114 @@
#!/usr/bin/perl
# -*- perl -*-
#
# Plugin to graph http performance
# Version: 0.8.7
#
# The purpose of this plugin is to monitor several properties of a web page.
# All measurements are done for the complete web page, including images, css
# and other content a standard browser would download automatically.
#
# This version supports monitoring:
# * The total time to download a complete web page (using serial GET requests)
# * The total size of a web page
# * The different response codes (200, 404, 500, etc)
# * The different tags (img src, a href, etc)
# * The the different content types (image/png, text/css/, etc)
# * The number of elements the web page consists of
#
# Author: Espen Braastad / Linpro AS
# espen@linpro.no
# Olivier Mehani (multigraph support)
# shtrom+munin@ssji.net
#
##### Short usage guide: #####
#
# Requirements:
# * The server running this plugin must be allowed to connect to the web
# server(s) you are going to monitor.
# * Some perl modules:
# Time::HiRes, LWP::UserAgent, HTML::LinkExtor, LWP::ConnCache
#
# Initial configuration:
# 1. Copy this file to /usr/share/munin/plugins/
#
# 2. Create a file (/etc/munin/http_load_urls.txt) with one
# full url per line, as many as you want, i.e.:
# $ echo "http://www.dn.no/" >> /etc/munin/urls.txt
# $ echo "http://www.intrafish.no/" >> /etc/munin/urls.txt
#
# 3. Add a cron job running the plugin with cron as the argument:
# */15 * * * * <user> /usr/sbin/munin-run http_load_<site>_loadtime cron
# <user> should be the user that has write permission to the $cachedir
# directory set below. <site> should be any of the configured sites (all
# sites will get updated), likewise, you should replace loadtime by any
# metric that is enabled for that site (all metrics will get updated).
# Set the intervals to whatever you want.
#
# For verbose output (for debugging) you can do:
# sudo -u <user> /usr/share/munin/plugins/http_load_ cron verbose
#
# 4. Run munin-node-configure --suggest --shell and run the symlink
# commands manually to update the munin-node plugin list.xi
#
# (5. If you want to change the filter which the plugin uses to select which
# tags to follow in a web page, edit the subroutine called "filter" below.)
#
# Add a new url to monitor:
# 1. Add a new line in /etc/munin/urls.txt with the full URL, i.e.:
# $ echo "http://www.linpro.no/" >> /etc/munin/http_load_urls.txt
#
# 2. Run munin-node-configure --suggest --shell and manually
# add the new symlink(s)
#
# 3. /etc/init.d/munin-node restart
#
# Remove a url from monitoring:
# 1. Remove it from /etc/munin/http_load_urls.txt
#
# 2. Remove ${cachedir}/http_load_<url_id>*
#
# 3. Remove /etc/munin/plugins/http_load_<url_id>*
#
# 4. /etc/init.d/munin-node restart
#
# Single graph support
#
# The default behaviour is the multigraph mode: only the loadtime will be shown
# on the Munin summary page. The graphs there are linked to a second-level
# summary page that list all other metrics. It is also possible to create
# single graphs, that would show immediately on the summary page, by using
# symlinks with a different name, postfixed with the name of the metric:
# * http_load_hostname: multigraph (default)
# * http_load_hostname_loadtime: loadtime only
# * http_load_hostname_size: total page size
# * http_load_hostname_response: response code
# * http_load_hostname_tags: HTML tags summary
# * http_load_hostname_type: Content-Types
# * http_load_hostname_elements: source site of the loaded elements
#
# Note that hostname is not the FQDN of the host, but rather the one given when
# running munin-node-configure --suggest --shell and run the symlink
#
#####
#
# Todo:
# * Add support for forking to simulate real browsers
# * Use checksums as fieldnames
#
# $Id: $
#
# Magic markers:
#%# family=auto
#%# capabilities=autoconf suggest

=head1 NAME
http_load_ Munin multigraph plugin to monitor websites's HTTP responses and performance
=head1 DESCRIPTION
The purpose of this plugin is to monitor several properties of a web page.
All measurements are done for the complete web page, including images, css
and other content a standard browser would download automatically.
This version supports monitoring:
- loadtime: total time to download a complete web page (using serial GET requests)
- size: total size of a web page
- response: different response codes (200, 404, 500, etc)
- tags: HTML tags (img src, a href, etc)
- type: content types (image/png, text/css/, etc)
- elements: source of elements loaded by the web page
=head1 REQUIREMENTS
- The server running this plugin must be allowed to connect to the web
server(s) you are going to monitor.
- Some perl modules:
Time::HiRes, LWP::UserAgent, HTML::LinkExtor, LWP::ConnCache
=head1 CONFIGURATION
=head2 INITIAL SETUP
1. Copy this file to /usr/share/munin/plugins/
2. Create a file (/etc/munin/http_load_urls.txt) with one
full url per line, as many as you want, i.e.:
$ echo "http://www.dn.no/" >> /etc/munin/urls.txt
$ echo "http://www.intrafish.no/" >> /etc/munin/urls.txt
3. Add a cron job running the plugin with cron as the argument:
*/15 * * * * <user> /usr/sbin/munin-run http_load_<site>_loadtime cron
<user> should be the user that has write permission to the $cachedir
directory set below. <site> should be any of the configured sites (all
sites will get updated), likewise, you should replace loadtime by any
metric that is enabled for that site (all metrics will get updated).
Set the intervals to whatever you want.
For verbose output (for debugging) you can do:
sudo -u <user> /usr/share/munin/plugins/http_load_ cron verbose
4. Run munin-node-configure --suggest --shell and run the symlink
commands manually to update the munin-node plugin list.xi
5. If you want to change the filter which the plugin uses to select which
tags to follow in a web page, edit the subroutine called "filter" below.)
=head2 SPECIFY URLS TO MONITOR
1. Add a new line in /etc/munin/urls.txt with the full URL, i.e.:
$ echo "http://www.linpro.no/" >> /etc/munin/http_load_urls.txt
2. Run munin-node-configure --suggest --shell and manually
add the new symlink(s)
3. /etc/init.d/munin-node restart
=head2 REMOVE A URL
1. Remove it from /etc/munin/http_load_urls.txt
2. Remove ${cachedir}/http_load_<url_id>*
3. Remove /etc/munin/plugins/http_load_<url_id>*
4. /etc/init.d/munin-node restart
=head2 SINGLE GRAPH SUPPORT
The default behaviour is the multigraph mode: only the loadtime will be shown
on the Munin summary page. The graphs there are linked to a second-level
summary page that list all other metrics. It is also possible to create
single graphs, that would show immediately on the summary page, by using
symlinks with a different name, postfixed with the name of the metric:
- http_load_hostname: multigraph (default)
- http_load_hostname_loadtime: loadtime only
- http_load_hostname_size: total page size
- http_load_hostname_response: response code
- http_load_hostname_tags: HTML tags summary
- http_load_hostname_type: Content-Types
- http_load_hostname_elements: source site of the loaded elements
Note that hostname is not the FQDN of the host, but rather the one given when
running munin-node-configure --suggest --shell and run the symlink
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf suggest
=head1 TODO
- Specify URLs from a standard Munin plugins configuration file (e.g., env.urls)
- Add support for forking to simulate real browsers
=head1 AUTHORS
- Espen Braastad / Linpro AS <espen@linpro.no>, initial implementation
- Olivier Mehani <shtrom+munin@ssji.net>, multigraph support
=cut

use strict;
use Time::HiRes qw( gettimeofday tv_interval );
Expand Down

0 comments on commit f4e73b8

Please sign in to comment.