How to Setup HTTP Monitoring with the HttpMonitor ZenPack.

From SysAdminWiki

Jump to: navigation, search

Contents

Overview

Here is a tutorial which explains how to setup HTTP monitoring using the ZenPacks.zenoss.HttpMonitor-2.0.0 zenpack. The methods should be similar for older and future releases however.

Things to note: I assume you put your websites you want to monitor in the /Devices/Websites class path.

Procedure

  • 1. Download and install the ZenPack from here. If your not sure how to install a ZenPack yet follow this article.


  • 2. Once installed you will have a new datasource available to you called HttpMonitor. So lets start by creating a new template under the /Devices/Websites section.
    • Once under /Devices/Websites click on the Templates Tab. This is a list of templates currently associated with all the servers you put here. We are going to add a new one.
    • Click the drop down arrow next to Available Performance Templates and select Add New Template.
    • Name each monitor something unique. I went with HTTP Response Time.
    • Your new template should show up in the list. Click on it to go to the actual template itself.


  • 3. Next we are going to build the template.
    • Under Description put "Real time HTTP Monitor and Performance Graphs." Click Save.
    • Click the drop down menu next to Data Sources and select Add DataSource.
    • From the Add a New DataSource Box type the name Time_Size_http.
    • In the Type box choose HttpMonitor and hit OK.


  • 4. You should now be in Data Source properties. Here we will set the value of component to website.
    • So under Name it would be Time_Size_http in our case.
    • Source Type should be HttpMonitor.
    • Enabled should be True.
    • Component can be set to website.
    • Event Class should be set to /Status/Web.
    • Event Key can be blank.
    • Severity should be set accordingly. In my case its critical if it fails.
    • Timeout i left at 60 seconds.
    • Cycletime i left at 300 seconds.
    • Hostname: ${dev/id} (can also be a domain name)
    • IP Address: ${dev/manageIp} (can also be a real IP)
    • Rest be left as is.
    • Click Save. Notice you now have new datapoints called 'time' and 'size' below under datapoints.



  • 5. Next we will want to go back to the Template Overview page. Easiest way to do this is look above the Data Source tab and you will see your current path. Next we are going to setup the graphs for the response time.
    • Click on Add Graph from the drop down menu next to Graphs.
    • Name the graph: Website Response Time and Size
    • On the Graph Definitions tab click the drop down next to Graph Points and select Add DataPoint.
    • If you did the above steps correctly you will see a point for each datasource defined. Click the appropiate ones. In our case http_size_size and http_size_time. Select it and hit ok. If you have more points add them the same way. Mine has a total of 4 points, one for each website tested.
    • Under units set it to 's' for seconds.


  • 6. Ok so thats about all you need to do get the realtime monitoring and graphing working for HTTP. Setting thresholds is not covered where they will be specific for your needs. All you need to do now is apply the template to whatever device you want this to run on. This is done by navigating to your device, and clicking on the drop down next to Status. Then click More -> Templates.


  • 7. Click the drop down next to Performance Templates and click Add Template.
    • Type in HTTP Response Time and hit OK. Note Substitute name if needed.


  • 8. Wait some time check out the perf tab of your device for the graphs.


Troubleshooting

  • You see an error somewhere along the lines:
Command timed out on device mail.net: 
/usr/local/zenoss/zenoss/../common/libexec/check_http -H <hostname> -I <ipaddy> -p 80 -t 60 -u /<subfolderifyouhaveone> -f follow

Or from the command line:

CRITICAL - Socket timeout after 60 seconds

I've noticed this to happen when monitoring SSL sites. What you need to do is do a custom Command data source and add the following in the Command Template (fill out the other values of course):

/usr/local/zenoss/common/libexec/check_http --ssl -H <hostname> -I <ipaddy> -p 443 -t 60 -u /<subfolderifyouhaveone>

Here is an example of how it should roughly look:

Image:httpmonitorexample.jpg

check_http --help

  • # ./check_http --help | more
check_http (nagios-plugins 1.4.5) 1.96
Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>
Copyright (c) 1999-2006 Nagios Plugin Development Team
        <nagiosplug-devel@lists.sourceforge.net>

This plugin tests the HTTP service on the specified host. It can test
normal (http) and secure (https) servers, follow redirects, search for
strings and regular expressions, check connection times, and report on
certificate expiration times.


Usage: check_http -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]
       [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]
       [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]
       [-s string] [-l] [-r <regex> | -R <case-insensitive regex>] [-P string]
       [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>] [-A string] [-k string]
NOTE: One or both of -H and -I must be specified

Options:
 -h, --help
    Print detailed help screen
 -V, --version
    Print version information
 -H, --hostname=ADDRESS
    Host name argument for servers using host headers (virtual host)
    Append a port to include it in the header (eg: example.com:5000)
 -I, --IP-address=ADDRESS
    IP address or name (use numeric address if possible to bypass DNS lookup).
 -p, --port=INTEGER
 Port number (default: 80)
 -4, --use-ipv4
    Use IPv4 connection
 -6, --use-ipv6
    Use IPv6 connection
 -S, --ssl
   Connect via SSL
 -C, --certificate=INTEGER
   Minimum number of days a certificate has to be valid.
   (when this option is used the url is not checked.)
 -e, --expect=STRING
    String to expect in first (status) line of server response (default:
HTTP/1.
    If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)
 -s, --string=STRING
    String to expect in the content
 -u, --url=PATH
    URL to GET or POST (default: /)


,-P, --post=STRING    URL encoded http POST data
 -N, --no-body
    Don't wait for document body: stop reading after headers.
    (Note that this still does an HTTP GET or POST, not a HEAD.)
 -M, --max-age=SECONDS
    Warn if document is more than SECONDS old. the number can also be of
    the form "10m" for minutes, "10h" for hours, or "10d" for days.
 -T, --content-type=STRING
    specify Content-Type header media type when POSTing

 -l, --linespan
    Allow regex to span newlines (must precede -r or -R)
 -r, --regex, --ereg=STRING
    Search page for regex STRING
 -R, --eregi=STRING
    Search page for case-insensitive regex STRING
 --invert-regex
    Return CRITICAL if found, OK if not

 -a, --authorization=AUTH_PAIR
    Username:password on sites with basic authentication
 -A, --useragent=STRING
    String to be sent in http header as "User Agent"
 -k, --header=STRING
     Any other tags to be sent in http header. Use multiple times for additional headers
 -L, --link=URL
    Wrap output in HTML link (obsoleted by urlize)
 -f, --onredirect=<ok|warning|critical|follow>
    How to handle redirected pages
 -m, --pagesize=INTEGER<:INTEGER>
    Minimum page size required (bytes) : Maximum page size required (bytes)
 -w, --warning=DOUBLE
    Response time to result in warning status (seconds)
 -c, --critical=DOUBLE
    Response time to result in critical status (seconds)
 -t, --timeout=INTEGER
    Seconds before connection times out (default: 10)
 -v, --verbose
    Show details for command-line debugging (Nagios may truncate output)
Notes: This plugin will attempt to open an HTTP connection with the host.
 Successful connects return STATE_OK, refusals and timeouts return STATE_CRITICAL
 other errors return STATE_UNKNOWN.  Successful connects, but incorrect reponse
 messages from the host result in STATE_WARNING return values.  If you are
 checking a virtual server that uses 'host headers' you must supply the FQDN
 (fully qualified domain name) as the [host_name] argument.
 This plugin can also check whether an SSL enabled web server is able to
 serve content (optionally within a specified time) or whether the X509
 certificate is still valid for the specified number of days.
Examples: CHECK CONTENT: check_http -w 5 -c 10 --ssl www.verisign.com

 When the 'www.verisign.com' server returns its content within 5 seconds,
 a STATE_OK will be returned. When the server returns its content but exceeds
 the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,
 a STATE_CRITICAL will be returned.

 CHECK CERTIFICATE: check_http www.verisign.com -C 14

 When the certificate of 'www.verisign.com' is valid for more than 14 days,
 a STATE_OK is returned. When the certificate is still valid, but for less than
 14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when
 the certificate is expired.


Send email to nagios-users@lists.sourceforge.net if you have questions
regarding use of this software. To submit patches or suggest improvements,
send email to nagiosplug-devel@lists.sourceforge.net

Advertisement