Changeset 4a0da0e513a734ae484e56cee0fdc99f321e3766
- Timestamp:
- 01/25/12 22:30:15
(1 year ago)
- Author:
- Philip Maddox <pmaddox@circonus.com>
- git-committer:
- Philip Maddox <pmaddox@circonus.com> 1327530615 -0500
- git-parent:
[2c77cc6f256e2dd45190aaf508321a230e0095d4]
- git-author:
- Philip Maddox <pmaddox@circonus.com> 1327530615 -0500
- Message:
Added support for EHLO response metrics
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r5f14683 |
r4a0da0e |
|
| 144 | 144 | local elapsed_ms = math.floor(tostring(elapsed) * 1000) |
|---|
| 145 | 145 | check.metric(phase .. "_time", elapsed_ms) |
|---|
| | 146 | |
|---|
| | 147 | if phase == 'ehlo' and message ~= nil then |
|---|
| | 148 | local fields = string.split(message, "\r\n") |
|---|
| | 149 | if fields ~= nil then |
|---|
| | 150 | local response = "" |
|---|
| | 151 | local extensions = "" |
|---|
| | 152 | if fields[1] ~= nil then |
|---|
| | 153 | response = fields[1] |
|---|
| | 154 | check.metric("ehlo_response_banner", response) |
|---|
| | 155 | end |
|---|
| | 156 | if expected_code == actual_code and fields[1] ~= nil then |
|---|
| | 157 | table.remove(fields, 1) |
|---|
| | 158 | for line, value in pairs(fields) do |
|---|
| | 159 | if value ~= nil and value ~= "" then |
|---|
| | 160 | value = value:gsub("^%s*(.-)%s*$", "%1") |
|---|
| | 161 | local subfields = string.split(value, "%s+", 1) |
|---|
| | 162 | if subfields ~= nil and subfields[1] ~= nil then |
|---|
| | 163 | local header = subfields[1] |
|---|
| | 164 | if subfields[2] ~= nil then |
|---|
| | 165 | check.metric("ehlo_response_" .. string.lower(header), subfields[2]) |
|---|
| | 166 | else |
|---|
| | 167 | check.metric("ehlo_response_" .. string.lower(header), 'true') |
|---|
| | 168 | end |
|---|
| | 169 | end |
|---|
| | 170 | end |
|---|
| | 171 | end |
|---|
| | 172 | end |
|---|
| | 173 | end |
|---|
| | 174 | end |
|---|
| 146 | 175 | return success |
|---|
| 147 | 176 | end |
|---|
| … | … | |
| 214 | 243 | end |
|---|
| 215 | 244 | |
|---|
| | 245 | -- from http://www.wellho.net/resources/ex.php4?item=u108/split |
|---|
| | 246 | -- modified to split up to 'max' times |
|---|
| | 247 | function string:split(delimiter, max) |
|---|
| | 248 | local result = { } |
|---|
| | 249 | local from = 1 |
|---|
| | 250 | local delim_from, delim_to = string.find( self, delimiter, from ) |
|---|
| | 251 | local nb = 0 |
|---|
| | 252 | if max == nil then |
|---|
| | 253 | max = 0 |
|---|
| | 254 | end |
|---|
| | 255 | while delim_from do |
|---|
| | 256 | local insert_string = string.sub( self, from , delim_from-1 ) |
|---|
| | 257 | nb = nb + 1 |
|---|
| | 258 | table.insert( result, insert_string ) |
|---|
| | 259 | from = delim_to + 1 |
|---|
| | 260 | delim_from, delim_to = string.find( self, delimiter, from ) |
|---|
| | 261 | if nb == max then |
|---|
| | 262 | break |
|---|
| | 263 | end |
|---|
| | 264 | end |
|---|
| | 265 | local last_res = string.sub (self, from) |
|---|
| | 266 | if last_res ~= nil and last_res ~= "" then |
|---|
| | 267 | table.insert( result, last_res ) |
|---|
| | 268 | end |
|---|
| | 269 | return result |
|---|
| | 270 | end |
|---|
| | 271 | |
|---|