1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
5
* Copyright (C) 2010 Joseph Daly
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; version 2 of the License.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#include <boost/lexical_cast.hpp>
23
#include "status_helper.h"
24
#include "drizzled/set_var.h"
25
#include "drizzled/drizzled.h"
26
#include "plugin/myisam/myisam.h"
28
#include <drizzled/refresh_version.h>
37
extern time_t server_start_time;
38
extern time_t flush_status_time;
40
static int show_starttime_new(drizzle_show_var *var, char *buff)
44
*((long *)buff)= (long) (time(NULL) - server_start_time);
48
static int show_flushstatustime_new(drizzle_show_var *var, char *buff)
52
*((long *)buff)= (long) (time(NULL) - flush_status_time);
56
static int show_connection_count_new(drizzle_show_var *var, char *buff)
60
*((uint32_t *)buff)= connection_count;
64
static st_show_var_func_container show_starttime_cont_new= { &show_starttime_new };
66
static st_show_var_func_container show_flushstatustime_cont_new= { &show_flushstatustime_new };
68
static st_show_var_func_container show_connection_count_cont_new= { &show_connection_count_new };
70
string StatusHelper::fillHelper(system_status_var *status_var, char *value, SHOW_TYPE show_type)
76
case SHOW_DOUBLE_STATUS:
77
value= ((char *) status_var + (ulong) value);
81
oss << *(double *) value;
82
return_value= oss.str();
84
case SHOW_LONG_STATUS:
85
value= ((char *) status_var + (ulong) value);
88
return_value=boost::lexical_cast<std::string>(*(long*) value);
90
case SHOW_LONGLONG_STATUS:
91
value= ((char *) status_var + (uint64_t) value);
94
return_value=boost::lexical_cast<std::string>(*(int64_t*) value);
97
return_value=boost::lexical_cast<std::string>(*(size_t*) value);
100
return_value=boost::lexical_cast<std::string>((int64_t) *(ha_rows*) value);
104
return_value= *(bool*) value ? "ON" : "OFF";
107
case SHOW_INT_NOFLUSH: // the difference lies in refresh_status()
108
return_value=boost::lexical_cast<std::string>((long) *(uint32_t*) value);
119
return_value= *(char**) value;
124
break; // Return empty string
125
case SHOW_SYS: // Cannot happen
134
drizzle_show_var StatusHelper::status_vars_defs[]=
136
{"Aborted_clients", (char*) offsetof(system_status_var, aborted_threads), SHOW_LONGLONG_STATUS},
137
{"Aborted_connects", (char*) offsetof(system_status_var, aborted_connects), SHOW_LONGLONG_STATUS},
138
{"Bytes_received", (char*) offsetof(system_status_var, bytes_received), SHOW_LONGLONG_STATUS},
139
{"Bytes_sent", (char*) offsetof(system_status_var, bytes_sent), SHOW_LONGLONG_STATUS},
140
{"Connections", (char*) ¤t_global_counters.connections, SHOW_LONGLONG},
141
{"Created_tmp_disk_tables", (char*) offsetof(system_status_var, created_tmp_disk_tables), SHOW_LONGLONG_STATUS},
142
{"Created_tmp_tables", (char*) offsetof(system_status_var, created_tmp_tables), SHOW_LONGLONG_STATUS},
143
{"Flush_commands", (char*) &refresh_version, SHOW_INT_NOFLUSH},
144
{"Handler_commit", (char*) offsetof(system_status_var, ha_commit_count), SHOW_LONGLONG_STATUS},
145
{"Handler_delete", (char*) offsetof(system_status_var, ha_delete_count), SHOW_LONGLONG_STATUS},
146
{"Handler_prepare", (char*) offsetof(system_status_var, ha_prepare_count), SHOW_LONGLONG_STATUS},
147
{"Handler_read_first", (char*) offsetof(system_status_var, ha_read_first_count), SHOW_LONGLONG_STATUS},
148
{"Handler_read_key", (char*) offsetof(system_status_var, ha_read_key_count), SHOW_LONGLONG_STATUS},
149
{"Handler_read_next", (char*) offsetof(system_status_var, ha_read_next_count), SHOW_LONGLONG_STATUS},
150
{"Handler_read_prev", (char*) offsetof(system_status_var, ha_read_prev_count), SHOW_LONGLONG_STATUS},
151
{"Handler_read_rnd", (char*) offsetof(system_status_var, ha_read_rnd_count), SHOW_LONGLONG_STATUS},
152
{"Handler_read_rnd_next", (char*) offsetof(system_status_var, ha_read_rnd_next_count), SHOW_LONGLONG_STATUS},
153
{"Handler_rollback", (char*) offsetof(system_status_var, ha_rollback_count), SHOW_LONGLONG_STATUS},
154
{"Handler_savepoint", (char*) offsetof(system_status_var, ha_savepoint_count), SHOW_LONGLONG_STATUS},
155
{"Handler_savepoint_rollback",(char*) offsetof(system_status_var, ha_savepoint_rollback_count), SHOW_LONGLONG_STATUS},
156
{"Handler_update", (char*) offsetof(system_status_var, ha_update_count), SHOW_LONGLONG_STATUS},
157
{"Handler_write", (char*) offsetof(system_status_var, ha_write_count), SHOW_LONGLONG_STATUS},
158
{"Last_query_cost", (char*) offsetof(system_status_var, last_query_cost), SHOW_DOUBLE_STATUS},
159
{"Max_used_connections", (char*) ¤t_global_counters.max_used_connections, SHOW_LONGLONG},
160
{"Questions", (char*) offsetof(system_status_var, questions), SHOW_LONGLONG_STATUS},
161
{"Select_full_join", (char*) offsetof(system_status_var, select_full_join_count), SHOW_LONGLONG_STATUS},
162
{"Select_full_range_join", (char*) offsetof(system_status_var, select_full_range_join_count), SHOW_LONGLONG_STATUS},
163
{"Select_range", (char*) offsetof(system_status_var, select_range_count), SHOW_LONGLONG_STATUS},
164
{"Select_range_check", (char*) offsetof(system_status_var, select_range_check_count), SHOW_LONGLONG_STATUS},
165
{"Select_scan", (char*) offsetof(system_status_var, select_scan_count), SHOW_LONGLONG_STATUS},
166
{"Sessions_connected", (char*) &show_connection_count_cont_new, SHOW_FUNC},
167
{"Slow_queries", (char*) offsetof(system_status_var, long_query_count), SHOW_LONGLONG_STATUS},
168
{"Sort_merge_passes", (char*) offsetof(system_status_var, filesort_merge_passes), SHOW_LONGLONG_STATUS},
169
{"Sort_range", (char*) offsetof(system_status_var, filesort_range_count), SHOW_LONGLONG_STATUS},
170
{"Sort_rows", (char*) offsetof(system_status_var, filesort_rows), SHOW_LONGLONG_STATUS},
171
{"Sort_scan", (char*) offsetof(system_status_var, filesort_scan_count), SHOW_LONGLONG_STATUS},
172
{"Table_locks_immediate", (char*) ¤t_global_counters.locks_immediate, SHOW_LONGLONG},
173
{"Table_locks_waited", (char*) ¤t_global_counters.locks_waited, SHOW_LONGLONG},
174
{"Uptime", (char*) &show_starttime_cont_new, SHOW_FUNC},
175
{"Uptime_since_flush_status", (char*) &show_flushstatustime_cont_new, SHOW_FUNC},
176
{NULL, NULL, SHOW_LONGLONG}
179
} /* namespace drizzled */