Couchbase C Client  2.4.4
Retrieve statistics from the cluster

Detailed Description

Functions

lcb_stat_callback lcb_set_stat_callback (lcb_t, lcb_stat_callback)
 
lcb_error_t lcb_server_stats (lcb_t instance, const void *command_cookie, lcb_SIZE num, const lcb_server_stats_cmd_t *const *commands)
 Request server statistics. More...
 

Typedefs

typedef void(* lcb_stat_callback )(lcb_t instance, const void *cookie, lcb_error_t error, const lcb_server_stat_resp_t *resp)
 The callback function for a stat request. More...
 

Function Documentation

lcb_error_t lcb_server_stats ( lcb_t  instance,
const void *  command_cookie,
lcb_SIZE  num,
const lcb_server_stats_cmd_t *const *  commands 
)

Request server statistics.

Without a key specified the server will respond with a "default" set of statistics information. Each piece of statistical information is returned in its own packet (key contains the name of the statistical item and the body contains the value in ASCII format). The sequence of return packets is terminated with a packet that contains no key and no value.

The command will signal about transfer completion by passing NULL as the server endpoint and 0 for key length. Note that key length will be zero when some server responds with error. In latter case server endpoint argument will indicate the server address.

lcb_server_stats_cmd_t *cmd = calloc(1, sizeof(*cmd));
cmd->version = 0;
cmd->v.v0.name = "tap";
cmd->v.v0.nname = strlen(cmd->v.v0.nname);
lcb_server_stats_cmd_t* commands[] = { cmd };
lcb_server_stats(instance, NULL, 1, commands);
Parameters
instancethe instance used to batch the requests from
command_cookiea cookie passed to all of the notifications from this command
numthe total number of elements in the commands array
commandsthe array containing the statistic to get
Returns
The status of the operation

Data Structure Documentation

struct lcb_STATSRESPv0

Per-server, per-stat response structure for lcb_server_stats()

This structure is returned for each statistic requested by lcb_server_stats(). As both the number of servers replying to this function as well as the number of stats per server is variable, the application should pay attention to the following semantics:

  1. A new statistic item is delivered with the server_endpoint and key being non-NULL
  2. If a specific server encounters an error, the key and bytes fields will be NULL.
  3. Once no more replies remain from any of the servers, a final callback will be delivered with the server_endpoint field set to NULL.

It is recommended to index statistics twice; first based on the server_endpoint field and then on the key field. It is likely that the same key will be received multiple times for different server_endpoints.

Data Fields
const char * server_endpoint Server which the statistic is from.
const void * key Statistic name.
lcb_SIZE nkey
const void * bytes Statistic value.
lcb_SIZE nbytes
struct lcb_server_stat_resp_t

Wrapper structure for lcb_STATSRESPv0.

Data Fields
int version
union lcb_server_stat_resp_t v

Typedef Documentation

typedef void(* lcb_stat_callback)(lcb_t instance, const void *cookie, lcb_error_t error, const lcb_server_stat_resp_t *resp)

The callback function for a stat request.

Parameters
instancethe instance performing the operation
cookiethe cookie associated with with the command
errorThe status of the operation
respresponse data