[Reconnoiter-devel] [reconnoiter commit] Reconnoiter branch, master, updated. 55a909658a1fb1434491caf0b50e9b25fc8ac095
git at labs.omniti.com
git at labs.omniti.com
Wed Mar 14 17:20:56 EDT 2012
Pushed by: jesus
The branch, master has been updated
via 55a909658a1fb1434491caf0b50e9b25fc8ac095 (commit)
via 1581bb9cbc2230831b3d94d346397c1c030124ea (commit)
via 1f9edc74e34a100b1e519135ef7e2d7e774cd605 (commit)
from 3de78ae6b819653d9651f0061e1b54f9f68339ea (commit)
Summary of changes:
docs/config/modules/noit.module.resmon.xml | 28 ++++++++++++++++++++++++++++
src/modules-lua/noit/HttpClient.lua | 8 ++++++--
src/modules-lua/noit/module/http.lua | 2 +-
src/modules-lua/noit/module/resmon.lua | 7 ++++++-
src/modules/lua.c | 2 +-
src/modules/lua_noit.c | 4 ++--
6 files changed, 44 insertions(+), 7 deletions(-)
Log:
commit 55a909658a1fb1434491caf0b50e9b25fc8ac095
Author: Theo Schlossnagle <jesus at omniti.com>
Date: Wed Mar 14 17:20:41 2012 -0400
Update resmon documentation to reflect the read_limit parameter.
diff --git a/docs/config/modules/noit.module.resmon.xml b/docs/config/modules/noit.module.resmon.xml
index b483cc3..0c3e881 100644
--- a/docs/config/modules/noit.module.resmon.xml
+++ b/docs/config/modules/noit.module.resmon.xml
@@ -67,6 +67,34 @@
</listitem>
</varlistentry>
</variablelist>
+ <variablelist>
+ <varlistentry>
+ <term>read_limit</term>
+ <listitem>
+ <variablelist>
+ <varlistentry>
+ <term>required</term>
+ <listitem>
+ <para>optional</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>default</term>
+ <listitem>
+ <para>0</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>allowed</term>
+ <listitem>
+ <para>\d+</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>Sets an approximate limit on the data read (0 means no limit).</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</section>
<example>
<title>Checking resmon services on OmniTI Labs.</title>
commit 1581bb9cbc2230831b3d94d346397c1c030124ea
Author: Theo Schlossnagle <jesus at omniti.com>
Date: Wed Mar 14 17:19:35 2012 -0400
Make the read_limit config param in http module pass-thru to the
gunzip deflate limit transparently so that the limit is not hardcoded
in the lua module (only a sane default is).
Also, enable the resmon module to use the same config parameter in
the same way
diff --git a/src/modules-lua/noit/HttpClient.lua b/src/modules-lua/noit/HttpClient.lua
index 82798bd..f37d406 100644
--- a/src/modules-lua/noit/HttpClient.lua
+++ b/src/modules-lua/noit/HttpClient.lua
@@ -187,13 +187,17 @@ function HttpClient:get_body(read_limit)
local cefunc = ce_passthru
local ce = self.headers["content-encoding"]
if ce ~= nil then
+ local deflater
if ce == "gzip" then
- cefunc = noit.gunzip()
+ deflater = noit.gunzip()
elseif ce == "deflate" then
- cefunc = noit.gunzip()
+ deflater = noit.gunzip()
else
error("unknown content-encoding: " .. ce)
end
+ cefunc = function(str)
+ return deflater(str, read_limit)
+ end
end
local te = self.headers["transfer-encoding"]
local cl = self.headers["content-length"]
diff --git a/src/modules-lua/noit/module/http.lua b/src/modules-lua/noit/module/http.lua
index 8f7a7fa..13bb9f3 100644
--- a/src/modules-lua/noit/module/http.lua
+++ b/src/modules-lua/noit/module/http.lua
@@ -283,7 +283,7 @@ function initiate(module, check)
local pcre_match_limit = check.config.pcre_match_limit or 10000
local redirects = check.config.redirects or 0
local include_body = false
- local read_limit = tonumber(check.config.read_limit) or 0
+ local read_limit = tonumber(check.config.read_limit) or nil
-- expect the worst
check.bad()
diff --git a/src/modules-lua/noit/module/resmon.lua b/src/modules-lua/noit/module/resmon.lua
index ac20534..3ed6bd5 100644
--- a/src/modules-lua/noit/module/resmon.lua
+++ b/src/modules-lua/noit/module/resmon.lua
@@ -47,6 +47,10 @@ function onload(image)
<parameter name="port"
required="optional"
allowed="\d+">The TCP port can be specified to overide the default of 81.</parameter>
+ <parameter name="read_limit"
+ required="optional"
+ default="0"
+ allowed="\d+">Sets an approximate limit on the data read (0 means no limit).</parameter>
</checkconfig>
<examples>
<example>
@@ -195,6 +199,7 @@ function initiate(module, check)
local codere = noit.pcre(check.config.code or '^200$')
local good = false
local starttime = noit.timeval.now()
+ local read_limit = tonumber(check.config.read_limit) or nil
local user = check.config.auth_user or nil
local pass = check.config.auth_password or nil
@@ -243,7 +248,7 @@ function initiate(module, check)
headers["Authorization"] = "Basic " .. encoded
end
client:do_request("GET", uri, headers)
- client:get_response()
+ client:get_response(read_limit)
local jsondoc = nil
if string.find(hdrs_in["content-type"] or '', 'json') ~= nil or
diff --git a/src/modules/lua_noit.c b/src/modules/lua_noit.c
index 539c3ca..0959d28 100644
--- a/src/modules/lua_noit.c
+++ b/src/modules/lua_noit.c
@@ -1221,7 +1221,7 @@ nl_gunzip_deflate(lua_State *L) {
lua_pushnil(L);
return 1;
}
- if(n == 2)
+ if(n == 2 && !lua_isnil(L, 2))
limit = lua_tointeger(L, 2);
stream->next_in = (Bytef *)input;
@@ -1232,7 +1232,7 @@ nl_gunzip_deflate(lua_State *L) {
/* got some data */
int size_read = DEFLATE_CHUNK_SIZE - stream->avail_out;
uLong newoutlen = outlen + size_read;
- if(newoutlen > limit) {
+ if(limit && newoutlen > limit) {
err = Z_MEM_ERROR;
break;
}
commit 1f9edc74e34a100b1e519135ef7e2d7e774cd605
Author: Theo Schlossnagle <jesus at omniti.com>
Date: Wed Mar 14 17:10:28 2012 -0400
bug in error output for lua failures
diff --git a/src/modules/lua.c b/src/modules/lua.c
index d9c1f98..56848ca 100644
--- a/src/modules/lua.c
+++ b/src/modules/lua.c
@@ -707,7 +707,7 @@ noit_lua_resume(noit_lua_check_info_t *ci, int nargs) {
if(err) noitL(nldeb, "err -> %s\n", err);
if(nerr) noitL(nldeb, "nerr -> %s\n", nerr);
if(nerr && *nerr == 31) nerr = NULL; // 31? WTF lua?
- if(!nerr && err) {
+ if(err) {
nerr = strchr(err, ' '); /* advance past the file */
if(nerr) nerr += 1;
}
hooks/post-receive
--
Reconnoiter
More information about the Reconnoiter-devel
mailing list