# Analyzing servers

## SYNOPSIS

#include <libmemcached/memcached.h>

  Compile and link with -lmemcached

typedef struct memcached_analysis_st memcached_analysis_st

memcached_analysis_st *memcached_analyze(memcached_st *ptr, memcached_stat_st *stat, memcached_return_t *error)
  Parameters:

    - ptr -- pointer to initialized `memcached_st` struct

    - stat -- pointer to a `memcached_stat_st` struct to fill

    - error -- pointer to `memcached_return_t` indicating success

  Returns:

    pointer to an allocated and filled out `memcached_analysis_t` struct

## DESCRIPTION

`libmemcached` has the ability to query a memcached server (or collection of servers) for their current state. Queries to find state return a `memcached_analysis_st` structure. You are responsible for freeing this structure.

`memcached_analyze()` analyzes useful information based on the provided servers and sets the result to the `memcached_analysis_st` structure. The return value must be freed by the calling application.

See also

`memstat -a|--analyze [<arg>]` A command line tool to analyze a memcached server.

## RETURN VALUE

A pointer to the allocated `memcached_analysis_st` structure on success and a NULL pointer on failure. You may inspect the error detail by checking the `memcached_return_t` value.

Any method returning a `memcached_analysis_st` expects you to free the memory allocated for it.

## SEE ALSO

- memcached(1)

- C/C++ Client Library for memcached

- Converting Error Codes to Messages