Nagios XI Website URL and Transaction Monitoring

Nagios XI Website URL and Transaction Monitoring

Nagios XI comes with a number of plugins two of which can be used to perform website url and transaction monitoring. The first is check_http which is the traditional one most Nagios Core users are familiar with. The second is WebInject which can be used to perform a number of tests in sequence. check_http will beused to monitor tarket URLs and WebInject will be used to perform "transactions" such as, in the case of an ecommerce site, browsing categories and adding items to a shopping cart. This article will explain how to setup batches of URL monitors as well as custom HTTP transaction monitors. This guide will show you how to implement a quality web monitoring solution, based on Nagios XI, which can rival enterprise-grade solutions such as Gomez and HP SiteScope in terms of features, flexibility, robustness, and ease of maintenance.

Configuring Batches of URL Monitors

#!/bin/bash
# $1 - The FQDN of the monitored target
# $2 - The lower bound on the node id range
# $3 - The upper bound on the node id range
# $4 - The Data Center codename (optional)
#
# Usage: setup_web_monitors.sh origin-www.sephora.com 10 56 VZB > import/origin-www.sephora.com.cfg

function print_usage()
{
  printf "Usage: setup_web_monitors.sh origin-www.sephora.com 10 56 VZB > import/origin-www.sephora.com.cfg\n"
  printf '  $1 - The FQDN of the monitored target\n'
  printf '  $2 - The lower bound on the node id range\n'
  printf '  $2 - The upper bound on the node id range\n'
  printf '  $4 - The Data Center codename (optional)\n'
}

argc=$#

if [[ $argc -lt 3 || $argc -gt 4 ]]; then
  printf "Invalid invocation. Supply the necessary arguments.\n"
  print_usage
  exit 1
fi

HOSTNAME=$1
shift

LOWER=$1
shift

UPPER=$1
shift

if ! [[ -z $1 ]]; then
  DATACENTER=$1
fi

IPV4ADDR=$(nslookup $HOSTNAME | grep -v '#53' | awk '/Address:/{print $2}')

cat << EOF
define host {
        host_name                   ${HOSTNAME}
        use                         xiwizard_website_host
        address                             ${HOSTNAME}
        max_check_attempts          5
        check_interval                      5
        retry_interval                      1
        check_period                        xi_timeperiod_24x7
        contacts                    nagiosadmin
        notification_interval               60
        notification_period         xi_timeperiod_24x7
        icon_image                  www_server.png
        statusmap_image                     www_server.png
        _xiwizard                   websiteurl
        register                    1
}

define service {
        host_name                       ${HOSTNAME}
        service_description             ${DATACENTER} Origin Main Website URL Status
        use                             xiwizard_website_http_service
        check_command                   check_xi_service_http! -I ${IPV4ADDR} -c 5 -w 10 -f follow -H ${HOSTNAME} -u '/' -p 80
        max_check_attempts              5
        check_interval                  5
        retry_interval                  1
        check_period                    xi_timeperiod_24x7
        notification_interval           60
        notification_period             xi_timeperiod_24x7
        contacts                        nagiosadmin
        _xiwizard                       websiteurl
        register                        1
}
EOF

for i in $(seq $LOWER $UPPER); do
        cat << EOF
define service {
        host_name                       ${HOSTNAME}
        service_description             ${DATACENTER} Origin Node${i} Homepage URL Status
        use                             xiwizard_website_http_service
        check_command                   check_xi_service_http! -I ${IPV4ADDR} -c 5 -w 10 -f follow -H ${HOSTNAME} -u '/\$USER9\$jessionid=.node${i}' -p 80
        max_check_attempts              5
        check_interval                  5
        retry_interval                  1
        check_period                    xi_timeperiod_24x7
        notification_interval           60
        notification_period             xi_timeperiod_24x7
        contacts                        nagiosadmin
        _xiwizard                       websiteurl
        register                        1
}

EOF
done

# vim: ts=8 sw=8 noexpandtab autoindent