Functions | Variables

counters.c File Reference

counters/stats: More...

#include "counters.h"
#include "str_hash.h"
#include "str.h"
#include "compiler_opt.h"
#include "mem/mem.h"
#include "mem/shm_mem.h"
Include dependency graph for counters.c:

Go to the source code of this file.

Functions

Variables


Detailed Description

Definition in file counters.c.


Function Documentation

static struct counter_record* cnt_hash_add ( str group,
str name,
int  flags,
counter_cbk_f  cbk,
void *  param,
const char *  doc 
) [static, read]
Returns:
pointer to new record on success, 0 on error.

Definition at line 306 of file counters.c.

References _cnts_vals, cnts_hash_table, grp_hash_get_create(), _str::len, and _str::s.

Referenced by cnt_hash_get_create().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct counter_record* cnt_hash_get_create ( str group,
str name,
int  flags,
counter_cbk_f  cbk,
void *  param,
const char *  doc 
) [static, read]
Returns:
pointer to counter_record on succes, 0 on failure ( not found and failed to create new group record).

Definition at line 450 of file counters.c.

References cnt_hash_add(), and cnt_hash_lookup().

Referenced by counter_register().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct counter_record* cnt_hash_lookup ( str group,
str name 
) [static, read]
Parameters:
group - counter group name. If "" the first matching counter with the given name will be returned (k compat).
name 
Returns:
pointer to counter_record on success, 0 on failure (not found).

Definition at line 414 of file counters.c.

References cnts_hash_table, _str::len, and _str::s.

Referenced by cnt_hash_get_create(), counter_lookup_str(), and counter_register().

Here is the caller graph for this function:

char* counter_get_doc ( counter_handle_t  handle  ) 
Parameters:
handle - counter handle obtained using counter_lookup() or counter_register().
Returns:
asciiz pointer on success, 0 on error.

Definition at line 721 of file counters.c.

References _cnts_vals.

char* counter_get_group ( counter_handle_t  handle  ) 
Parameters:
handle - counter handle obtained using counter_lookup() or counter_register().
Returns:
asciiz pointer on success, 0 on error.

Definition at line 698 of file counters.c.

References _cnts_vals.

char* counter_get_name ( counter_handle_t  handle  ) 
Parameters:
handle - counter handle obtained using counter_lookup() or counter_register().
Returns:
asciiz pointer on success, 0 on error.

Definition at line 675 of file counters.c.

References _cnts_vals.

counter_val_t counter_get_raw_val ( counter_handle_t  handle  ) 
Parameters:
handle - counter handle obtained using counter_lookup() or counter_register().
Returns:
counter value.

Definition at line 599 of file counters.c.

References _cnts_vals, and counter_pprocess_val.

Referenced by counter_get_val().

Here is the caller graph for this function:

counter_val_t counter_get_val ( counter_handle_t  handle  ) 
Parameters:
handle - counter handle obtained using counter_lookup() or counter_register().
Returns:
counter value.

Definition at line 625 of file counters.c.

References _cnts_vals, and counter_get_raw_val().

Here is the call graph for this function:

void counter_iterate_grp_names ( void(*)(void *p, str *grp_name)  cbk,
void *  p 
)
Parameters:
cbk - pointer to a callback function that will be called for each group name.
p - parameter that will be passed to the callback function (along the group name).

Definition at line 745 of file counters.c.

void counter_iterate_grp_var_names ( const char *  group,
void(*)(void *p, str *var_name)  cbk,
void *  p 
)
Parameters:
group - group name.
cbk - pointer to a callback function that will be called for each variable name.
p - parameter that will be passed to the callback function (along the variable name).

Definition at line 762 of file counters.c.

References grp_hash_lookup(), _str::len, and _str::s.

Here is the call graph for this function:

void counter_iterate_grp_vars ( const char *  group,
void(*)(void *p, str *g, str *n, counter_handle_t h)  cbk,
void *  p 
)
Parameters:
group - group name.
cbk - pointer to a callback function that will be called for each [variable name, variable handle] pair.
p - parameter that will be passed to the callback function (along the group name, variable name and variable handle).

Definition at line 787 of file counters.c.

References grp_hash_lookup(), _str::len, and _str::s.

Here is the call graph for this function:

int counter_lookup ( counter_handle_t *  handle,
const char *  group,
const char *  name 
)
Parameters:
handle - filled with the corresp. handle on success.
group - counter group name. If 0 or "" the first matching counter with the given name will be returned (k compat).
name - counter name.
Returns:
0 on success, < 0 on error

Definition at line 559 of file counters.c.

References counter_lookup_str(), _str::len, and _str::s.

Here is the call graph for this function:

int counter_lookup_str ( counter_handle_t *  handle,
str group,
str name 
)
Parameters:
handle - filled with the corresp. handle on success.
group - counter group name. If "" the first matching counter with the given name will be returned (k compat).
name - counter name.
Returns:
0 on success, < 0 on error

Definition at line 536 of file counters.c.

References cnt_hash_lookup().

Referenced by counter_lookup().

Here is the call graph for this function:

Here is the caller graph for this function:

int counter_register ( counter_handle_t *  handle,
const char *  group,
const char *  name,
int  flags,
counter_cbk_f  cbk,
void *  cbk_param,
const char *  doc,
int  reg_flags 
)

Can be called only before forking (e.g. from mod_init() or init_child(PROC_INIT)).

Parameters:
handle - result parameter, it will be filled with the counter handle on success (can be null if not needed).
group - group name
name - counter name (group.name must be unique).
flags - counter flags: one of CNT_F_*.
cbk - read callback function (if set it will be called each time someone will call counter_get()).
cbk_param - callback param.
doc - description/documentation string.
reg_flags - register flags: 1 - don't fail if counter already registered (act like counter_lookup(handle, group, name).
Returns:
0 on succes, < 0 on error (-1 not init or malloc error, -2 already registered (and register_flags & 1 == 0).

Definition at line 483 of file counters.c.

References cnt_hash_get_create(), cnt_hash_lookup(), _str::len, and _str::s.

Referenced by add_script_counter(), and counter_register_array().

Here is the call graph for this function:

Here is the caller graph for this function:

int counter_register_array ( const char *  group,
counter_def_t *  defs 
)
Parameters:
group - counters group.
defs - null terminated array containing counters definitions.
Returns:
0 on success, < 0 on error ( - (counter_number+1))

Definition at line 579 of file counters.c.

References counter_register().

Here is the call graph for this function:

void counter_reset ( counter_handle_t  handle  ) 

Reset a counter, unless it has the CNT_F_NO_RESET flag set.

Parameters:
handle - counter handle obtained using counter_lookup() or counter_register(). Note: it's racy.

Definition at line 648 of file counters.c.

References _cnts_vals, and counter_pprocess_val.

int counters_prefork_init ( int  max_process_no  ) 

shm must be available.

Returns:
0 on success, < 0 on error

Definition at line 187 of file counters.c.

References _cnts_vals, counter_pprocess_val, and process_no.

static struct grp_record* grp_hash_add ( str group  )  [static, read]
Returns:
pointer to new group record on success, 0 on error.

Definition at line 225 of file counters.c.

References grp_hash_table, _str::len, and _str::s.

Referenced by grp_hash_get_create().

Here is the caller graph for this function:

static struct grp_record* grp_hash_get_create ( str group  )  [static, read]
Returns:
pointer to grp_record on succes, 0 on failure ( not found and failed to create new group record).

Definition at line 291 of file counters.c.

References grp_hash_add(), and grp_hash_lookup().

Referenced by cnt_hash_add().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct grp_record* grp_hash_lookup ( str group  )  [static, read]
Returns:
pointer to grp_record on success, 0 on failure (not found).

Definition at line 278 of file counters.c.

References grp_hash_table, _str::len, and _str::s.

Referenced by counter_iterate_grp_var_names(), counter_iterate_grp_vars(), and grp_hash_get_create().

Here is the caller graph for this function:

int init_counters ( void   ) 
Returns:
0 on success, -1 on error.

Definition at line 102 of file counters.c.

References cnts_hash_table, and grp_hash_table.


Variable Documentation

counter_array_t* _cnts_vals

a[proc_no][counter_id] => _cnst_vals[proc_no*cnts_no+counter_id]

Definition at line 92 of file counters.c.

Referenced by cnt_hash_add(), counter_get_doc(), counter_get_group(), counter_get_name(), counter_get_raw_val(), counter_get_val(), counter_reset(), and counters_prefork_init().