2
* Copyright (c) 2009, Padraig O'Sullivan
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are met:
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 Padraig O'Sullivan 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.
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.
31
#include "drizzled/show.h"
32
#include "drizzled/gettext.h"
34
#include "stats_table.h"
35
#include "analysis_table.h"
36
#include "sysvar_holder.h"
42
using namespace drizzled;
45
* DATA_DICTIONARY tables.
47
static AnalysisTableTool *analysis_table_tool;
49
static StatsTableTool *stats_table_tool;
52
* System variable related variables.
54
static char *sysvar_memcached_servers= NULL;
57
* Initialize the memcached stats plugin.
59
* @param[in] registry the drizzled::plugin::Registry singleton
60
* @return false on success; true on failure.
62
static int init(plugin::Context &context)
65
SysvarHolder &sysvar_holder= SysvarHolder::singleton();
66
sysvar_holder.setServersString(sysvar_memcached_servers);
68
/* we are good to go */
69
stats_table_tool= new(std::nothrow)StatsTableTool;
70
context.add(stats_table_tool);
72
analysis_table_tool= new(std::nothrow)AnalysisTableTool;
73
context.add(analysis_table_tool);
78
static int check_memc_servers(Session *,
83
char buff[STRING_BUFFER_USUAL_SIZE];
84
int len= sizeof(buff);
85
const char *input= value->val_str(value, buff, &len);
89
SysvarHolder &sysvar_holder= SysvarHolder::singleton();
90
sysvar_holder.setServersStringVar(input);
91
*(bool *) save= (bool) true;
95
*(bool *) save= (bool) false;
99
static void set_memc_servers(Session *,
104
if (*(bool *) save != false)
106
SysvarHolder &sysvar_holder= SysvarHolder::singleton();
107
sysvar_holder.updateServersSysvar((const char **) var_ptr);
111
static DRIZZLE_SYSVAR_STR(servers,
112
sysvar_memcached_servers,
114
N_("List of memcached servers."),
115
check_memc_servers, /* check func */
116
set_memc_servers, /* update func */
117
""); /* default value */
119
static drizzle_sys_var *system_variables[]=
121
DRIZZLE_SYSVAR(servers),
125
DRIZZLE_DECLARE_PLUGIN
130
"Padraig O'Sullivan",
131
N_("Memcached Stats as I_S tables"),
133
init, /* Plugin Init */
134
system_variables, /* system variables */
135
NULL /* config options */
137
DRIZZLE_DECLARE_PLUGIN_END;