stats.c File Reference
`#include <config.h>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <fcntl.h>`
`#include <stdint.h>`
`#include <stddef.h>`
`#include <unistd.h>`
`#include <libknet.h>`
`#include <qb/qblist.h>`
`#include <qb/qbipcs.h>`
`#include <qb/qbipc_common.h>`
`#include <corosync/corodefs.h>`
`#include <corosync/coroapi.h>`
`#include <corosync/logsys.h>`
`#include <corosync/icmap.h>`
`#include <corosync/totem/totemstats.h>`
`#include "util.h"`
`#include "ipcs_stats.h"`
`#include "stats.h"`
Include dependency graph for stats.c:

Go to the source code of this file.

## Data Structures

struct | schedmiss_entry
struct | cs_stats_conv
struct | stats_item
struct | cs_stats_tracker

## Macros

#define | MAX_SCHEDMISS_EVENTS 10
#define | SCHEDMISS_PREFIX "stats.schedmiss"
#define | NUM_PG_STATS (sizeof(cs_pg_stats) / sizeof(struct cs_stats_conv))
#define | NUM_SRP_STATS (sizeof(cs_srp_stats) / sizeof(struct cs_stats_conv))
#define | NUM_KNET_STATS (sizeof(cs_knet_stats) / sizeof(struct cs_stats_conv))
#define | NUM_KNET_HANDLE_STATS (sizeof(cs_knet_handle_stats) / sizeof(struct cs_stats_conv))
#define | NUM_IPCSC_STATS (sizeof(cs_ipcs_conn_stats) / sizeof(struct cs_stats_conv))
#define | NUM_IPCSG_STATS (sizeof(cs_ipcs_global_stats) / sizeof(struct cs_stats_conv))
#define | STATS_CLEAR "stats.clear."
#define | STATS_CLEAR_KNET "stats.clear.knet"
#define | STATS_CLEAR_IPC "stats.clear.ipc"
#define | STATS_CLEAR_TOTEM "stats.clear.totem"
#define | STATS_CLEAR_ALL "stats.clear.all"
#define | STATS_CLEAR_SCHEDMISS "stats.clear.schedmiss"

## Functions

| LOGSYS_DECLARE_SUBSYS ("STATS")
| QB_LIST_DECLARE (stats_tracker_list_head)
cs_error_t | stats_map_init (const struct corosync_api_v1 *corosync_api)
cs_error_t | stats_map_get (const char *key_name, void *value, size_t *value_len, icmap_value_types_t *type)
void | stats_add_schedmiss_event (uint64_t timestamp, float delay)
cs_error_t | stats_map_set (const char *key_name, const void *value, size_t value_len, icmap_value_types_t type)
cs_error_t | stats_map_adjust_int (const char *key_name, int32_t step)
cs_error_t | stats_map_delete (const char *key_name)
int | stats_map_is_key_ro (const char *key_name)
icmap_iter_t | stats_map_iter_init (const char *prefix)
const char * | stats_map_iter_next (icmap_iter_t iter, size_t *value_len, icmap_value_types_t *type)
void | stats_map_iter_finalize (icmap_iter_t iter)
void | stats_trigger_trackers ()
cs_error_t | stats_map_track_add (const char *key_name, int32_t track_type, icmap_notify_fn_t notify_fn, void *user_data, icmap_track_t *icmap_track)
cs_error_t | stats_map_track_delete (icmap_track_t icmap_track)
void * | stats_map_track_get_user_data (icmap_track_t icmap_track)
void | stats_knet_add_member (knet_node_id_t nodeid, uint8_t link_no)
void | stats_knet_del_member (knet_node_id_t nodeid, uint8_t link_no)
void | stats_knet_add_handle (void)
void | stats_ipcs_add_connection (int service_id, uint32_t pid, void *ptr)
void | stats_ipcs_del_connection (int service_id, uint32_t pid, void *ptr)

## Variables

struct cs_stats_conv | cs_pg_stats []
struct cs_stats_conv | cs_srp_stats []
struct cs_stats_conv | cs_knet_stats []
struct cs_stats_conv | cs_knet_handle_stats []
struct cs_stats_conv | cs_ipcs_conn_stats []
struct cs_stats_conv | cs_ipcs_global_stats []
struct cs_stats_conv | cs_schedmiss_stats []

## Macro Definition Documentation

## MAX_SCHEDMISS_EVENTS

#define MAX_SCHEDMISS_EVENTS 10

Definition at line 68 of file stats.c.

Referenced by stats_add_schedmiss_event().

## NUM_IPCSC_STATS

#define NUM_IPCSC_STATS (sizeof(cs_ipcs_conn_stats) / sizeof(struct cs_stats_conv))

Definition at line 213 of file stats.c.

Referenced by stats_ipcs_add_connection(), and stats_ipcs_del_connection().

## NUM_IPCSG_STATS

#define NUM_IPCSG_STATS (sizeof(cs_ipcs_global_stats) / sizeof(struct cs_stats_conv))

Definition at line 214 of file stats.c.

Referenced by stats_map_init().

## NUM_KNET_HANDLE_STATS

#define NUM_KNET_HANDLE_STATS (sizeof(cs_knet_handle_stats) / sizeof(struct cs_stats_conv))

Definition at line 212 of file stats.c.

Referenced by stats_knet_add_handle().

## NUM_KNET_STATS

#define NUM_KNET_STATS (sizeof(cs_knet_stats) / sizeof(struct cs_stats_conv))

Definition at line 211 of file stats.c.

Referenced by stats_knet_add_member(), and stats_knet_del_member().

## NUM_PG_STATS

#define NUM_PG_STATS (sizeof(cs_pg_stats) / sizeof(struct cs_stats_conv))

Definition at line 209 of file stats.c.

Referenced by stats_map_init().

## NUM_SRP_STATS

#define NUM_SRP_STATS (sizeof(cs_srp_stats) / sizeof(struct cs_stats_conv))

Definition at line 210 of file stats.c.

Referenced by stats_map_init().

## SCHEDMISS_PREFIX

#define SCHEDMISS_PREFIX "stats.schedmiss"

Definition at line 72 of file stats.c.

Referenced by stats_add_schedmiss_event(), and stats_map_get().

## STATS_CLEAR

#define STATS_CLEAR "stats.clear."

Definition at line 473 of file stats.c.

Referenced by stats_map_is_key_ro().

## STATS_CLEAR_ALL

#define STATS_CLEAR_ALL "stats.clear.all"

Definition at line 477 of file stats.c.

Referenced by stats_map_set().

## STATS_CLEAR_IPC

#define STATS_CLEAR_IPC "stats.clear.ipc"

Definition at line 475 of file stats.c.

Referenced by stats_map_set().

## STATS_CLEAR_KNET

#define STATS_CLEAR_KNET "stats.clear.knet"

Definition at line 474 of file stats.c.

Referenced by stats_map_set().

## STATS_CLEAR_SCHEDMISS

#define STATS_CLEAR_SCHEDMISS "stats.clear.schedmiss"

Definition at line 478 of file stats.c.

Referenced by stats_map_set().

## STATS_CLEAR_TOTEM

#define STATS_CLEAR_TOTEM "stats.clear.totem"

Definition at line 476 of file stats.c.

Referenced by stats_map_set().

## Function Documentation

## LOGSYS_DECLARE_SUBSYS()

LOGSYS_DECLARE_SUBSYS | ( | "STATS" |  | ) |

References stats_map.

## QB_LIST_DECLARE()

QB_LIST_DECLARE | ( | stats_tracker_list_head |  | ) |

References type, and value.

## stats_add_schedmiss_event()

void stats_add_schedmiss_event | ( | uint64_t | timestamp,
|  | float | delay )

Definition at line 447 of file stats.c.

References cs_schedmiss_stats, ICMAP_KEYNAME_MAXLEN, MAX_SCHEDMISS_EVENTS, param, and SCHEDMISS_PREFIX.

## stats_ipcs_add_connection()

void stats_ipcs_add_connection | ( | int | service_id,
|  | uint32_t | pid,
|  | void * | ptr )

Definition at line 765 of file stats.c.

References cs_ipcs_conn_stats, ICMAP_KEYNAME_MAXLEN, NUM_IPCSC_STATS, and param.

## stats_ipcs_del_connection()

void stats_ipcs_del_connection | ( | int | service_id,
|  | uint32_t | pid,
|  | void * | ptr )

Definition at line 775 of file stats.c.

References cs_ipcs_conn_stats, ICMAP_KEYNAME_MAXLEN, NUM_IPCSC_STATS, and param.

## stats_knet_add_handle()

void stats_knet_add_handle | ( | void |  | ) |

Definition at line 753 of file stats.c.

References cs_knet_handle_stats, ICMAP_KEYNAME_MAXLEN, NUM_KNET_HANDLE_STATS, and param.

Referenced by totemknet_initialize().

## stats_knet_add_member()

void stats_knet_add_member | ( | knet_node_id_t | nodeid,
|  | uint8_t | link_no )

Definition at line 730 of file stats.c.

References cs_knet_stats, ICMAP_KEYNAME_MAXLEN, nodeid, NUM_KNET_STATS, and param.

Referenced by totemknet_member_add().

## stats_knet_del_member()

void stats_knet_del_member | ( | knet_node_id_t | nodeid,
|  | uint8_t | link_no )

Definition at line 740 of file stats.c.

References cs_knet_stats, ICMAP_KEYNAME_MAXLEN, nodeid, NUM_KNET_STATS, and param.

Referenced by totemknet_member_remove().

## stats_map_adjust_int()

cs_error_t stats_map_adjust_int | ( | const char * | key_name,
|  | int32_t | step )

Definition at line 515 of file stats.c.

References CS_ERR_NOT_SUPPORTED.

## stats_map_delete()

cs_error_t stats_map_delete | ( | const char * | key_name | ) |

Definition at line 520 of file stats.c.

References CS_ERR_NOT_SUPPORTED.

## stats_map_get()

cs_error_t stats_map_get | ( | const char * | key_name,
|  | void * | value,
|  | size_t * | value_len,
|  | icmap_value_types_t * | type )

Definition at line 325 of file stats.c.

References stats_item::cs_conv, CS_ERR_LIBRARY, CS_ERR_NOT_EXIST, cs_ipcs_get_conn_stats(), cs_ipcs_get_global_stats(), CS_OK, ICMAP_VALUETYPE_FLOAT, ICMAP_VALUETYPE_UINT64, nodeid, SCHEDMISS_PREFIX, totempg_stats_t::srp, stats_map, totemknet_handle_get_stats(), totemknet_link_get_status(), cs_stats_conv::type, type, and value.

Referenced by stats_map_track_add(), and stats_trigger_trackers().

## stats_map_init()

cs_error_t stats_map_init | ( | const struct corosync_api_v1 * | corosync_api | ) |

Definition at line 289 of file stats.c.

References CS_ERR_INIT, cs_ipcs_global_stats, cs_pg_stats, cs_srp_stats, ICMAP_KEYNAME_MAXLEN, NUM_IPCSG_STATS, NUM_PG_STATS, NUM_SRP_STATS, param, qb_to_cs_error(), and stats_map.

Referenced by main().

## stats_map_is_key_ro()

int stats_map_is_key_ro | ( | const char * | key_name | ) |

Definition at line 525 of file stats.c.

References STATS_CLEAR.

## stats_map_iter_finalize()

void stats_map_iter_finalize | ( | icmap_iter_t | iter | ) |

Definition at line 555 of file stats.c.

## stats_map_iter_init()

icmap_iter_t stats_map_iter_init | ( | const char * | prefix | ) |

Definition at line 535 of file stats.c.

References stats_map.

## stats_map_iter_next()

const char * stats_map_iter_next | ( | icmap_iter_t | iter,
|  | size_t * | value_len,
|  | icmap_value_types_t * | type )

Definition at line 541 of file stats.c.

References stats_item::cs_conv, and type.

## stats_map_set()

cs_error_t stats_map_set | ( | const char * | key_name,
|  | const void * | value,
|  | size_t | value_len,
|  | icmap_value_types_t | type )

Definition at line 480 of file stats.c.

References CS_ERR_NOT_SUPPORTED, cs_ipcs_clear_stats(), CS_OK, STATS_CLEAR_ALL, STATS_CLEAR_IPC, STATS_CLEAR_KNET, STATS_CLEAR_SCHEDMISS, STATS_CLEAR_TOTEM, totempg_stats_clear(), TOTEMPG_STATS_CLEAR_TOTEM, TOTEMPG_STATS_CLEAR_TRANSPORT, type, and value.

## stats_map_track_add()

cs_error_t stats_map_track_add | ( | const char * | key_name,
|  | int32_t | track_type,
|  | icmap_notify_fn_t | notify_fn,
|  | void * | user_data,
|  | icmap_track_t * | icmap_track )

Definition at line 637 of file stats.c.

References CS_ERR_NO_MEMORY, CS_ERR_NOT_SUPPORTED, CS_OK, cs_stats_tracker::events, ICMAP_TRACK_ADD, ICMAP_TRACK_DELETE, ICMAP_TRACK_PREFIX, icmap_tt_to_qbtt(), cs_stats_tracker::key_name, cs_stats_tracker::list, log_printf, LOGSYS_LEVEL_ERROR, cs_stats_tracker::notify_fn, cs_stats_tracker::old_value, qb_to_cs_error(), stats_map, stats_map_get(), type, cs_stats_tracker::user_data, and user_data.

## stats_map_track_delete()

cs_error_t stats_map_track_delete | ( | icmap_track_t | icmap_track | ) |

Definition at line 700 of file stats.c.

References CS_OK, cs_stats_tracker::events, ICMAP_TRACK_ADD, ICMAP_TRACK_DELETE, icmap_tt_to_qbtt(), cs_stats_tracker::key_name, cs_stats_tracker::list, log_printf, LOGSYS_LEVEL_ERROR, and stats_map.

## stats_map_track_get_user_data()

void * stats_map_track_get_user_data | ( | icmap_track_t | icmap_track | ) |

Definition at line 722 of file stats.c.

References cs_stats_tracker::user_data.

## stats_trigger_trackers()

void stats_trigger_trackers | ( | void |  | ) |

Definition at line 561 of file stats.c.

References CS_OK, icmap_notify_value::data, cs_stats_tracker::events, ICMAP_TRACK_MODIFY, ICMAP_TRACK_PREFIX, cs_stats_tracker::key_name, icmap_notify_value::len, cs_stats_tracker::notify_fn, cs_stats_tracker::old_value, stats_map_get(), icmap_notify_value::type, type, cs_stats_tracker::user_data, and value.

## Variable Documentation

## cs_ipcs_conn_stats

struct cs_stats_conv cs_ipcs_conn_stats[]

Initial value:
= {
{ STAT_IPCSC, "queueing", offsetof(struct ipcs_conn_stats, cnx.queuing), ICMAP_VALUETYPE_INT32},
{ STAT_IPCSC, "queued", offsetof(struct ipcs_conn_stats, cnx.queued), ICMAP_VALUETYPE_UINT32},
{ STAT_IPCSC, "invalid_request", offsetof(struct ipcs_conn_stats, cnx.invalid_request), ICMAP_VALUETYPE_UINT64},
{ STAT_IPCSC, "overload", offsetof(struct ipcs_conn_stats, cnx.overload), ICMAP_VALUETYPE_UINT64},
{ STAT_IPCSC, "sent", offsetof(struct ipcs_conn_stats, cnx.sent), ICMAP_VALUETYPE_UINT32},
{ STAT_IPCSC, "procname", offsetof(struct ipcs_conn_stats, cnx.proc_name), ICMAP_VALUETYPE_STRING},
{ STAT_IPCSC, "requests", offsetof(struct ipcs_conn_stats, conn.requests), ICMAP_VALUETYPE_UINT64},
{ STAT_IPCSC, "responses", offsetof(struct ipcs_conn_stats, conn.responses), ICMAP_VALUETYPE_UINT64},
{ STAT_IPCSC, "dispatched", offsetof(struct ipcs_conn_stats, conn.events), ICMAP_VALUETYPE_UINT64},
{ STAT_IPCSC, "send_retries", offsetof(struct ipcs_conn_stats, conn.send_retries), ICMAP_VALUETYPE_UINT64},
{ STAT_IPCSC, "recv_retries", offsetof(struct ipcs_conn_stats, conn.recv_retries), ICMAP_VALUETYPE_UINT64},
{ STAT_IPCSC, "flow_control", offsetof(struct ipcs_conn_stats, conn.flow_control_state), ICMAP_VALUETYPE_UINT32},
{ STAT_IPCSC, "flow_control_count", offsetof(struct ipcs_conn_stats, conn.flow_control_count), ICMAP_VALUETYPE_UINT64},
}
ICMAP_VALUETYPE_UINT64
@ ICMAP_VALUETYPE_UINT64
Definition icmap.h:66
ICMAP_VALUETYPE_UINT32
@ ICMAP_VALUETYPE_UINT32
Definition icmap.h:64
ICMAP_VALUETYPE_STRING
@ ICMAP_VALUETYPE_STRING
Definition icmap.h:69
ICMAP_VALUETYPE_INT32
@ ICMAP_VALUETYPE_INT32
Definition icmap.h:63
ipcs_conn_stats
Definition ipcs_stats.h:53

Definition at line 185 of file stats.c.

Referenced by stats_ipcs_add_connection(), and stats_ipcs_del_connection().

## cs_ipcs_global_stats

struct cs_stats_conv cs_ipcs_global_stats[]

Initial value:
= {
{ STAT_IPCSG, "global.active", offsetof(struct ipcs_global_stats, active), ICMAP_VALUETYPE_UINT64},
{ STAT_IPCSG, "global.closed", offsetof(struct ipcs_global_stats, closed), ICMAP_VALUETYPE_UINT64},
}
ipcs_global_stats
Definition ipcs_stats.h:47

Definition at line 200 of file stats.c.

Referenced by stats_map_init().

## cs_knet_handle_stats

struct cs_stats_conv cs_knet_handle_stats[]

Initial value:
= {
{ STAT_KNET_HANDLE, "tx_uncompressed_packets", offsetof(struct knet_handle_stats, tx_uncompressed_packets), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "tx_compressed_packets", offsetof(struct knet_handle_stats, tx_compressed_packets), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "tx_compressed_original_bytes", offsetof(struct knet_handle_stats, tx_compressed_original_bytes), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "tx_compressed_size_bytes", offsetof(struct knet_handle_stats, tx_compressed_size_bytes), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "tx_compress_time_min", offsetof(struct knet_handle_stats, tx_compress_time_min), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "tx_compress_time_max", offsetof(struct knet_handle_stats, tx_compress_time_max), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "tx_compress_time_ave", offsetof(struct knet_handle_stats, tx_compress_time_ave), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "rx_compressed_packets", offsetof(struct knet_handle_stats, rx_compressed_packets), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "rx_compressed_original_bytes", offsetof(struct knet_handle_stats, rx_compressed_original_bytes), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "rx_compressed_size_bytes", offsetof(struct knet_handle_stats, rx_compressed_size_bytes), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "rx_compress_time_min", offsetof(struct knet_handle_stats, rx_compress_time_min), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "rx_compress_time_max", offsetof(struct knet_handle_stats, rx_compress_time_max), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "rx_compress_time_ave", offsetof(struct knet_handle_stats, rx_compress_time_ave), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "tx_crypt_time_min", offsetof(struct knet_handle_stats, tx_crypt_time_min), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "tx_crypt_time_max", offsetof(struct knet_handle_stats, tx_crypt_time_max), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "tx_crypt_time_ave", offsetof(struct knet_handle_stats, tx_crypt_time_ave), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "tx_crypt_byte_overhead", offsetof(struct knet_handle_stats, tx_crypt_byte_overhead), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "tx_crypt_packets", offsetof(struct knet_handle_stats, tx_crypt_packets), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "rx_crypt_time_min", offsetof(struct knet_handle_stats, rx_crypt_time_min), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "rx_crypt_time_max", offsetof(struct knet_handle_stats, rx_crypt_time_max), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "rx_crypt_time_ave", offsetof(struct knet_handle_stats, rx_crypt_time_ave), ICMAP_VALUETYPE_UINT64},
{ STAT_KNET_HANDLE, "rx_crypt_packets", offsetof(struct knet_handle_stats, rx_crypt_packets), ICMAP_VALUETYPE_UINT64},
}

Definition at line 160 of file stats.c.

Referenced by stats_knet_add_handle().

## cs_knet_stats

struct cs_stats_conv cs_knet_stats[]

Definition at line 119 of file stats.c.

Referenced by stats_knet_add_member(), and stats_knet_del_member().

## cs_pg_stats

struct cs_stats_conv cs_pg_stats[]

Initial value:
= {
{ STAT_PG, "msg_queue_avail", offsetof(totempg_stats_t, msg_queue_avail), ICMAP_VALUETYPE_UINT32},
{ STAT_PG, "msg_reserved", offsetof(totempg_stats_t, msg_reserved), ICMAP_VALUETYPE_UINT32},
}
totempg_stats_t
Definition totemstats.h:94

Definition at line 82 of file stats.c.

Referenced by stats_map_init().

## cs_schedmiss_stats

struct cs_stats_conv cs_schedmiss_stats[]

Initial value:
= {
{ STAT_SCHEDMISS, "timestamp", offsetof(struct schedmiss_entry, timestamp), ICMAP_VALUETYPE_UINT64},
{ STAT_SCHEDMISS, "delay", offsetof(struct schedmiss_entry, delay), ICMAP_VALUETYPE_FLOAT},
}
ICMAP_VALUETYPE_FLOAT
@ ICMAP_VALUETYPE_FLOAT
Definition icmap.h:67
schedmiss_entry
Definition stats.c:64

Definition at line 204 of file stats.c.

Referenced by stats_add_schedmiss_event().

## cs_srp_stats

struct cs_stats_conv cs_srp_stats[]

Definition at line 86 of file stats.c.

Referenced by stats_map_init().