# ---------------------------------------------------------------
# realhttp
# ---------------------------------------------------------------
#
# ---------------------------------------------------------------
# DESCRIPTION:
# ---------------------------------------------------------------
#
# This module is used to execute an HTTP request for a specified
# URL.  It utilizes the LWP libraries so it can support HTTPS
# if the Crypt/SSLeay libraries have been installed on your 
# system.
#
# A query is considered successfull if LWP reports success.  There
# is no method currently implemented to check that the page
# returned is what would be expected.
#
# ---------------------------------------------------------------
# NOTES:
# ---------------------------------------------------------------
#
# When specifying the URL to retrieve in $BSHOME/adm/uxmon-net,
# be certain to replace all instances of the colon character (:)
# with a carat (^).  This is neccessary as Big Sister currently
# massages any parameters with colons present.  The carat symbol
# was chosen as I haven't seen many URLs with them present.
# (This shouldn't be necessary any more but has been kept for
# compatibility reasons - Tom)
#
# Both the "greppos" and "grepneg" arguments can be specified.
#
# Use at your own risk, no warranty, blah blah blah.
#
#                                               Kevin O'Donnell
#                                              January 20, 2000
#                                         Vancouver, BC, Canada
#                                      kevin_odonnell@telus.net
#
# ---------------------------------------------------------------
# PARAMETERS:
# ---------------------------------------------------------------
#
#   url     The url to retrieve.  Note that all instances of the 
#           colon character (:) must be replaced with the carat
#           symbol (^).
#   item    The item to report this test as.  Defaults to 'http'.
#   greppos A regular expression which should be found in the
#           contents returned from the server.  
#   grepneg A regular expression which should *NOT* be found in
#           the contents returned from the server.
#   user    A username to supply in basic authentication
#   pass    A password to supply in basic authentication
#    
#
# ---------------------------------------------------------------
# EXAMPLE:
# ---------------------------------------------------------------
#
# Sample entry from $BSHOME/adm/uxmon-net
#
# localhost \
#     url=http^//www.mybc.com realhhtp \
#     url=http^//www.mybc.com/cgi-bin/mycgi item=cgi realhhtp \
#     url=https^//secure.mybc.com:447/index.html item=secure \
#        realhttp \
#     url=http^//127.0.0.1/index.html greppos=success realhttp \
#     url=http^//127.0.0.1/t.html grepneg=test realhttp \
#
# ---------------------------------------------------------------

# Load the monitor
my $realhttp;
unless( $realhttp = $memory{"realhttp"} ) {
    &uxmon::load_module( "realhttp" );
    &uxmon::checker(
        $memory{"realhttp"} = $realhttp = Monitor::realhttp->new()
    );
}

uxmon::test_deprecated( \%args );

# Translate all instances of '^' back to a colon
my $url = $args{url}; $url =~ s/\^/:/g;

# Retrieve the item name; use 'http' as the default
my $item = $args{item} ? $args{item} : 'http'; # default to http

# Retrieve the positive regular expressions.
# Default to matching anything.
my $greppos = $args{greppos} ? $args{greppos} : '.*';

# Retrieve the negative regular expressions.
# Default to matching nothing.
my $grepneg = $args{grepneg} ? $args{grepneg} : '';

# Set the alias for this check
my $host = $args{alias};

my $user = $args{user};
my $pass = $args{pass};

# Add this url/item combination to the list of checks 
$realhttp->add_url($url,"$host.$item",$greppos,$grepneg,$user,$pass);

1;
