[Pkg-nagios-changes] [pkg-nagios-plugins-contrib] 02/03: Revert "Fix check_ajp to handle non-responding tcp ports."

Bernd Zeimetz bernd at bzed.de
Tue Mar 10 19:54:58 UTC 2015


This is an automated email from the git hooks/post-receive script.

bzed pushed a commit to branch master
in repository pkg-nagios-plugins-contrib.

commit d0e0af8bb6be2c8d801c757fc2fbf252e25aa1d8
Author: Bernd Zeimetz <bernd at bzed.de>
Date:   Tue Mar 10 20:54:11 2015 +0100

    Revert "Fix check_ajp to handle non-responding tcp ports."
    
    This reverts commit f8d59a383175bbcf0011b8308d0505868c6b61e4.
    
    Change was applied by patch...
---
 check_ajp/check_ajp | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/check_ajp/check_ajp b/check_ajp/check_ajp
index 1851615..68aa243 100644
--- a/check_ajp/check_ajp
+++ b/check_ajp/check_ajp
@@ -7,7 +7,6 @@
 #
 # check_ajp - nagios plugin for jboss monitoring
 # Copyright (C) 2010  Michel Rode <rmichel at devnu11.net>
-# Copyright (C) 2013  Bernd Zeimetz <b.zeimetz at conova.com>
 #
 # 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
@@ -31,8 +30,6 @@ use strict;
 use Getopt::Long;
 use Socket;
 use Time::HiRes 'time';
-use IO::Socket;
-
 
 my $app = '';
 my $port = '8009';
@@ -40,14 +37,9 @@ my $warntime = '1.5';
 my $crittime = '3';
 my $timeout = '10';
 
-my ($sock, $time1, $time2);
+my ($iaddr, $paddr, $proto, $sock, $time1, $time2);
 my $pong = 'null';
 
-sub conndie{
-	my $msg = shift;
-	print "CRITICAL : $msg\n";
-	exit 2;
-}
 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";
@@ -57,10 +49,6 @@ sub xdie{
 
 GetOptions("app=s" => \$app, "port=s" => \$port, "warn=f" => \$warntime, "crit=f" => \$crittime, "timeout=f" => \$timeout);
 
-if ($app eq '') {
-    xdie('--app not given')
-}
-
 my $ping = pack 'C5'    # Format template.
     , 0x12, 0x34        # Magic number for server->container packets.
     , 0x00, 0x01        # 2 byte int length of payload.
@@ -73,23 +61,24 @@ my $expected = pack 'C5'    # Format template.
     , 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);
-	$sock = IO::Socket::INET->new(Proto => "tcp",
-					PeerAddr  => $app,
-					PeerPort  => $port) || conndie($@);
-	$sock->autoflush(1);
-	print $sock $ping;
-	$sock->recv($pong,5);
-        close $sock;
+	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 ($@) {
-	conndie($@) unless $@ eq "alarm\n";
+	die unless $@ eq "alarm\n";
 	$time2 = (time() - $time1);
 	printf "CRITICAL - AJP - Timeout after %1.0fs\n",$time2;
 	exit 2;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-nagios-plugins-contrib.git



More information about the Pkg-nagios-changes mailing list