Rate counters

## Data Structures

struct | vty_out_context

## Typedefs

typedef int(* | rate_ctr_handler_t) (struct rate_ctr_group *, struct rate_ctr *, const struct rate_ctr_desc *, void *)
typedef int(* | rate_ctr_group_handler_t) (struct rate_ctr_group *, void *)

## Enumerations

enum | rate_ctr_intv

## Functions

struct rate_ctr_group * | rate_ctr_group_alloc (void *ctx, const struct rate_ctr_group_desc *desc, unsigned int idx)
static void | rate_ctr_group_upd_idx (struct rate_ctr_group *grp, unsigned int idx)
void | rate_ctr_group_free (struct rate_ctr_group *grp)
void | rate_ctr_add (struct rate_ctr *ctr, int inc)
static void | rate_ctr_inc (struct rate_ctr *ctr)
static void | rate_ctr_inc2 (struct rate_ctr_group *ctrg, unsigned int idx)
int64_t | rate_ctr_difference (struct rate_ctr *ctr)
int | rate_ctr_init (void *tall_ctx)
struct rate_ctr_group * | rate_ctr_get_group_by_name_idx (const char *name, const unsigned int idx)
const struct rate_ctr * | rate_ctr_get_by_name (const struct rate_ctr_group *ctrg, const char *name)
int | rate_ctr_for_each_counter (struct rate_ctr_group *ctrg, rate_ctr_handler_t handle_counter, void *data)
int | rate_ctr_for_each_group (rate_ctr_group_handler_t handle_group, void *data)
void | rate_ctr_reset (struct rate_ctr *ctr)
void | rate_ctr_group_reset (struct rate_ctr_group *ctrg)
static | LLIST_HEAD (rate_ctr_groups)
static bool | rate_ctrl_group_desc_validate (const struct rate_ctr_group_desc *desc)
static char * | mangle_identifier_ifneeded (const void *ctx, const char *in)
static struct rate_ctr_group_desc * | rate_ctr_group_desc_mangle (void *ctx, const struct rate_ctr_group_desc *desc)
static unsigned int | rate_ctr_get_unused_name_idx (const char *name)
static void | interval_expired (struct rate_ctr *ctr, enum rate_ctr_intv intv)
static void | rate_ctr_group_intv (struct rate_ctr_group *grp)
static void | rate_ctr_timer_cb (void *data)
static int | rate_ctr_handler (struct rate_ctr_group *ctrg, struct rate_ctr *ctr, const struct rate_ctr_desc *desc, void *vctx_)
void | vty_out_rate_ctr_group (struct vty *vty, const char *prefix, struct rate_ctr_group *ctrg)
| print a rate counter group to given VTY More...
static char * | pad_append_str (char *s, const char *a, int minwidth)
static char * | pad_append_ctr (char *s, uint64_t ctr, int minwidth)
static int | rate_ctr_handler_fmt (struct rate_ctr_group *ctrg, struct rate_ctr *ctr, const struct rate_ctr_desc *desc, void *vctx_)
void | vty_out_rate_ctr_group_fmt (struct vty *vty, const char *fmt, struct rate_ctr_group *ctrg)
| print a rate counter group to given VTY, formatting the line for each counter according to a format string. More...
static int | rate_ctr_group_handler (struct rate_ctr_group *ctrg, void *vctx_)

## Variables

| RATE_CTR_INTV_SEC
| RATE_CTR_INTV_MIN
| RATE_CTR_INTV_HOUR
| RATE_CTR_INTV_DAY
static void * | tall_rate_ctr_ctx
static struct osmo_timer_list | rate_ctr_timer
static uint64_t | timer_ticks

## Detailed Description

## Function Documentation

## pad_append_ctr()

static char* pad_append_ctr | ( | char * | s,
|  | uint64_t | ctr,
|  | int | minwidth
| ) |  |

static

References OSMO_ASSERT.

Referenced by rate_ctr_handler_fmt().

## pad_append_str()

static char* pad_append_str | ( | char * | s,
|  | const char * | a,
|  | int | minwidth
| ) |  |

static

References OSMO_ASSERT.

Referenced by rate_ctr_handler_fmt().

## rate_ctr_group_handler()

static int rate_ctr_group_handler | ( | struct rate_ctr_group * | ctrg,
|  | void * | vctx_
| ) |  |

static

References rate_ctr_group_desc::class_id, rate_ctr_group::desc, rate_ctr_group_desc::group_description, rate_ctr_group::idx, vty_out_context::max_level, vty_out_context::prefix, rate_ctr_for_each_counter(), rate_ctr_handler(), vty_out_context::vty, VTY_NEWLINE, and vty_out().

Referenced by vty_out_statistics_partial().

## rate_ctr_handler()

static int rate_ctr_handler | ( | struct rate_ctr_group * | ctrg,
|  | struct rate_ctr * | ctr,
|  | const struct rate_ctr_desc * | desc,
|  | void * | vctx_
| ) |  |

static

References current, intv, vty_out_context::prefix, rate_ctr_per_intv::rate, RATE_CTR_INTV_DAY, RATE_CTR_INTV_HOUR, RATE_CTR_INTV_MIN, RATE_CTR_INTV_SEC, vty_out_context::vty, VTY_NEWLINE, and vty_out().

Referenced by rate_ctr_group_handler(), and vty_out_rate_ctr_group().

## rate_ctr_handler_fmt()

static int rate_ctr_handler_fmt | ( | struct rate_ctr_group * | ctrg,
|  | struct rate_ctr * | ctr,
|  | const struct rate_ctr_desc * | desc,
|  | void * | vctx_
| ) |  |

static

References current, intv, len(), OSMO_ASSERT, pad_append_ctr(), pad_append_str(), vty_out_context::prefix, previous, rate_ctr_per_intv::rate, RATE_CTR_INTV_DAY, RATE_CTR_INTV_HOUR, RATE_CTR_INTV_MIN, RATE_CTR_INTV_SEC, vty_out_context::vty, VTY_NEWLINE, and vty_out().

Referenced by vty_out_rate_ctr_group_fmt().

## vty_out_rate_ctr_group()

void vty_out_rate_ctr_group | ( | struct vty * | vty,
|  | const char * | prefix,
|  | struct rate_ctr_group * | ctrg
| ) |  |

print a rate counter group to given VTY

Parameters

  [in] | vty | The VTY to which it should be printed
  [in] | prefix | Any additional log prefix ahead of each line
  [in] | ctrg | Rate counter group to be printed

References rate_ctr_group::desc, rate_ctr_group_desc::group_description, vty_out_context::prefix, rate_ctr_for_each_counter(), rate_ctr_handler(), vty, VTY_NEWLINE, and vty_out().

## vty_out_rate_ctr_group_fmt()

void vty_out_rate_ctr_group_fmt | ( | struct vty * | vty,
|  | const char * | fmt,
|  | struct rate_ctr_group * | ctrg
| ) |  |

print a rate counter group to given VTY, formatting the line for each counter according to a format string.

The following format string directives are supported:

- d: The description of the counter
- n: The name of the counter
- c: The current value of the counter
- p: The previous value of the counter
- S: The interval of the counter in seconds
- M: The interval of the counter in minutes
- H: The interval of the counter in hours
- D: The interval of the counter in days
- %%: Print a literal %.

An optional number between % and the letter in a format directive may be used to set a minimum field width. If the expanded format directive is smaller than this width (according to strlen()) the string will be left-padded (if the number is positive) or right-padded (if the number is negative) with spaces. For example, "%25n" prints the counter name left-padded up to a minimum width of 25 columns.

VTY_NEWLINE will be appended to the format string when it is printed.

Parameters

  [in] | vty | The VTY to which it should be printed
  [in] | ctrg | Rate counter group to be printed
  [in] | fmt | A format which may contain the above directives.

References rate_ctr_for_each_counter(), rate_ctr_handler_fmt(), and vty.

Referenced by rate_ctr_group_handler().