MySQL  8.0.16
Source Code Documentation
mcstat.c File Reference
#include "config.h"
#include <memcached/protocol_binary.h>
#include <getopt.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

Functions

static int connect_server (const char *hostname, const char *port)
 Try to connect to the server. More...
 
static void retry_send (int sock, const void *buf, size_t len)
 Send the chunk of data to the other side, retry if an error occurs (or terminate the program if retry wouldn't help us) More...
 
static void retry_recv (int sock, void *buf, size_t len)
 Receive a fixed number of bytes from the socket. More...
 
static void print (const char *key, int keylen, const char *val, int vallen)
 Print the key value pair. More...
 
static void request_stat (int sock, const char *key)
 Request a stat from the server. More...
 
int main (int argc, char **argv)
 Program entry point. More...
 

Function Documentation

◆ connect_server()

static int connect_server ( const char *  hostname,
const char *  port 
)
static

Try to connect to the server.

Parameters
hostnamethe name of the server
portthe port to connect to
Returns
a socket descriptor connected to host:port for success, -1 otherwise

◆ main()

int main ( int  argc,
char **  argv 
)

Program entry point.

Connect to a memcached server and use the binary protocol to retrieve a given set of stats.

Parameters
argcargument count
argvargument vector
Returns
0 if success, error code otherwise

◆ print()

static void print ( const char *  key,
int  keylen,
const char *  val,
int  vallen 
)
static

Print the key value pair.

Parameters
keykey to print
keylenlength of key to print
valvalue to print
vallenlength of value

◆ request_stat()

static void request_stat ( int  sock,
const char *  key 
)
static

Request a stat from the server.

Parameters
socksocket connected to the server
keythe name of the stat to receive (NULL == ALL)

◆ retry_recv()

static void retry_recv ( int  sock,
void *  buf,
size_t  len 
)
static

Receive a fixed number of bytes from the socket.

(Terminate the program if we encounter a hard error...)

Parameters
socksocket to receive data from
bufbuffer to store data to
lenlength of data to receive

◆ retry_send()

static void retry_send ( int  sock,
const void *  buf,
size_t  len 
)
static

Send the chunk of data to the other side, retry if an error occurs (or terminate the program if retry wouldn't help us)

Parameters
socksocket to write data to
bufbuffer to send
lenlength of data to send