diff options
Diffstat (limited to 'plugins-scripts')
-rwxr-xr-x | plugins-scripts/check_ircd.pl | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl index cc730cf..3fbce2e 100755 --- a/plugins-scripts/check_ircd.pl +++ b/plugins-scripts/check_ircd.pl | |||
@@ -59,7 +59,7 @@ use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); | |||
59 | sub print_help (); | 59 | sub print_help (); |
60 | sub print_usage (); | 60 | sub print_usage (); |
61 | sub connection ($$$$); | 61 | sub connection ($$$$); |
62 | sub bindRemote ($$$); | 62 | sub bindRemote ($$); |
63 | 63 | ||
64 | # -------------------------------------------------------------[ Enviroment ]-- | 64 | # -------------------------------------------------------------[ Enviroment ]-- |
65 | 65 | ||
@@ -141,28 +141,20 @@ Perl Check IRCD plugin for Nagios | |||
141 | 141 | ||
142 | # -------------------------------------------------------------[ bindRemote ]-- | 142 | # -------------------------------------------------------------[ bindRemote ]-- |
143 | 143 | ||
144 | sub bindRemote ($$$) | 144 | sub bindRemote ($$) |
145 | { | 145 | { |
146 | my ($in_remotehost, $in_remoteport, $in_hostname) = @_; | 146 | my ($in_remotehost, $in_remoteport) = @_; |
147 | my $proto = getprotobyname('tcp'); | 147 | my $proto = getprotobyname('tcp'); |
148 | my $sockaddr; | 148 | my $sockaddr; |
149 | my $this; | ||
150 | my $thisaddr = gethostbyname($in_hostname); | ||
151 | my $that; | 149 | my $that; |
152 | my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost); | 150 | my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost); |
153 | # ($name,$aliases,$type,$len,$thisaddr) = gethostbyname($in_hostname); | ||
154 | 151 | ||
155 | if (!socket(ClientSocket,AF_INET, SOCK_STREAM, $proto)) { | 152 | if (!socket(ClientSocket,AF_INET, SOCK_STREAM, $proto)) { |
156 | print "IRCD UNKNOWN: Could not start socket ($!)\n"; | 153 | print "IRCD UNKNOWN: Could not start socket ($!)\n"; |
157 | exit $ERRORS{"UNKNOWN"}; | 154 | exit $ERRORS{"UNKNOWN"}; |
158 | } | 155 | } |
159 | $sockaddr = 'S n a4 x8'; | 156 | $sockaddr = 'S n a4 x8'; |
160 | $this = pack($sockaddr, AF_INET, 0, $thisaddr); | ||
161 | $that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr); | 157 | $that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr); |
162 | if (!bind(ClientSocket, $this)) { | ||
163 | print "IRCD UNKNOWN: Could not bind socket ($!)\n"; | ||
164 | exit $ERRORS{"UNKNOWN"}; | ||
165 | } | ||
166 | if (!connect(ClientSocket, $that)) { | 158 | if (!connect(ClientSocket, $that)) { |
167 | print "IRCD UNKNOWN: Could not connect socket ($!)\n"; | 159 | print "IRCD UNKNOWN: Could not connect socket ($!)\n"; |
168 | exit $ERRORS{"UNKNOWN"}; | 160 | exit $ERRORS{"UNKNOWN"}; |
@@ -221,13 +213,10 @@ MAIN: | |||
221 | 213 | ||
222 | alarm($TIMEOUT); | 214 | alarm($TIMEOUT); |
223 | 215 | ||
224 | chomp($hostname = `/bin/hostname`); | ||
225 | $hostname = $1 if ($hostname =~ /([-.a-zA-Z0-9]+)/); | ||
226 | my ($name, $alias, $proto) = getprotobyname('tcp'); | 216 | my ($name, $alias, $proto) = getprotobyname('tcp'); |
227 | print "MAIN(debug): hostname = $hostname\n" if $verbose; | ||
228 | 217 | ||
229 | print "MAIN(debug): binding to remote host: $remotehost -> $remoteport -> $hostname\n" if $verbose; | 218 | print "MAIN(debug): binding to remote host: $remotehost -> $remoteport\n" if $verbose; |
230 | my $ClientSocket = &bindRemote($remotehost,$remoteport,$hostname); | 219 | my $ClientSocket = &bindRemote($remotehost,$remoteport); |
231 | 220 | ||
232 | print ClientSocket "NICK $NICK\nUSER $USER_INFO\n"; | 221 | print ClientSocket "NICK $NICK\nUSER $USER_INFO\n"; |
233 | 222 | ||