33#define ENDPOINTS_STATE_HELP "Individual endpoint states. 0=unknown; 1=offline; 2=online."
35#define ENDPOINTS_CHANNELS_COUNT_HELP "Count of the number of channels currently existing that are associated with the endpoint."
81 .name =
"asterisk_endpoints_state",
86 .name =
"asterisk_endpoints_channels_count",
105 int i, j, num_endpoints;
108 "asterisk_endpoints_count",
109 "Current endpoint count.",
116 if (!endpoint_cache) {
129 snprintf(endpoint_count.
value,
sizeof(endpoint_count.
value),
"%d", num_endpoints);
132 if (num_endpoints == 0) {
138 if (!endpoint_metrics) {
176 .
name =
"Endpoints 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.
struct stasis_message_type * ast_endpoint_snapshot_type(void)
Message type for ast_endpoint_snapshot.
struct stasis_cache * ast_endpoint_cache(void)
Backend cache for ast_endpoint_topic_all_cached().
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
static struct ao2_container * endpoints
Prometheus Metric Internal API.
static void endpoint_metrics_unload_cb(void)
static void get_endpoint_channel_count(struct prometheus_metric *metric, struct ast_endpoint_snapshot *snapshot)
struct prometheus_callback endpoints_callback
static void get_endpoint_state(struct prometheus_metric *metric, struct ast_endpoint_snapshot *snapshot)
static struct prometheus_metrics_provider provider
static void endpoints_scrape_cb(struct ast_str **response)
#define ENDPOINTS_CHANNELS_COUNT_HELP
#define ENDPOINTS_STATE_HELP
int endpoint_metrics_init(void)
Initialize endpoint metrics.
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 ao2_container * stasis_cache_dump(struct stasis_cache *cache, struct stasis_message_type *type)
Dump cached items to a subscription for the ast_eid_default entity.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
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...
A snapshot of an endpoint's state.
const ast_string_field tech
enum ast_endpoint_state state
const ast_string_field id
const ast_string_field resource
Support for dynamic strings.
void(*const get_value)(struct prometheus_metric *metric, struct ast_endpoint_snapshot *snapshot)
Callback function to generate a metric value for a given endpoint.
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.
const char * help
Pointer to a static string defining this metric's help text.
char value[PROMETHEUS_MAX_VALUE_LENGTH]
The current value.
enum prometheus_metric_type type
What type of metric we are.
A function table for a metrics provider.
const char * name
Handy name of the provider for debugging purposes.
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.