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"
33
#include "drizzled/plugin/info_schema_table.h"
35
#include "stats_table.h"
36
#include "analysis_table.h"
37
#include "sysvar_holder.h"
43
using namespace drizzled;
46
* DATA_DICTIONARY tables.
48
static AnalysisTableTool *analysis_table_tool;
50
static StatsTableTool *stats_table_tool;
53
* System variable related variables.
55
static char *sysvar_memcached_servers= NULL;
58
* Initialize the memcached stats plugin.
60
* @param[in] registry the drizzled::plugin::Registry singleton
61
* @return false on success; true on failure.
63
static int init(plugin::Registry ®istry)
66
SysvarHolder &sysvar_holder= SysvarHolder::singleton();
67
sysvar_holder.setServersString(sysvar_memcached_servers);
69
/* we are good to go */
70
stats_table_tool= new(std::nothrow)StatsTableTool;
71
registry.add(stats_table_tool);
73
analysis_table_tool= new(std::nothrow)AnalysisTableTool;
74
registry.add(analysis_table_tool);
80
* Clean up the memcached stats plugin.
82
* @param[in] registry the drizzled::plugin::Registry singleton
83
* @return false on success; true on failure
85
static int deinit(plugin::Registry ®istry)
87
registry.remove(stats_table_tool);
88
delete stats_table_tool;
89
registry.remove(analysis_table_tool);
90
delete analysis_table_tool;
94
static int check_memc_servers(Session *,
99
char buff[STRING_BUFFER_USUAL_SIZE];
100
int len= sizeof(buff);
101
const char *input= value->val_str(value, buff, &len);
105
SysvarHolder &sysvar_holder= SysvarHolder::singleton();
106
sysvar_holder.setServersStringVar(input);
107
*(bool *) save= (bool) true;
111
*(bool *) save= (bool) false;
115
static void set_memc_servers(Session *,
120
if (*(bool *) save != false)
122
SysvarHolder &sysvar_holder= SysvarHolder::singleton();
123
sysvar_holder.updateServersSysvar((const char **) var_ptr);
127
static DRIZZLE_SYSVAR_STR(servers,
128
sysvar_memcached_servers,
130
N_("List of memcached servers."),
131
check_memc_servers, /* check func */
132
set_memc_servers, /* update func */
133
""); /* default value */
135
static drizzle_sys_var *system_variables[]=
137
DRIZZLE_SYSVAR(servers),
141
DRIZZLE_DECLARE_PLUGIN
146
"Padraig O'Sullivan",
147
N_("Memcached Stats as I_S tables"),
149
init, /* Plugin Init */
150
deinit, /* Plugin Deinit */
151
system_variables, /* system variables */
152
NULL /* config options */
154
DRIZZLE_DECLARE_PLUGIN_END;