Re: Netsaint check to read data off a webpage

"Roger Flemming/SYD/CEtv" <[email protected]>
Newsgroups gmane.network.netsaint.user
Message-ID <[email protected]>
Hello net hagiolators,

Shawn Jones <[email protected]> wrote:

> I am not sure if this is possible.  I wanted to know if anyone knows a 
way
> to setup a netsaint check to read data from a webpage.  We have an 
internal
> application that produces a webpage with 2 lines of text stating there 
is
> or is not a connection to a db2 database.  The url does not change, only
> the data on the webpage changes.  So a simple url check will not work.
> Does anyone have any suggestions or examples on how to do this?  Is it 
even
> possible with the current Netsaint setup?

If you need to do some reasonably complicated parsing of the returned 
page,
you could create a Perl plugin something like this:

    use LWP::Simple;
    #   ^^^--- Enables you to do HTTP GETs straight out of Perl
 
    #         (All the other 
    #        plugin boilerplate
    #             here)
 
    my $report = get($the_url_you_want);
 
    # $report now contains the whole page, do some
    # pattern matching to decide how to respond
    # This gets as sophisticated as your patterns.
 
    unless ($report) {
        print "Couldn't read report page";
        exit $ERRORS{'UNKNOWN'};
    }
    if ( $report =~ /bad bad bad/ ) {
        print "db2 is bad bad bad!";
        exit $ERRORS{'CRITICAL'};
    }
    if ( $report =~ /not so good/ ) {
        print "db2 is not so good";
        exit $ERRORS{'WARNING'};
    }
    if ( $report =~ /happy happy/ ) {
        print "db2 is happy happy!";
        exit $ERRORS{'OK'};
    }
 
    # We get here if we got data but no patterns matched
    print "Couldn't understand the report page";
    exit $ERRORS{'UNKNOWN'};

Anyway, you get the idea.

Cheers,
Roger

***************************************************************************************************************************************************************************
This email and any files transmitted with it, are confidential and is intended solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error, please notify the system manager.

This footnote also confirms that this email message has been scanned by AUSTAR Communications content  and virus scanning applications
for the presence of computer viruses.
***************************************************************************************************************************************************************************
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.