Changeset 3c4929015c7e763c1aa84c4ecf095f93e09a936f

Show
Ignore:
Timestamp:
09/27/11 06:28:12 (3 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1317104892 -0400
git-parent:

[559e017dc530d5467cb14742be11d9f328bf4e01], [4d67783cefed3fcbb1d0054cfd469b63262bc00c]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1317104892 -0400
Message:

Merge branch 'master' of github.com:omniti-labs/reconnoiter

Files:

Legend:

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

    r5f14683 ra751ee3  
    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    if e:write(check.config.send_body) < 0 then 
     185      check.bad() 
     186      check.status("send_body: received hangup") 
     187      return 
     188    end 
     189  end 
    179190 
    180191  -- match banner 
     
    205216  end 
    206217 
     218  -- match body 
     219  if check.config.body_match ~= nil then 
     220    str = e:read(1024) 
     221    if str == nil then 
     222      check.status("bad body length " .. (str and str:len() or "0")) 
     223      return 
     224    end 
     225    local bodybytetime = noit.timeval.now() 
     226    elapsed(check, "tt_body", starttime, bodybytetime) 
     227 
     228    local exre = noit.pcre(check.config.body_match) 
     229    local rv = true 
     230    local found = false 
     231    local m = nil 
     232    while rv and m ~= '' do 
     233      rv, m, key, value = exre(str or '', { limit = pcre_match_limit }) 
     234      if rv then 
     235        found = true 
     236        if key ~= nil then 
     237          check.metric(key, value) 
     238        end 
     239      end 
     240    end 
     241 
     242    if found then 
     243      status = status .. ',body_match=matched' 
     244    else 
     245      good = false 
     246      status = status .. ',body_match=failed' 
     247    end 
     248 
     249    check.metric_string('body',str) 
     250  end 
     251 
    207252  -- turnaround time 
    208253  local endtime = noit.timeval.now()