Addition of show eventtimes and /events/times URL to maxinfo
This commit is contained in:
@ -33,6 +33,7 @@
|
||||
#include <housekeeper.h>
|
||||
#include <config.h>
|
||||
#include <mysql.h>
|
||||
#include <resultset.h>
|
||||
|
||||
#define PROFILE_POLL 0
|
||||
|
||||
@ -1561,3 +1562,69 @@ poll_get_stat(POLL_STAT stat)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a row to the result set that defines the event queue statistics
|
||||
*
|
||||
* @param set The result set
|
||||
* @param data The index of the row to send
|
||||
* @return The next row or NULL
|
||||
*/
|
||||
static RESULT_ROW *
|
||||
eventTimesRowCallback(RESULTSET *set, void *data)
|
||||
{
|
||||
int *rowno = (int *)data;
|
||||
char buf[40];
|
||||
RESULT_ROW *row;
|
||||
|
||||
if (*rowno >= N_QUEUE_TIMES)
|
||||
{
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
row = resultset_make_row(set);
|
||||
if (*rowno == 0)
|
||||
resultset_row_set(row, 0, "< 100ms");
|
||||
else if (*rowno == N_QUEUE_TIMES - 1)
|
||||
{
|
||||
sprintf(buf, "> %2d00ms", N_QUEUE_TIMES);
|
||||
resultset_row_set(row, 0, buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(buf, "%2d00 - %2d00ms", *rowno, (*rowno) + 1);
|
||||
resultset_row_set(row, 0, buf);
|
||||
}
|
||||
sprintf(buf, "%d", queueStats.qtimes[*rowno]);
|
||||
resultset_row_set(row, 1, buf);
|
||||
sprintf(buf, "%d", queueStats.exectimes[*rowno]);
|
||||
resultset_row_set(row, 2, buf);
|
||||
(*rowno)++;
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a resultset that has the current set of services in it
|
||||
*
|
||||
* @return A Result set
|
||||
*/
|
||||
RESULTSET *
|
||||
eventTimesGetList()
|
||||
{
|
||||
RESULTSET *set;
|
||||
int *data;
|
||||
|
||||
if ((data = (int *)malloc(sizeof(int))) == NULL)
|
||||
return NULL;
|
||||
*data = 0;
|
||||
if ((set = resultset_create(eventTimesRowCallback, data)) == NULL)
|
||||
{
|
||||
free(data);
|
||||
return NULL;
|
||||
}
|
||||
resultset_add_column(set, "Duration", 20, COL_TYPE_VARCHAR);
|
||||
resultset_add_column(set, "No. Events Queued", 12, COL_TYPE_VARCHAR);
|
||||
resultset_add_column(set, "No. Events Executed", 12, COL_TYPE_VARCHAR);
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
*/
|
||||
#include <dcb.h>
|
||||
#include <gwbitmask.h>
|
||||
#include <resultset.h>
|
||||
|
||||
/**
|
||||
* @file poll.h The poll related functionality
|
||||
@ -63,4 +64,5 @@ void poll_add_epollin_event_to_dcb(DCB* dcb, GWBUF* buf);
|
||||
extern void dShowEventQ(DCB *dcb);
|
||||
extern void dShowEventStats(DCB *dcb);
|
||||
extern int poll_get_stat(POLL_STAT stat);
|
||||
extern RESULTSET *eventTimesGetList();
|
||||
#endif
|
||||
|
||||
@ -666,6 +666,10 @@ PARSE_ERROR err;
|
||||
|
||||
typedef RESULTSET *(*RESULTSETFUNC)();
|
||||
|
||||
/**
|
||||
* Table that maps a URI to a function to call to
|
||||
* to obtain the result set related to that URI
|
||||
*/
|
||||
static struct uri_table {
|
||||
char *uri;
|
||||
RESULTSETFUNC func;
|
||||
@ -678,6 +682,7 @@ static struct uri_table {
|
||||
{ "/servers", serverGetList },
|
||||
{ "/variables", maxinfo_variables },
|
||||
{ "/status", maxinfo_status },
|
||||
{ "/event/times", eventTimesGetList },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ maxinfo_execute(DCB *dcb, MAXINFO_TREE *tree)
|
||||
* Fetch the list of services and stream as a result set
|
||||
*
|
||||
* @param dcb DCB to which to stream result set
|
||||
* @param tree Potential liek clause (currently unused)
|
||||
* @param tree Potential like clause (currently unused)
|
||||
*/
|
||||
static void
|
||||
exec_show_services(DCB *dcb, MAXINFO_TREE *tree)
|
||||
@ -109,7 +109,7 @@ RESULTSET *set;
|
||||
* Fetch the list of listeners and stream as a result set
|
||||
*
|
||||
* @param dcb DCB to which to stream result set
|
||||
* @param tree Potential liek clause (currently unused)
|
||||
* @param tree Potential like clause (currently unused)
|
||||
*/
|
||||
static void
|
||||
exec_show_listeners(DCB *dcb, MAXINFO_TREE *tree)
|
||||
@ -127,7 +127,7 @@ RESULTSET *set;
|
||||
* Fetch the list of sessions and stream as a result set
|
||||
*
|
||||
* @param dcb DCB to which to stream result set
|
||||
* @param tree Potential liek clause (currently unused)
|
||||
* @param tree Potential like clause (currently unused)
|
||||
*/
|
||||
static void
|
||||
exec_show_sessions(DCB *dcb, MAXINFO_TREE *tree)
|
||||
@ -145,7 +145,7 @@ RESULTSET *set;
|
||||
* Fetch the list of client sessions and stream as a result set
|
||||
*
|
||||
* @param dcb DCB to which to stream result set
|
||||
* @param tree Potential liek clause (currently unused)
|
||||
* @param tree Potential like clause (currently unused)
|
||||
*/
|
||||
static void
|
||||
exec_show_clients(DCB *dcb, MAXINFO_TREE *tree)
|
||||
@ -163,7 +163,7 @@ RESULTSET *set;
|
||||
* Fetch the list of servers and stream as a result set
|
||||
*
|
||||
* @param dcb DCB to which to stream result set
|
||||
* @param tree Potential liek clause (currently unused)
|
||||
* @param tree Potential like clause (currently unused)
|
||||
*/
|
||||
static void
|
||||
exec_show_servers(DCB *dcb, MAXINFO_TREE *tree)
|
||||
@ -181,7 +181,7 @@ RESULTSET *set;
|
||||
* Fetch the list of modules and stream as a result set
|
||||
*
|
||||
* @param dcb DCB to which to stream result set
|
||||
* @param tree Potential liek clause (currently unused)
|
||||
* @param tree Potential like clause (currently unused)
|
||||
*/
|
||||
static void
|
||||
exec_show_modules(DCB *dcb, MAXINFO_TREE *tree)
|
||||
@ -199,7 +199,7 @@ RESULTSET *set;
|
||||
* Fetch the list of monitors and stream as a result set
|
||||
*
|
||||
* @param dcb DCB to which to stream result set
|
||||
* @param tree Potential liek clause (currently unused)
|
||||
* @param tree Potential like clause (currently unused)
|
||||
*/
|
||||
static void
|
||||
exec_show_monitors(DCB *dcb, MAXINFO_TREE *tree)
|
||||
@ -213,6 +213,24 @@ RESULTSET *set;
|
||||
resultset_free(set);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the event times data
|
||||
*
|
||||
* @param dcb DCB to which to stream result set
|
||||
* @param tree Potential like clause (currently unused)
|
||||
*/
|
||||
static void
|
||||
exec_show_eventTimes(DCB *dcb, MAXINFO_TREE *tree)
|
||||
{
|
||||
RESULTSET *set;
|
||||
|
||||
if ((set = eventTimesGetList()) == NULL)
|
||||
return;
|
||||
|
||||
resultset_stream_mysql(set, dcb);
|
||||
resultset_free(set);
|
||||
}
|
||||
|
||||
/**
|
||||
* The table of show commands that are supported
|
||||
*/
|
||||
@ -229,6 +247,7 @@ static struct {
|
||||
{ "servers", exec_show_servers },
|
||||
{ "modules", exec_show_modules },
|
||||
{ "monitors", exec_show_monitors },
|
||||
{ "eventTimes", exec_show_eventTimes },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user