Mercurial > prosody-modules
comparison mod_statistics_auth/mod_statistics_auth.lua @ 1439:86ceb94e3db4
mod_statistics_auth: Collects statistics on number of successful or failed authentication attempts
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 20 Jun 2014 17:47:53 +0200 |
parents | |
children | 78133eb11e7d |
comparison
equal
deleted
inserted
replaced
1438:feca77ad88ac | 1439:86ceb94e3db4 |
---|---|
1 -- mod_statistics_auth | |
2 module:set_global(); | |
3 | |
4 local auth_ok, auth_fail = 0, 0 | |
5 | |
6 function module.add_host(module) | |
7 module:hook("authentication-success", function(event) | |
8 auth_ok = auth_ok + 1 | |
9 end); | |
10 module:hook("authentication-failure", function(event) | |
11 auth_fail = auth_fail + 1 | |
12 end); | |
13 end | |
14 | |
15 module:provides("statistics", { | |
16 statistics = { | |
17 c2s_auth = { -- virtual memory | |
18 get = function () | |
19 return auth_ok; | |
20 end; | |
21 tostring = tostring; | |
22 }; | |
23 c2s_authfail = { -- virtual memory | |
24 get = function () | |
25 return auth_fail; | |
26 end; | |
27 tostring = tostring; | |
28 }; | |
29 } | |
30 }); |