--------------070801000406090401030605
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
X-MIME-Autoconverted: from 8bit to quoted-printable by volkswagen.financial.com id hALDnZ94023283
Hi,
i wrote a http-post-module which we use to call a remote program via a=20
jsp and return STDOUT and STDERR. i attached a basic skeleton of it you=20
can easily modefiy to do exactly what you want. just check for=20
$query_string and modify the if ($result =3D "blablabl") at the top to=20
match your conditions.
chris
Steve wrote:
> I posted this to the user list without any response sorry for the cross=
=20
> post but this list seems more suitable for this request..
>=20
> Hello,
>=20
> Searching now for a way to use nagios to monitor a http post command=20
> which returns a numeric value (memory) to be exact its a java component=
=20
> that I can monitor via a http admin, a link within the admin returns=20
> just a single value for each topic..
>=20
> I would like the response viewable within the nagios web and if it=20
> exceeds the numeric value of x would then shoot a error, a plus would b=
e=20
> able to have nagios monitor/log the levels. Considering MRTG to graph=20
> results..
>=20
> Example:
>=20
> http://ip:port/query?component=3Dmemory
>=20
> returns me
>=20
> 100
>=20
> if anything > than 500 returns I get an alert.
>=20
> Again a plus would be to log the level at every check.
>=20
> -steve
>=20
>=20
>=20
>=20
>=20
>=20
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive? Does it
> help you create better code? SHARE THE LOVE, and help us help
> YOU! Click Here: http://sourceforge.net/donate/
> _______________________________________________
> Nagios-devel mailing list
> Nagios-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/lis ... gios-devel
--=20
financial.com AG
Maria-Probst-Stra=DFe 19 Tel.: ++49(0)89/318528-44
D- 80939 M=FCnchen Fax.: ++49(0)89/318528-28
--------------070801000406090401030605
Content-Type: text/plain;
name="http_check.pl"
Content-Disposition: inline;
filename="http_check.pl"
Content-Transfer-Encoding: 7bit
#!/usr/bin/perl
#
#
define();
getcmd();
my $result=abfrage_ausfuehren();
if ($result = "blablabla")
{
print STDOUT $2;
print STDERR $3;
exit $1;
} else {
print "$result\n";
exit 27;
}
###########################################################################
# The fun starts here
#
###########################################################################
# mein RequestAgent
sub define {
# ein paar http-objekte
use HTTP::Request;
use HTTP::Headers;
# include package for cmd-line-arguments
use Getopt::Std;
use LWP;
package RequestAgent;
@ISA =qw(LWP::UserAgent);
sub get_basic_credentials {
my($self, $realm, $uri) = @_;
return ($main::opts{'u'},$main::opts{'p'});
}
}
sub getcmd {
# hash mit optionen
%opts =(
u => '',
p => '',
l => 'http://your.server.com',
a => '',
c => '',
h => '0',
);
# welche optionen gibt es ?
getopts('u:p:l
# hilfe ausgeben
if ( $opts{'h'} ) {
print "Usage: $0 [ -u ] [ -p password ] [-a args ] [ -c command ] -l URL\n";
exit 1;
}
} # sub cetcmd
sub abfrage_ausfuehren {
# string der geschickt wird
my $post_string="args=".$opts{'a'}."&cmd=".$opts{'c'};
# user agent erzeugen
my $ua = RequestAgent->new();
# http-header erzeugen
my $header = HTTP::Headers->new();
# content-type des http-header richtig setzen
$header->header('Content-Type' => 'application/x-www-form-urlencoded');
# request-objekt erzeugen
#print $post_string;
my $request = HTTP::Request->new('POST', $opts{'l'}, $header, $post_string);
# den request abschicken und die fkt callbak zum auswerten registrieren
my $response = $ua->request($request,\&callback);
# ergebnis des HTTP-requests
if ($response->is_success) {
return $theline
} else {
# krasser fehler !
return $response->status_line()
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: cm@financial.com