Changeset 48509f8af144c17f11fe6dee153726c6ca9636cf

Show
Ignore:
Timestamp:
09/22/11 02:31:02 (3 years ago)
Author:
Ryan Phillips <ryan.phillips@rackspace.com>
git-committer:
Ryan Phillips <ryan.phillips@rackspace.com> 1316658662 -0500
git-parent:

[4299e397f43c438472a1933713f8d35e706c97cb]

git-author:
Ryan Phillips <ryan.phillips@rackspace.com> 1316658596 -0500
Message:

Changes to tcp check for send_body and body_match

Contributors: Paul Querna <pquerna@apache.org>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules-lua/noit/module/tcp.lua

    r5f14683 r48509f8  
    4444    <parameter name="banner_match" required="optional" 
    4545              allowed=".+">This regular expression is matched against the response banner.  If a match is not found, the check will be marked as bad.</parameter> 
     46  <parameter name="send_body" required="optional" 
     47            allowed=".+">Data to send on the socket once connected and optionally SSL is negotiated, but before the body match is tested.</parameter> 
     48  <parameter name="body_match" required="optional" 
     49            allowed=".+">This regular expression is matched against the body (the leftover data up to 1024 bytes) after the banner.</parameter> 
    4650    <parameter name="use_ssl" required="optional" allowed="^(?:true|false|on|off)$" default="false">Upgrade TCP connection to use SSL.</parameter> 
    4751    <parameter name="ca_chain" 
     
    177181  end 
    178182 
     183  if check.config.send_body ~= nil then 
     184    e:write(check.config.send_body) 
     185  end 
    179186 
    180187  -- match banner 
     
    205212  end 
    206213 
     214  -- match body 
     215  if check.config.body_match ~= nil then 
     216    local bodybytetime = noit.timeval.now() 
     217    str = e:read(1024) 
     218    if str == nil then 
     219      check.status("bad body length " .. (str and str:len() or "0")) 
     220      return 
     221    end 
     222    elapsed(check, "tt_body", starttime, bodybytetime) 
     223 
     224    local bodyre = noit.pcre(check.config.body_match) 
     225    if bodyre ~= nil then 
     226      local rv = true 
     227      rv, m = bodyre(str) 
     228      if rv then 
     229        status = status .. ',body_match=matched' 
     230      else 
     231        good = false 
     232        status = status .. ',body_match=failed' 
     233      end 
     234    end 
     235 
     236    check.metric_string('body',str) 
     237  end 
     238 
    207239  -- turnaround time 
    208240  local endtime = noit.timeval.now()