#!/usr/bin/perl #This module is used to log into an ilo 100 and scrap the sensor data #from the page without using snmp engine which the ilo 100 does not have use strict; use WWW::Mechanize; use Getopt::Std; use LWP::UserAgent; use HTML::TableExtract; my $plugin_name = 'check_http_ilo'; my $VERSION = '0.9'; # getopt module config $Getopt::Std::STANDARD_HELP_VERSION = 1; # nagios exit codes use constant EXIT_OK => 0; use constant EXIT_WARNING => 1; use constant EXIT_CRITICAL => 2; use constant EXIT_UNKNOWN => 3; # getopt module config my %opts; getopts('vU:t:', \%opts); # to do # these should be accepted as variables not hard coded # but it works for the rough hack in $opts{user} = 'yourilousernamehere'; $opts{pass} = 'yourilopasswordhere'; $opts{t} = 60 unless (defined $opts{t}); if (not (defined $opts{U} )) { print "ERROR: INVALID USAGE\n"; HELP_MESSAGE(); exit EXIT_CRITICAL; } my $status = EXIT_OK; my $mech = WWW::Mechanize->new; $mech->credentials( $opts{user}, $opts{pass} ); my $text = $mech->get($opts{U}); #You now have the text from the page you can do with it what you need #I am going to grab all the table rows and dump the relavant ones to nagios output my $text = $mech->content; my $output = ""; my $te = HTML::TableExtract->new( attribs => { id => "Table1" } ); $te->parse($text); foreach my $ts ($te->tables) { #print "Table with border=1 found at ", join(',', $ts->coords), ":\n"; foreach my $row ($ts->rows) { #$output .= join(';', @$row); $output .= @$row[1]; $output .= " "; $output .= @$row[2]; $output .= " "; $output .= @$row[3]; $output .= " "; $output .= @$row[4]; $output .= ";\n"; } } print "ilo status online: sensor readings|\n"; print $output; exit $status; sub HELP_MESSAGE { print < Text to match in the output of the URL -t Timeout in seconds to wait for the URL to load. If the page fails to load, $plugin_name will exit with UNKNOWN state (default 60) EOHELP ; } sub VERSION_MESSAGE { print <