53
53
add_field("COUNT_ADMIN", TableFunction::NUMBER);
56
CommandsTool::Generator::Generator(Field **arg, LoggingStats *in_logging_stats) :
57
plugin::TableFunction::Generator(arg)
59
pthread_rwlock_rdlock(&LOCK_scoreboard);
56
CurrentCommandsTool::Generator::Generator(Field **arg, LoggingStats *logging_stats) :
57
plugin::TableFunction::Generator(arg)
59
isEnabled= logging_stats->isEnabled();
61
if (isEnabled == false)
66
current_scoreboard= logging_stats->getCurrentScoreboard();
69
vector_of_scoreboard_vectors_it= current_scoreboard->getVectorOfScoreboardVectors()->begin();
70
vector_of_scoreboard_vectors_end= current_scoreboard->getVectorOfScoreboardVectors()->end();
72
setVectorIteratorsAndLock(current_bucket);
75
void CurrentCommandsTool::Generator::setVectorIteratorsAndLock(uint32_t bucket_number)
77
vector<ScoreboardSlot* > *scoreboard_vector=
78
current_scoreboard->getVectorOfScoreboardVectors()->at(bucket_number);
80
current_lock= current_scoreboard->getVectorOfScoreboardLocks()->at(bucket_number);
82
scoreboard_vector_it= scoreboard_vector->begin();
83
scoreboard_vector_end= scoreboard_vector->end();
84
pthread_rwlock_rdlock(current_lock);
87
bool CurrentCommandsTool::Generator::populate()
89
if (isEnabled == false)
94
while (vector_of_scoreboard_vectors_it != vector_of_scoreboard_vectors_end)
96
while (scoreboard_vector_it != scoreboard_vector_end)
98
ScoreboardSlot *scoreboard_slot= *scoreboard_vector_it;
99
if (scoreboard_slot->isInUse())
101
UserCommands *user_commands= scoreboard_slot->getUserCommands();
102
push(scoreboard_slot->getUser());
103
push(scoreboard_slot->getIp());
104
push(user_commands->getSelectCount());
105
push(user_commands->getDeleteCount());
106
push(user_commands->getUpdateCount());
107
push(user_commands->getInsertCount());
108
push(user_commands->getRollbackCount());
109
push(user_commands->getCommitCount());
110
push(user_commands->getCreateCount());
111
push(user_commands->getAlterCount());
112
push(user_commands->getDropCount());
113
push(user_commands->getAdminCount());
114
++scoreboard_vector_it;
117
++scoreboard_vector_it;
120
++vector_of_scoreboard_vectors_it;
121
pthread_rwlock_unlock(current_lock);
123
if (vector_of_scoreboard_vectors_it != vector_of_scoreboard_vectors_end)
125
setVectorIteratorsAndLock(current_bucket);
132
CumulativeCommandsTool::CumulativeCommandsTool(LoggingStats *logging_stats) :
133
plugin::TableFunction("DATA_DICTIONARY", "CUMULATIVE_SQL_COMMANDS")
135
outer_logging_stats= logging_stats;
138
add_field("COUNT_SELECT", TableFunction::NUMBER);
139
add_field("COUNT_DELETE", TableFunction::NUMBER);
140
add_field("COUNT_UPDATE", TableFunction::NUMBER);
141
add_field("COUNT_INSERT", TableFunction::NUMBER);
142
add_field("COUNT_ROLLBACK", TableFunction::NUMBER);
143
add_field("COUNT_COMMIT", TableFunction::NUMBER);
144
add_field("COUNT_CREATE", TableFunction::NUMBER);
145
add_field("COUNT_ALTER", TableFunction::NUMBER);
146
add_field("COUNT_DROP", TableFunction::NUMBER);
147
add_field("COUNT_ADMIN", TableFunction::NUMBER);
150
CumulativeCommandsTool::Generator::Generator(Field **arg, LoggingStats *in_logging_stats) :
151
plugin::TableFunction::Generator(arg)
60
153
logging_stats= in_logging_stats;
62
156
if (logging_stats->isEnabled())
158
total_records= logging_stats->getCumulativeStatsByUserIndex();
68
record_number= logging_stats->getScoreBoardSize();
72
CommandsTool::Generator::~Generator()
74
pthread_rwlock_unlock(&LOCK_scoreboard);
77
bool CommandsTool::Generator::populate()
79
if (record_number == logging_stats->getScoreBoardSize())
166
bool CumulativeCommandsTool::Generator::populate()
168
if (record_number == total_records)
84
ScoreBoardSlot *score_board_slots= logging_stats->getScoreBoardSlots();
86
while (record_number < logging_stats->getScoreBoardSize())
88
ScoreBoardSlot *score_board_slot= &score_board_slots[record_number];
89
if (score_board_slot->isInUse())
91
UserCommands *user_commands= score_board_slot->getUserCommands();
92
push(score_board_slot->getUser());
93
push(score_board_slot->getIp());
94
push(user_commands->getSelectCount());
95
push(user_commands->getDeleteCount());
96
push(user_commands->getUpdateCount());
97
push(user_commands->getInsertCount());
98
push(user_commands->getRollbackCount());
99
push(user_commands->getCommitCount());
100
push(user_commands->getCreateCount());
101
push(user_commands->getAlterCount());
102
push(user_commands->getDropCount());
103
push(user_commands->getAdminCount());
173
ScoreboardSlot *cumulative_scoreboard_slot=
174
logging_stats->getCumulativeStatsByUserVector()->at(record_number);
176
push(cumulative_scoreboard_slot->getUser());
177
push(cumulative_scoreboard_slot->getUserCommands()->getSelectCount());
178
push(cumulative_scoreboard_slot->getUserCommands()->getDeleteCount());
179
push(cumulative_scoreboard_slot->getUserCommands()->getUpdateCount());
180
push(cumulative_scoreboard_slot->getUserCommands()->getInsertCount());
181
push(cumulative_scoreboard_slot->getUserCommands()->getRollbackCount());
182
push(cumulative_scoreboard_slot->getUserCommands()->getCommitCount());
183
push(cumulative_scoreboard_slot->getUserCommands()->getCreateCount());
184
push(cumulative_scoreboard_slot->getUserCommands()->getAlterCount());
185
push(cumulative_scoreboard_slot->getUserCommands()->getDropCount());
186
push(cumulative_scoreboard_slot->getUserCommands()->getAdminCount());