From 1e2387474a449452b78520b9ad96a8b4b5e99722 Mon Sep 17 00:00:00 2001 From: Harald Pfeiffer Date: Wed, 17 Apr 2019 19:07:19 +0200 Subject: initial commit of source fetch --- .../check_ajp/Makefile | 5 + .../check_ajp/ajp.cfg | 6 ++ .../check_ajp/check_ajp | 103 +++++++++++++++++++++ .../check_ajp/control | 8 ++ .../check_ajp/copyright | 17 ++++ 5 files changed, 139 insertions(+) create mode 100644 nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/Makefile create mode 100644 nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/ajp.cfg create mode 100644 nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/check_ajp create mode 100644 nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/control create mode 100644 nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/copyright (limited to 'nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp') diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/Makefile b/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/Makefile new file mode 100644 index 0000000..e301afc --- /dev/null +++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/Makefile @@ -0,0 +1,5 @@ +PLUGIN := check_ajp + +include ../common.mk + + diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/ajp.cfg b/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/ajp.cfg new file mode 100644 index 0000000..89221e0 --- /dev/null +++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/ajp.cfg @@ -0,0 +1,6 @@ +# 'check_ajp' command definition +define command{ + command_name check_ajp + command_line /usr/lib/nagios/plugins/check_ajp --app '$HOSTADDRESS$' + } + diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/check_ajp b/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/check_ajp new file mode 100644 index 0000000..68aa243 --- /dev/null +++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/check_ajp @@ -0,0 +1,103 @@ +#!/usr/bin/perl -w +# +# History: +# 2010-11-05 First release (v1) +# +# Comment: Please send bug fixes and enhancements to +# +# check_ajp - nagios plugin for jboss monitoring +# Copyright (C) 2010 Michel Rode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# +# Usage: ./check_ajp --app ip.of.the.app [--port 8009 --warn 1 --crit 2 --timeout 5] +# + +use warnings; +use strict; +use Getopt::Long; +use Socket; +use Time::HiRes 'time'; + +my $app = ''; +my $port = '8009'; +my $warntime = '1.5'; +my $crittime = '3'; +my $timeout = '10'; + +my ($iaddr, $paddr, $proto, $sock, $time1, $time2); +my $pong = 'null'; + +sub xdie{ + my $msg = shift; + printf STDERR "Usage: check_ajp --app ip.of.the.app [--port 8009 --warn 1 --crit 2 --timeout 5]\n\n"; + printf STDERR "ERROR: $msg\n"; + exit 3; +} + +GetOptions("app=s" => \$app, "port=s" => \$port, "warn=f" => \$warntime, "crit=f" => \$crittime, "timeout=f" => \$timeout); + +my $ping = pack 'C5' # Format template. + , 0x12, 0x34 # Magic number for server->container packets. + , 0x00, 0x01 # 2 byte int length of payload. + , 0x0A # Type of packet. 10 = CPing. +; + +my $expected = pack 'C5' # Format template. + , 0x41, 0x42 # Magic number for container->server packets. + , 0x00, 0x01 # 2 byte int length of payload. + , 0x09 # Type of packet. 9 = CPong reply. +; + +$iaddr = inet_aton($app) || xdie("No host given !"); +$paddr = sockaddr_in($port, $iaddr) || xdie("Wrong port !"); +$proto = getprotobyname 'tcp'; + +$time1 = time(); + +eval { + local $SIG{ALRM} = sub { die "alarm\n" }; + alarm($timeout); + socket $sock, PF_INET, SOCK_STREAM, $proto || xdie("socket !"); + connect $sock, $paddr || xdie("connect !"); + syswrite $sock, $ping || xdie("syswrite !"); + sysread $sock, $pong, 5 || xdie("sysread !"); + alarm(0); +}; + +if ($@) { + die unless $@ eq "alarm\n"; + $time2 = (time() - $time1); + printf "CRITICAL - AJP - Timeout after %1.0fs\n",$time2; + exit 2; +} else { + $time2 = (time() - $time1); + + if ($pong eq $expected) { + if ($time2 >= $crittime) { + printf "CRITICAL - AJP - %3.5f seconds response time|time=%3.6fs;;;0.000000;%2.6f\n",$time2,$time2,$timeout; + exit 2; + } elsif ($time2 >= $warntime) { + printf "WARNING - AJP - %3.5f seconds response time|time=%3.6fs;;;0.000000;%2.6f\n",$time2,$time2,$timeout; + exit 1; + } else { + printf "OK - AJP - %3.5f seconds response time|time=%3.6fs;;;0.000000;%2.6f\n",$time2,$time2,$timeout; + exit 0; + } + } else { + printf "UNKNOWN - AJP - %3.5f seconds response time|time=%3.6fs;;;0.000000;%2.6f\n",$time2,$time2,$timeout; + exit 3; + } +} diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/control b/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/control new file mode 100644 index 0000000..3b586cf --- /dev/null +++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/control @@ -0,0 +1,8 @@ +Version: 1 +Uploaders: Bernd Zeimetz +Description: plugin to monitor the AJP ping response time + Should work with all application servers (Tomcat, JBoss,....) + which provide an AJPv13 connector. +Homepage: http://blog.devnu11.net/projects/ +Watch: http://blog.devnu11.net/projects/

v([0-9]*) – md5: +Recommends: libsocket-perl diff --git a/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/copyright b/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/copyright new file mode 100644 index 0000000..cc3b682 --- /dev/null +++ b/nagios-plugins-contrib-24.20190301~bpo9+1/check_ajp/copyright @@ -0,0 +1,17 @@ +Comment: Please send bug fixes and enhancements to + +check_ajp - nagios plugin for jboss monitoring +Copyright (C) 2010 Michel Rode + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . -- cgit v1.2.3