33#define BRIDGES_CHANNELS_COUNT_HELP "Number of channels in the bridge."
67 .name =
"asterisk_bridges_channels_count",
87 int i, j, num_bridges, num_outputs = 0;
90 "asterisk_bridges_count",
91 "Current bridge count.",
112 snprintf(bridge_count.
value,
sizeof(bridge_count.
value),
"%d", num_bridges);
115 if (num_bridges == 0) {
127 if (!bridge_metrics) {
149 int index = num_outputs++;
162 if (bridge_metrics[j] ==
NULL) {
163 bridge_metrics[j] = &
metrics[index];
173 if (bridge_metrics[j]) {
184 .
name =
"bridges callback",
Asterisk main include file. File version handling, generic pbx functions.
#define ast_calloc(num, len)
A wrapper for calloc()
#define ao2_iterator_next(iter)
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_container_clone(orig, flags)
Create a clone/copy of the given container.
static struct ao2_container * bridges
struct ao2_container * ast_bridges(void)
Returns the global bridges container.
@ AST_BRIDGE_FLAG_INVISIBLE
#define BRIDGES_CHANNELS_COUNT_HELP
struct prometheus_callback bridges_callback
static void bridge_metrics_unload_cb(void)
static struct prometheus_metrics_provider provider
static void bridges_scrape_cb(struct ast_str **response)
int bridge_metrics_init(void)
Initialize bridge metrics.
static void get_bridge_channel_count(struct prometheus_metric *metric, struct ast_bridge_snapshot *snapshot)
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Prometheus Metric Internal API.
Asterisk Prometheus Metrics.
#define PROMETHEUS_METRIC_SET_LABEL(metric, label, n, v)
Convenience macro for setting a label / value in a metric.
#define PROMETHEUS_METRIC_STATIC_INITIALIZATION(mtype, n, h, cb)
Convenience macro for initializing a metric on the stack.
@ PROMETHEUS_METRIC_GAUGE
A metric whose value can bounce around like a jackrabbit.
void prometheus_callback_unregister(struct prometheus_callback *callback)
Remove a registered callback.
void prometheus_metric_to_string(struct prometheus_metric *metric, struct ast_str **output)
Convert a metric (and its children) into Prometheus compatible text.
void prometheus_metrics_provider_register(const struct prometheus_metrics_provider *provider)
Register a metrics provider.
int prometheus_callback_register(struct prometheus_callback *callback)
struct ast_bridge_snapshot * ast_bridge_get_snapshot(struct ast_bridge *bridge)
Returns the current snapshot for the bridge.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Structure that contains a snapshot of information about a bridge.
const ast_string_field creator
const ast_string_field uniqueid
unsigned int num_channels
const ast_string_field technology
const ast_string_field name
const ast_string_field subclass
Structure that contains information about a bridge.
struct ast_flags feature_flags
Support for dynamic strings.
void(*const get_value)(struct prometheus_metric *metric, struct ast_bridge_snapshot *snapshot)
Callback function to generate a metric value for a given bridge.
const char * name
Name of the metric.
const char * help
Help text to display.
Defines a callback that will be invoked when the HTTP route is called.
const char * name
The name of our callback (always useful for debugging)
An actual, honest to god, metric.
char value[PROMETHEUS_MAX_VALUE_LENGTH]
The current value.
A function table for a metrics provider.
const char * name
Handy name of the provider for debugging purposes.
#define ast_test_flag(p, flag)
char * ast_eid_to_str(char *s, int maxlen, struct ast_eid *eid)
Convert an EID to a string.
struct ast_eid ast_eid_default
Global EID.