From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- web/attachments/295596-check_ircd.pl.diff | 119 ++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 web/attachments/295596-check_ircd.pl.diff (limited to 'web/attachments/295596-check_ircd.pl.diff') diff --git a/web/attachments/295596-check_ircd.pl.diff b/web/attachments/295596-check_ircd.pl.diff new file mode 100644 index 0000000..b3792c4 --- /dev/null +++ b/web/attachments/295596-check_ircd.pl.diff @@ -0,0 +1,119 @@ +--- check_ircd.pl.orig 2002-05-06 22:35:49.000000000 -0700 ++++ check_ircd.pl 2008-10-01 01:22:43.496305819 -0700 +@@ -43,15 +43,17 @@ + + # ----------------------------------------------------------------[ Require ]-- + +-require 5.004; ++require 5.6.0; + + # -------------------------------------------------------------------[ Uses ]-- + +-use Socket; + use strict; ++use IO::Socket; ++use Sys::Hostname; + use Getopt::Long; + use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose); + use vars qw($PROGNAME); ++use vars qw($ClientSocket); + use lib utils.pm; + use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); + +@@ -60,7 +62,6 @@ + sub print_help (); + sub print_usage (); + sub connection ($$$$); +-sub bindRemote ($$$); + + # -------------------------------------------------------------[ Enviroment ]-- + +@@ -104,7 +105,7 @@ + $answer = "Server $in_remotehost has less than 0 users! Something is Really WRONG!\n"; + } + +- print ClientSocket "quit\n"; ++ print $ClientSocket "quit\n"; + print $answer; + exit $ERRORS{$state}; + } +@@ -140,38 +141,6 @@ + "; + } + +-# -------------------------------------------------------------[ bindRemote ]-- +- +-sub bindRemote ($$$) +-{ +- my ($in_remotehost, $in_remoteport, $in_hostname) = @_; +- my $proto = getprotobyname('tcp'); +- my $sockaddr; +- my $this; +- my $thisaddr = gethostbyname($in_hostname); +- my $that; +- my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost); +-# ($name,$aliases,$type,$len,$thisaddr) = gethostbyname($in_hostname); +- +- if (!socket(ClientSocket,AF_INET, SOCK_STREAM, $proto)) { +- print "IRCD UNKNOWN: Could not start socket ($!)\n"; +- exit $ERRORS{"UNKNOWN"}; +- } +- $sockaddr = 'S n a4 x8'; +- $this = pack($sockaddr, AF_INET, 0, $thisaddr); +- $that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr); +- if (!bind(ClientSocket, $this)) { +- print "IRCD UNKNOWN: Could not bind socket ($!)\n"; +- exit $ERRORS{"UNKNOWN"}; +- } +- if (!connect(ClientSocket, $that)) { +- print "IRCD UNKNOWN: Could not connect socket ($!)\n"; +- exit $ERRORS{"UNKNOWN"}; +- } +- select(ClientSocket); $| = 1; select(STDOUT); +- return \*ClientSocket; +-} +- + # ===================================================================[ MAIN ]== + + MAIN: +@@ -222,24 +191,34 @@ + + alarm($TIMEOUT); + +- chomp($hostname = `/bin/hostname`); ++ $hostname = hostname; + $hostname = $1 if ($hostname =~ /([-.a-zA-Z0-9]+)/); +- my ($name, $alias, $proto) = getprotobyname('tcp'); + print "MAIN(debug): hostname = $hostname\n" if $verbose; + + print "MAIN(debug): binding to remote host: $remotehost -> $remoteport -> $hostname\n" if $verbose; +- my $ClientSocket = &bindRemote($remotehost,$remoteport,$hostname); ++ ++ $ClientSocket = IO::Socket::INET->new( ++ PeerAddr => $remotehost, ++ PeerPort => $remoteport, ++ LocalAddr => $hostname, ++ Proto => "tcp" ++ ); ++ ++ if (! $ClientSocket) { ++ print "IRCD UNKNOWN: Could not connect socket ($!)\n"; ++ exit $ERRORS{"UNKNOWN"}; ++ } + +- print ClientSocket "NICK $NICK\nUSER $USER_INFO\n"; ++ print $ClientSocket "NICK $NICK\nUSER $USER_INFO\n"; + +- while () { ++ while (<$ClientSocket>) { + print "MAIN(debug): default var = $_\n" if $verbose; + + # DALnet,LagNet,UnderNet etc. Require this! + # Replies with a PONG when presented with a PING query. + # If a server doesn't require it, it will be ignored. + +- if (m/^PING (.*)/) {print ClientSocket "PONG $1\n";} ++ if (m/^PING (.*)/) {print $ClientSocket "PONG $1\n";} + + alarm(0); + -- cgit v1.2.3-74-g34f1