1320.4.1
by Joe Daly
scoreboard implementation for statistics |
1 |
/*
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
2 |
* Copyright (C) 2010 Joseph Daly <skinny.moey@gmail.com>
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
3 |
* All rights reserved.
|
4 |
*
|
|
5 |
* Redistribution and use in source and binary forms, with or without
|
|
6 |
* modification, are permitted provided that the following conditions are met:
|
|
7 |
*
|
|
8 |
* * Redistributions of source code must retain the above copyright notice,
|
|
9 |
* this list of conditions and the following disclaimer.
|
|
10 |
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
11 |
* this list of conditions and the following disclaimer in the documentation
|
|
12 |
* and/or other materials provided with the distribution.
|
|
13 |
* * Neither the name of Joseph Daly nor the names of its contributors
|
|
14 |
* may be used to endorse or promote products derived from this software
|
|
15 |
* without specific prior written permission.
|
|
16 |
*
|
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
18 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
19 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
20 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
21 |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22 |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23 |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24 |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25 |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
27 |
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
28 |
*/
|
|
29 |
||
30 |
/**
|
|
31 |
* @details
|
|
32 |
*
|
|
1561.3.24
by Joe Daly
update comments in various files |
33 |
* This plugin tracks session and global statistics, as well as user statistics.
|
34 |
* The commands are logged using the post() and postEnd() logging APIs.
|
|
35 |
* The statistics are stored in a Scoreboard where each active session owns a
|
|
36 |
* ScoreboardSlot during the sessions active lifetime.
|
|
37 |
*
|
|
1320.5.18
by Joe Daly
update comments in logging_stats.cc |
38 |
* Scoreboard
|
39 |
*
|
|
1561.3.24
by Joe Daly
update comments in various files |
40 |
* The scoreboard is a pre-allocated vector of vectors of ScoreboardSlots. It
|
41 |
* can be thought of as a vector of buckets where each bucket contains
|
|
42 |
* pre-allocated ScoreboardSlots. To determine which bucket gets used for
|
|
43 |
* recording statistics the modulus operator is used on the session_id. This
|
|
44 |
* will result in a bucket to search for a unused ScoreboardSlot. Once a
|
|
45 |
* ScoreboardSlot is found the index of the slot is stored in the Session
|
|
46 |
* for later use.
|
|
1320.4.6
by Joe Daly
update comment |
47 |
*
|
48 |
* Locking
|
|
1320.5.18
by Joe Daly
update comments in logging_stats.cc |
49 |
*
|
50 |
* Each vector in the Scoreboard has its own lock. This allows session 2
|
|
51 |
* to not have to wait for session 1 to locate a slot to use, as they
|
|
52 |
* will be in different buckets. A lock is taken to locate a open slot
|
|
1561.3.24
by Joe Daly
update comments in various files |
53 |
* in the scoreboard. Subsequent queries by the session will not take
|
54 |
* a lock.
|
|
1320.4.5
by Joe Daly
fix tests which were may not have been deterministic because of the ip field, add comments, add scoreboard size as a system var, remove multiple setting in a scoreboard slot |
55 |
*
|
1320.5.18
by Joe Daly
update comments in logging_stats.cc |
56 |
* A read lock is taken on the scoreboard vector when the table is queried
|
1561.3.18
by Joe Daly
remove functions that add/diff status_var this functionality is in the logging_stats plugin |
57 |
* in the data_dictionary. The "show status" and "show global status" do
|
58 |
* not take a read lock when the data_dictionary table is queried, the
|
|
59 |
* user is not displayed in these results so it is not necessary.
|
|
1320.5.3
by Joe Daly
update description of logging_stats class |
60 |
*
|
1491.4.3
by Joe Daly
update comment |
61 |
* Atomics
|
1491.4.10
by Joe Daly
update comments |
62 |
*
|
63 |
* The cumulative statistics use atomics, for the index into the vector
|
|
64 |
* marking the last index that is used by a user. New users will increment
|
|
65 |
* the atomic and claim the slot for use.
|
|
1491.4.3
by Joe Daly
update comment |
66 |
*
|
1320.5.17
by Joe Daly
clean up some unneeded destructors and add update comments |
67 |
* System Variables
|
68 |
*
|
|
69 |
* logging_stats_scoreboard_size - the size of the scoreboard this corresponds
|
|
70 |
* to the maximum number of concurrent connections that can be tracked
|
|
71 |
*
|
|
72 |
* logging_stats_max_user_count - this is used for cumulative statistics it
|
|
73 |
* represents the maximum users that can be tracked
|
|
74 |
*
|
|
75 |
* logging_stats_bucket_count - the number of buckets to have in the scoreboard
|
|
76 |
* this splits up locking across several buckets so the entire scoreboard is
|
|
77 |
* not locked at a single point in time.
|
|
78 |
*
|
|
79 |
* logging_stats_enabled - enable/disable plugin
|
|
1320.5.13
by Joe Daly
add description and comments to various files |
80 |
*
|
1320.4.5
by Joe Daly
fix tests which were may not have been deterministic because of the ip field, add comments, add scoreboard size as a system var, remove multiple setting in a scoreboard slot |
81 |
* TODO
|
1320.4.6
by Joe Daly
update comment |
82 |
*
|
1320.5.18
by Joe Daly
update comments in logging_stats.cc |
83 |
* Allow expansion of Scoreboard and cumulative vector
|
1491.4.26
by Joe Daly
add comment in TODO field of logging_stats.cc |
84 |
*
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
85 |
*/
|
86 |
||
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
87 |
#include <config.h> |
1561.3.8
by Joe Daly
try and create some logic with header files, and implement flush status properly |
88 |
#include "user_commands.h" |
89 |
#include "status_vars.h" |
|
90 |
#include "global_stats.h" |
|
91 |
#include "logging_stats.h" |
|
1561.3.5
by Joe Daly
remove old SESSION_STATUS tables, add new ones |
92 |
#include "status_tool.h" |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
93 |
#include "stats_schema.h" |
1660.11.1
by Vijay Samuel
Merge refactored commandline and modified test cases for logging_stats |
94 |
#include <boost/program_options.hpp> |
95 |
#include <drizzled/module/option_map.h> |
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
96 |
#include <drizzled/session.h> |
2269.1.6
by Olaf van der Spek
Session Times |
97 |
#include <drizzled/session/times.h> |
2234.1.1
by Olaf van der Spek
Refactor includes |
98 |
#include <drizzled/sql_lex.h> |
2241.3.1
by Olaf van der Spek
Refactor Session::status_var |
99 |
#include <drizzled/statistics_variables.h> |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
100 |
|
1660.11.1
by Vijay Samuel
Merge refactored commandline and modified test cases for logging_stats |
101 |
namespace po= boost::program_options; |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
102 |
using namespace drizzled; |
103 |
using namespace plugin; |
|
104 |
using namespace std; |
|
105 |
||
1561.3.11
by Joe Daly
get tests working |
106 |
static bool sysvar_logging_stats_enabled= true; |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
107 |
|
1964.2.13
by Monty Taylor
logging_stats |
108 |
typedef constrained_check<uint32_t, 50000, 10> scoreboard_size_constraint; |
109 |
static scoreboard_size_constraint sysvar_logging_stats_scoreboard_size; |
|
110 |
||
111 |
typedef constrained_check<uint32_t, 50000, 100> max_user_count_constraint; |
|
112 |
static max_user_count_constraint sysvar_logging_stats_max_user_count; |
|
113 |
||
114 |
typedef constrained_check<uint32_t, 500, 5> bucket_count_constraint; |
|
115 |
static bucket_count_constraint sysvar_logging_stats_bucket_count; |
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
116 |
|
1320.4.7
by Joe Daly
fix up some variable names, and namespaces paths in *.cc files, and add constant for UNINITIALIZED |
117 |
LoggingStats::LoggingStats(string name_arg) : Logging(name_arg) |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
118 |
{
|
1320.5.15
by Joe Daly
add a new test to make sure nothing crashes when the scoreboard is full, lower the limit in logging_stats to accomadate this test, its not a reasonable value but the test is necessary |
119 |
current_scoreboard= new Scoreboard(sysvar_logging_stats_scoreboard_size, |
120 |
sysvar_logging_stats_bucket_count); |
|
1320.5.6
by Joe Daly
first pass at using a module vector approach of scoreboard |
121 |
|
1491.4.1
by Joe Daly
move any tracking logic out of logging_stats its almost just a entry point, rework logic on cumulative stats by user to use a atomic rather then a lock |
122 |
cumulative_stats= new CumulativeStats(sysvar_logging_stats_max_user_count); |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
123 |
}
|
124 |
||
125 |
LoggingStats::~LoggingStats() |
|
126 |
{
|
|
1320.5.9
by Joe Daly
add destructors |
127 |
delete current_scoreboard; |
1491.4.1
by Joe Daly
move any tracking logic out of logging_stats its almost just a entry point, rework logic on cumulative stats by user to use a atomic rather then a lock |
128 |
delete cumulative_stats; |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
129 |
}
|
130 |
||
1320.5.2
by Joe Daly
use a vector instead of array for current user stats, rename score_board to scoreboard, move code around to be more OO |
131 |
void LoggingStats::updateCurrentScoreboard(ScoreboardSlot *scoreboard_slot, |
132 |
Session *session) |
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
133 |
{
|
2227.4.8
by Olaf van der Spek
Session::lex() |
134 |
enum_sql_command sql_command= session->lex().sql_command; |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
135 |
|
1561.3.1
by Joe Daly
add status_vars to scoreboard, initial pass |
136 |
scoreboard_slot->getUserCommands()->logCommand(sql_command); |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
137 |
|
1561.3.8
by Joe Daly
try and create some logic with header files, and implement flush status properly |
138 |
/* If a flush occurred copy over values before setting new values */
|
139 |
if (scoreboard_slot->getStatusVars()->hasBeenFlushed(session)) |
|
140 |
{
|
|
141 |
cumulative_stats->logGlobalStatusVars(scoreboard_slot); |
|
142 |
}
|
|
1561.3.1
by Joe Daly
add status_vars to scoreboard, initial pass |
143 |
scoreboard_slot->getStatusVars()->logStatusVar(session); |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
144 |
}
|
145 |
||
1900.3.1
by Andrew Hutchings
Add FLUSH GLOBAL STATUS; command |
146 |
bool LoggingStats::resetGlobalScoreboard() |
147 |
{
|
|
148 |
cumulative_stats->getGlobalStatusVars()->reset(); |
|
1928.1.1
by Andrew Hutchings
Fix broken Global Status test |
149 |
cumulative_stats->getGlobalStats()->getUserCommands()->reset(); |
1900.3.1
by Andrew Hutchings
Add FLUSH GLOBAL STATUS; command |
150 |
|
1928.1.1
by Andrew Hutchings
Fix broken Global Status test |
151 |
ScoreBoardVectors *vector_of_scoreboard_vectors= |
1900.3.1
by Andrew Hutchings
Add FLUSH GLOBAL STATUS; command |
152 |
current_scoreboard->getVectorOfScoreboardVectors(); |
153 |
||
1928.1.1
by Andrew Hutchings
Fix broken Global Status test |
154 |
ScoreBoardVectors::iterator v_of_scoreboard_v_begin_it= vector_of_scoreboard_vectors->begin(); |
1900.3.1
by Andrew Hutchings
Add FLUSH GLOBAL STATUS; command |
155 |
|
1928.1.1
by Andrew Hutchings
Fix broken Global Status test |
156 |
ScoreBoardVectors::iterator v_of_scoreboard_v_end_it= vector_of_scoreboard_vectors->end(); |
1900.3.1
by Andrew Hutchings
Add FLUSH GLOBAL STATUS; command |
157 |
|
158 |
for (; v_of_scoreboard_v_begin_it != v_of_scoreboard_v_end_it; ++v_of_scoreboard_v_begin_it) |
|
159 |
{
|
|
1966.2.6
by Brian Aker
This is from the catalog patch (I'm pushing it up as its own little thing |
160 |
std::vector<ScoreboardSlot* > *scoreboard_vector= *v_of_scoreboard_v_begin_it; |
1900.3.1
by Andrew Hutchings
Add FLUSH GLOBAL STATUS; command |
161 |
|
1966.2.6
by Brian Aker
This is from the catalog patch (I'm pushing it up as its own little thing |
162 |
std::vector<ScoreboardSlot* >::iterator scoreboard_vector_it= scoreboard_vector->begin(); |
163 |
std::vector<ScoreboardSlot* >::iterator scoreboard_vector_end= scoreboard_vector->end(); |
|
1900.3.1
by Andrew Hutchings
Add FLUSH GLOBAL STATUS; command |
164 |
for (; scoreboard_vector_it != scoreboard_vector_end; ++scoreboard_vector_it) |
165 |
{
|
|
166 |
ScoreboardSlot *scoreboard_slot= *scoreboard_vector_it; |
|
1928.1.1
by Andrew Hutchings
Fix broken Global Status test |
167 |
scoreboard_slot->getStatusVars()->reset(); |
168 |
scoreboard_slot->getUserCommands()->reset(); |
|
1900.3.1
by Andrew Hutchings
Add FLUSH GLOBAL STATUS; command |
169 |
}
|
170 |
}
|
|
171 |
||
172 |
return false; |
|
173 |
}
|
|
174 |
||
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
175 |
bool LoggingStats::post(Session *session) |
176 |
{
|
|
1320.5.1
by Joe Daly
add cumulative stats |
177 |
if (! isEnabled() || (session->getSessionId() == 0)) |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
178 |
{
|
179 |
return false; |
|
180 |
}
|
|
181 |
||
1320.5.6
by Joe Daly
first pass at using a module vector approach of scoreboard |
182 |
ScoreboardSlot *scoreboard_slot= current_scoreboard->findScoreboardSlotToLog(session); |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
183 |
|
1320.5.15
by Joe Daly
add a new test to make sure nothing crashes when the scoreboard is full, lower the limit in logging_stats to accomadate this test, its not a reasonable value but the test is necessary |
184 |
/* Its possible that the scoreboard is full with active sessions in which case
|
185 |
this could be null */
|
|
186 |
if (scoreboard_slot) |
|
187 |
{
|
|
188 |
updateCurrentScoreboard(scoreboard_slot, session); |
|
189 |
}
|
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
190 |
return false; |
191 |
}
|
|
192 |
||
193 |
bool LoggingStats::postEnd(Session *session) |
|
194 |
{
|
|
1320.5.1
by Joe Daly
add cumulative stats |
195 |
if (! isEnabled() || (session->getSessionId() == 0)) |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
196 |
{
|
197 |
return false; |
|
198 |
}
|
|
199 |
||
1625.2.1
by Joe Daly
initial user stats impl |
200 |
bool isInScoreboard= false; |
201 |
ScoreboardSlot *scoreboard_slot= current_scoreboard->findOurScoreboardSlot(session); |
|
1320.5.6
by Joe Daly
first pass at using a module vector approach of scoreboard |
202 |
|
1320.5.11
by Joe Daly
correct initializations and make sure delete call is only called if needed |
203 |
if (scoreboard_slot) |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
204 |
{
|
1625.2.1
by Joe Daly
initial user stats impl |
205 |
isInScoreboard= true; |
206 |
}
|
|
207 |
else
|
|
208 |
{
|
|
209 |
/* the session did not have a slot reserved, that could be because the scoreboard was
|
|
210 |
full, but most likely its a failed authentication so post() is never called where
|
|
211 |
the slot is assigned. Log the global status values below, and if the user has a slot
|
|
212 |
log to it, but do not reserve a new slot for a user. If it was a failed authentication
|
|
213 |
the scoreboard would be filled up quickly with invalid users.
|
|
214 |
*/
|
|
215 |
scoreboard_slot= new ScoreboardSlot(); |
|
2008.1.1
by Brian Aker
Adding user identifier that makes use of a shared ptr to handle concurrency |
216 |
scoreboard_slot->setUser(session->user()->username()); |
217 |
scoreboard_slot->setIp(session->user()->address()); |
|
1625.2.1
by Joe Daly
initial user stats impl |
218 |
}
|
219 |
||
220 |
scoreboard_slot->getStatusVars()->logStatusVar(session); |
|
2275.4.1
by Joseph Daly
fix bug 760367 |
221 |
boost::posix_time::ptime end(boost::posix_time::microsec_clock::universal_time()); |
2275.4.2
by Joseph Daly
merge trunk |
222 |
uint64_t end_time= (end - session->times.epoch()).total_seconds(); |
223 |
scoreboard_slot->getStatusVars()->getStatusVarCounters()->connection_time= end_time - session->times.getConnectSeconds(); |
|
1625.2.1
by Joe Daly
initial user stats impl |
224 |
|
225 |
cumulative_stats->logUserStats(scoreboard_slot, isInScoreboard); |
|
226 |
cumulative_stats->logGlobalStats(scoreboard_slot); |
|
227 |
cumulative_stats->logGlobalStatusVars(scoreboard_slot); |
|
228 |
||
229 |
if (isInScoreboard) |
|
230 |
{
|
|
231 |
scoreboard_slot->reset(); |
|
232 |
}
|
|
233 |
else
|
|
234 |
{
|
|
1320.5.11
by Joe Daly
correct initializations and make sure delete call is only called if needed |
235 |
delete scoreboard_slot; |
1625.2.1
by Joe Daly
initial user stats impl |
236 |
}
|
1320.5.2
by Joe Daly
use a vector instead of array for current user stats, rename score_board to scoreboard, move code around to be more OO |
237 |
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
238 |
return false; |
239 |
}
|
|
240 |
||
241 |
/* Plugin initialization and system variables */
|
|
242 |
||
243 |
static LoggingStats *logging_stats= NULL; |
|
244 |
||
1320.5.1
by Joe Daly
add cumulative stats |
245 |
static CurrentCommandsTool *current_commands_tool= NULL; |
246 |
||
247 |
static CumulativeCommandsTool *cumulative_commands_tool= NULL; |
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
248 |
|
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
249 |
static GlobalStatementsTool *global_statements_tool= NULL; |
250 |
||
251 |
static SessionStatementsTool *session_statements_tool= NULL; |
|
1491.4.2
by Joe Daly
rework atomics on cumulative user tables |
252 |
|
1561.3.5
by Joe Daly
remove old SESSION_STATUS tables, add new ones |
253 |
static StatusTool *global_status_tool= NULL; |
1561.3.2
by Joe Daly
add session_status_new |
254 |
|
1561.3.5
by Joe Daly
remove old SESSION_STATUS tables, add new ones |
255 |
static StatusTool *session_status_tool= NULL; |
1561.3.4
by Joe Daly
global status changes, will need updates to combine session and global status to a realistic class structure |
256 |
|
1625.2.1
by Joe Daly
initial user stats impl |
257 |
static CumulativeUserStatsTool *cumulative_user_stats_tool= NULL; |
258 |
||
1711.7.2
by Joseph Daly
add memory usage |
259 |
static ScoreboardStatsTool *scoreboard_stats_tool= NULL; |
260 |
||
1964.2.13
by Monty Taylor
logging_stats |
261 |
static void enable(Session *, sql_var_t) |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
262 |
{
|
263 |
if (logging_stats) |
|
264 |
{
|
|
1964.2.13
by Monty Taylor
logging_stats |
265 |
if (sysvar_logging_stats_enabled) |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
266 |
{
|
267 |
logging_stats->enable(); |
|
268 |
}
|
|
269 |
else
|
|
270 |
{
|
|
271 |
logging_stats->disable(); |
|
272 |
}
|
|
273 |
}
|
|
274 |
}
|
|
275 |
||
2246.3.2
by Olaf van der Spek
Refactor |
276 |
static int init(drizzled::module::Context &context) |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
277 |
{
|
2246.3.2
by Olaf van der Spek
Refactor |
278 |
const module::option_map &vm= context.getOptions(); |
279 |
sysvar_logging_stats_enabled= not vm.count("disable"); |
|
280 |
||
281 |
logging_stats= new LoggingStats("logging_stats"); |
|
2246.3.1
by Olaf van der Spek
Remove std::nothrow from new() |
282 |
current_commands_tool= new CurrentCommandsTool(logging_stats); |
283 |
cumulative_commands_tool= new CumulativeCommandsTool(logging_stats); |
|
284 |
global_statements_tool= new GlobalStatementsTool(logging_stats); |
|
285 |
session_statements_tool= new SessionStatementsTool(logging_stats); |
|
286 |
session_status_tool= new StatusTool(logging_stats, true); |
|
287 |
global_status_tool= new StatusTool(logging_stats, false); |
|
288 |
cumulative_user_stats_tool= new CumulativeUserStatsTool(logging_stats); |
|
289 |
scoreboard_stats_tool= new ScoreboardStatsTool(logging_stats); |
|
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
290 |
|
1381
by Brian Aker
Merge Monty. |
291 |
context.add(logging_stats); |
1320.5.10
by Joe Daly
merge trunk |
292 |
context.add(current_commands_tool); |
293 |
context.add(cumulative_commands_tool); |
|
1491.4.6
by Joe Daly
rework stats_schema use static char * for command strings |
294 |
context.add(global_statements_tool); |
295 |
context.add(session_statements_tool); |
|
1561.3.2
by Joe Daly
add session_status_new |
296 |
context.add(session_status_tool); |
1561.3.4
by Joe Daly
global status changes, will need updates to combine session and global status to a realistic class structure |
297 |
context.add(global_status_tool); |
1625.2.1
by Joe Daly
initial user stats impl |
298 |
context.add(cumulative_user_stats_tool); |
1711.7.2
by Joseph Daly
add memory usage |
299 |
context.add(scoreboard_stats_tool); |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
300 |
|
301 |
if (sysvar_logging_stats_enabled) |
|
302 |
logging_stats->enable(); |
|
303 |
||
1964.2.13
by Monty Taylor
logging_stats |
304 |
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("max_user_count", sysvar_logging_stats_max_user_count)); |
305 |
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("bucket_count", sysvar_logging_stats_bucket_count)); |
|
306 |
context.registerVariable(new sys_var_constrained_value_readonly<uint32_t>("scoreboard_size", sysvar_logging_stats_scoreboard_size)); |
|
307 |
context.registerVariable(new sys_var_bool_ptr("enable", &sysvar_logging_stats_enabled, enable)); |
|
308 |
||
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
309 |
return 0; |
310 |
}
|
|
311 |
||
312 |
||
1660.11.1
by Vijay Samuel
Merge refactored commandline and modified test cases for logging_stats |
313 |
static void init_options(drizzled::module::option_context &context) |
314 |
{
|
|
315 |
context("max-user-count", |
|
1964.2.13
by Monty Taylor
logging_stats |
316 |
po::value<max_user_count_constraint>(&sysvar_logging_stats_max_user_count)->default_value(500), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
317 |
_("Max number of users that will be logged")); |
1660.11.1
by Vijay Samuel
Merge refactored commandline and modified test cases for logging_stats |
318 |
context("bucket-count", |
1964.2.13
by Monty Taylor
logging_stats |
319 |
po::value<bucket_count_constraint>(&sysvar_logging_stats_bucket_count)->default_value(10), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
320 |
_("Max number of range locks to use for Scoreboard")); |
1660.11.1
by Vijay Samuel
Merge refactored commandline and modified test cases for logging_stats |
321 |
context("scoreboard-size", |
1964.2.13
by Monty Taylor
logging_stats |
322 |
po::value<scoreboard_size_constraint>(&sysvar_logging_stats_scoreboard_size)->default_value(2000), |
2068.4.1
by Andrew Hutchings
Fix intl domain |
323 |
_("Max number of concurrent sessions that will be logged")); |
324 |
context("disable", _("Enable Logging Statistics Collection")); |
|
1660.11.1
by Vijay Samuel
Merge refactored commandline and modified test cases for logging_stats |
325 |
}
|
326 |
||
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
327 |
DRIZZLE_DECLARE_PLUGIN
|
328 |
{
|
|
329 |
DRIZZLE_VERSION_ID, |
|
330 |
"logging_stats", |
|
331 |
"0.1", |
|
332 |
"Joseph Daly", |
|
333 |
N_("User Statistics as DATA_DICTIONARY tables"), |
|
334 |
PLUGIN_LICENSE_BSD, |
|
335 |
init, /* Plugin Init */ |
|
2095.3.1
by Monty Taylor
Re-purpose the old plugin sysvar slot in the struct to be a depends list. |
336 |
NULL, /* depends */ |
1660.11.1
by Vijay Samuel
Merge refactored commandline and modified test cases for logging_stats |
337 |
init_options /* config options */ |
1320.4.1
by Joe Daly
scoreboard implementation for statistics |
338 |
}
|
339 |
DRIZZLE_DECLARE_PLUGIN_END; |