[Nagiosplug-devel] check_tcp bug
    Russell Scibetti 
    russell at quadrix.com
       
    Wed Dec 18 16:21:06 CET 2002
    
    
  
I've noticed two small problems with the check_tcp plugin (nagiosplug 
1.3b2) that prevent it from doing its proper default expect string 
checking (i.e - if you are running check_smtp, by default you expect a 
"220" return, etc).
First, the expect value for check_pop (and check_spop) is incorrect. 
 The expect is set to "110", which is just the port for POP.  This never 
actually gets returned when to do a tcp connect to POP.  What you need 
to get back to know that POP is working is "+OK".
Secondly, there is a bug in that, unless the user gives uses the -e 
argument, none of the default expects will every be checked.  Here is a 
piece of the check_tcp code:
  /* use default expect if none listed in process_arguments() */
  if (EXPECT && server_expect_count == 0) {
!          server_expect = malloc (1);
           server_expect[server_expect_count - 1] = EXPECT;
  }
Well, unless you are doing a check_nntp or the user gave a -e <string>, 
the value of server_expect_count going into this is 0.  So 
server_expect[-1] is being stored and server_expect_count doesn't get 
set to 1 anywhere.  So later, when the code decides if it needs to check 
against any expect strings, it sees that server_expect_count = 0, and 
doesn't do any comparisons.
The way around this is:
  /* use default expect if none listed in process_arguments() */
  if (EXPECT && server_expect_count == 0) {
!          server_expect = malloc (++server_expect_count);
           server_expect[server_expect_count - 1] = EXPECT;
  }
Now, server_expect_count is increased to 1 and the value is stored in 
server_expect[0].  This will actually make check_tcp check the default 
expect values.  If you compare, this looks just like the section of code 
where you set a user-defined expect string.
I have included a context diff that can be used as a patch.  If you have 
any questions, just email me back.  Thanks.
-Russell Scibetti
-- 
Russell Scibetti
Quadrix Solutions, Inc.
http://www.quadrix.com
(732) 235-2335, ext. 7038
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: checktcp-diff.patch
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20021218/62a568c2/attachment.ksh>
    
    
More information about the Devel
mailing list