CNDP  22.08.0
metrics.h File Reference
#include <stdint.h>
#include <cne_common.h>
#include <cne_lport.h>
#include <uds.h>

Go to the source code of this file.

Macros

#define metrics_append(c, fmt, ...)
 

Functions

CNDP_API int metrics_register (const char *cmd, metrics_cb fn)
 
CNDP_API int metrics_init (void *priv_)
 
CNDP_API int metrics_destroy (void)
 
CNDP_API const char * metrics_cmd (metrics_client_t *client)
 
CNDP_API const char * metrics_params (metrics_client_t *client)
 
CNDP_API int metrics_port_stats (metrics_client_t *c, char *name, lport_stats_t *s)
 

Detailed Description

Metrics-related utility functions

Definition in file metrics.h.

Macro Definition Documentation

◆ metrics_append

#define metrics_append (   c,
  fmt,
  ... 
)
Value:
do { \
uds_append((uds_client_t *)c, (const char *)fmt, ##__VA_ARGS__); \
} while (0)

A snprintf() like routine to add text or data to the output buffer.

Parameters
cThe client pointer that holds the buffer to append the text data.
fmtThe snprintf() like format string with variable arguments
...Arguments for the format string to use
Returns
The number of bytes appended to the data buffer.
Examples
examples/cndpfwd/stats.c, examples/cnet-graph/stats.c, examples/cnet-quic/stats.c, and examples/l3fwd-graph/stats.c.

Definition at line 74 of file metrics.h.

Function Documentation

◆ metrics_register()

CNDP_API int metrics_register ( const char *  cmd,
metrics_cb  fn 
)

Register a new command to the metrics interface

Parameters
cmdThe command string including the '/' e.g. '/pktdev:stats'
fnThe function to callback for this command
Returns
0 on success or -1 on error
Examples
examples/cndpfwd/stats.c, examples/cnet-graph/stats.c, examples/cnet-quic/stats.c, and examples/l3fwd-graph/stats.c.

◆ metrics_init()

CNDP_API int metrics_init ( void *  priv_)

Initialize metrics library.

Parameters
priv_Pointer to metrics command group private data.
Returns
0 on success, -1 on error with errno indicating reason for failure
Examples
examples/cndpfwd/stats.c, examples/cnet-graph/stats.c, examples/cnet-quic/stats.c, and examples/l3fwd-graph/stats.c.

◆ metrics_destroy()

CNDP_API int metrics_destroy ( void  )

Remove all registered metrics commands.

Returns
0 on success, -1 on error with errno indicating reason for failure.
Examples
examples/cndpfwd/main.c, examples/cnet-graph/cnet-graph.c, examples/cnet-quic/cnet-quic.c, and examples/l3fwd-graph/fwd.c.

◆ metrics_cmd()

CNDP_API const char* metrics_cmd ( metrics_client_t *  client)

Return the command string pointer

Parameters
clientThe client structure pointer
Returns
NULL if not defined or the string pointer.

◆ metrics_params()

CNDP_API const char* metrics_params ( metrics_client_t *  client)

Return the params string pointer

Parameters
clientThe client structure pointer
Returns
NULL if not defined or the string pointer.

◆ metrics_port_stats()

CNDP_API int metrics_port_stats ( metrics_client_t *  c,
char *  name,
lport_stats_t *  s 
)

Add the standard lport statistics to the metrics buffer

Parameters
cThe metric_client_t structure pointer
nameThe name of the lport as a prefix to the stats names.
sThe lport_stats_t structure pointer
Returns
-1 on error, 0 on success
Examples
examples/cndpfwd/stats.c, examples/cnet-graph/stats.c, examples/cnet-quic/stats.c, and examples/l3fwd-graph/stats.c.