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.
An actual, honest to god, metric.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
char * ast_eid_to_str(char *s, int maxlen, struct ast_eid *eid)
Convert an EID to a string.
int prometheus_callback_register(struct prometheus_callback *callback)
#define ao2_container_clone(orig, flags)
struct stasis_message_type * ast_endpoint_snapshot_type(void)
Message type for ast_endpoint_snapshot.
const char * name
The name of our callback (always useful for debugging)
enum prometheus_metric_type type
What type of metric we are.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
int endpoint_metrics_init(void)
Initialize endpoint metrics.
const ast_string_field id
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.
#define PROMETHEUS_METRIC_STATIC_INITIALIZATION(mtype, n, h, cb)
Convenience macro for initializing a metric on the stack.
void prometheus_metric_to_string(struct prometheus_metric *metric, struct ast_str **output)
Convert a metric (and its children) into Prometheus compatible text.
const char * help
Help text to display.
#define PROMETHEUS_METRIC_SET_LABEL(metric, label, n, v)
Convenience macro for setting a label / value in a metric.
const ast_string_field resource
static struct ao2_container * endpoints
#define ao2_ref(o, delta)
static void get_endpoint_state(struct prometheus_metric *metric, struct ast_endpoint_snapshot *snapshot)
void prometheus_metrics_provider_register(const struct prometheus_metrics_provider *provider)
Register a metrics provider.
A snapshot of an endpoint's state.
static void get_endpoint_channel_count(struct prometheus_metric *metric, struct ast_endpoint_snapshot *snapshot)
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
const ast_string_field tech
static void endpoints_scrape_cb(struct ast_str **response)
#define ao2_iterator_next(iter)
const char * name
Name of the metric.
char value[PROMETHEUS_MAX_VALUE_LENGTH]
The current value.
static struct prometheus_metrics_provider provider
const char * help
Pointer to a static string defining this metric's help text.
#define ast_calloc(num, len)
A wrapper for calloc()
#define ENDPOINTS_STATE_HELP
void(*const get_value)(struct prometheus_metric *metric, struct ast_endpoint_snapshot *snapshot)
Callback function to generate a metric value for a given endpoint.
void prometheus_callback_unregister(struct prometheus_callback *callback)
Remove a registered callback.
const char * name
Handy name of the provider for debugging purposes.
struct ast_eid ast_eid_default
Global EID.
static void endpoint_metrics_unload_cb(void)
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
A function table for a metrics provider.
#define ENDPOINTS_CHANNELS_COUNT_HELP
struct prometheus_callback endpoints_callback
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
Defines a callback that will be invoked when the HTTP route is called.
enum ast_endpoint_state state
struct stasis_cache * ast_endpoint_cache(void)
Backend cache for ast_endpoint_topic_all_cached().