libosmovty 1.9.0.196-9975
Osmocom VTY library
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_grouprate_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_set_name (struct rate_ctr_group *grp, const char *name)
 
struct rate_ctrrate_ctr_group_get_ctr (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_add2 (struct rate_ctr_group *ctrg, unsigned int idx, 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_grouprate_ctr_get_group_by_name_idx (const char *name, const unsigned int idx)
 
const struct rate_ctrrate_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_descrate_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 int rate_ctr_timer_cb (struct osmo_fd *ofd, unsigned int what)
 
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_group2 (struct vty *vty, const char *prefix, struct rate_ctr_group *ctrg, bool skip_zero)
 print a rate counter group to given VTY More...
 
void vty_out_rate_ctr_group (struct vty *vty, const char *prefix, struct rate_ctr_group *ctrg)
 
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_fmt2 (struct vty *vty, const char *fmt, struct rate_ctr_group *ctrg, bool skip_zero)
 print a rate counter group to given VTY, formatting the line for each counter according to a format string. More...
 
void vty_out_rate_ctr_group_fmt (struct vty *vty, const char *fmt, struct rate_ctr_group *ctrg)
 
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_fd 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()

◆ rate_ctr_handler()

◆ rate_ctr_handler_fmt()

◆ vty_out_rate_ctr_group()

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

◆ vty_out_rate_ctr_group2()

void vty_out_rate_ctr_group2 ( struct vty vty,
const char *  prefix,
struct rate_ctr_group ctrg,
bool  skip_zero 
)

print a rate counter group to given VTY

Parameters
[in]vtyThe VTY to which it should be printed
[in]prefixAny additional log prefix ahead of each line
[in]ctrgRate counter group to be printed
[in]skip_zeroSkip all zero-valued counters

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

Referenced by vty_out_rate_ctr_group().

◆ vty_out_rate_ctr_group_fmt()

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

◆ vty_out_rate_ctr_group_fmt2()

void vty_out_rate_ctr_group_fmt2 ( struct vty vty,
const char *  fmt,
struct rate_ctr_group ctrg,
bool  skip_zero 
)

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]vtyThe VTY to which it should be printed
[in]ctrgRate counter group to be printed
[in]fmtA format which may contain the above directives.
[in]skip_zeroSkip all zero-valued counters

References rate_ctr_for_each_counter(), rate_ctr_handler_fmt(), vty_out_context::skip_zero, and vty.

Referenced by rate_ctr_group_handler(), and vty_out_rate_ctr_group_fmt().