summaryrefslogtreecommitdiffstats
path: root/plugins-scripts/check_ircd.pl
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2009-09-19 01:44:10 -0400
committerThomas Guyot-Sionnest <dermoth@aei.ca>2009-09-19 02:08:51 -0400
commitbc3c8c7cfbdbce716e8987bee211f69911ea8db2 (patch)
treed8a4c258be08fed8ac64346506683ca22641f007 /plugins-scripts/check_ircd.pl
parente82b6118400d9cfa76412f562f4b4b9b7262fdcd (diff)
downloadmonitoring-plugins-bc3c8c7cfbdbce716e8987bee211f69911ea8db2.tar.gz
Fix check_ircd binding to wrong interface (#668778)
Diffstat (limited to 'plugins-scripts/check_ircd.pl')
-rwxr-xr-xplugins-scripts/check_ircd.pl21
1 files changed, 5 insertions, 16 deletions
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl
index cc730cff..3fbce2e4 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);
59sub print_help (); 59sub print_help ();
60sub print_usage (); 60sub print_usage ();
61sub connection ($$$$); 61sub connection ($$$$);
62sub bindRemote ($$$); 62sub 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
144sub bindRemote ($$$) 144sub 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