34#define CHANNELS_STATE_HELP "Individual channel states. 0=down; 1=reserved; 2=offhook; 3=dialing; 4=ring; 5=ringing; 6=up; 7=busy; 8=dialing_offhook; 9=prering." 
   36#define CHANNELS_DURATION_HELP "Individual channel durations (in seconds)." 
   62    snprintf(metric->
value, 
sizeof(metric->
value), 
"%" PRIu64, duration);
 
 
   85        .name = 
"asterisk_channels_state",
 
   90        .name = 
"asterisk_channels_duration_seconds",
 
  112        "asterisk_calls_sum",
 
  118        "asterisk_calls_count",
 
  119        "Current call count.",
 
 
  142        "asterisk_channels_count",
 
  143        "Current channel count.",
 
  164    snprintf(channel_count.
value, 
sizeof(channel_count.
value), 
"%d", num_channels);
 
  174    if (num_channels == 0) {
 
  181    if (!channel_metrics) {
 
  198            if (snapshot->
peer) {
 
 
  219    .
name = 
"Channels 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 void channel_metrics_unload_cb(void)
static void get_current_call_count(struct prometheus_metric *metric)
int channel_metrics_init(void)
Initialize channel metrics.
#define CHANNELS_DURATION_HELP
static void get_channel_state(struct prometheus_metric *metric, struct ast_channel_snapshot *snapshot)
static void get_channel_duration(struct prometheus_metric *metric, struct ast_channel_snapshot *snapshot)
#define CHANNELS_STATE_HELP
static struct prometheus_metrics_provider provider
static void get_total_call_count(struct prometheus_metric *metric)
static struct prometheus_metric global_channel_metrics[]
static void channels_scrape_cb(struct ast_str **response)
struct prometheus_callback channels_callback
static struct channel_usage channels
struct ao2_container * ast_channel_cache_all(void)
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Core PBX routines and definitions.
int ast_active_calls(void)
Retrieve the number of active calls.
int ast_processed_calls(void)
Retrieve the total number of calls processed through the PBX since last restart.
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.
@ PROMETHEUS_METRIC_COUNTER
A metric whose value always goes up.
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)
static struct ao2_container * channel_cache
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...
struct timeval creationtime
const ast_string_field uniqueid
const ast_string_field type
const ast_string_field name
Structure representing a snapshot of channel state.
struct ast_channel_snapshot_peer * peer
struct ast_channel_snapshot_base * base
enum ast_channel_state state
Support for dynamic strings.
void(*const get_value)(struct prometheus_metric *metric, struct ast_channel_snapshot *snapshot)
Callback function to generate a metric value for a given channel.
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.
struct prometheus_metric::@289 children
A list of children metrics.
void(* get_metric_value)(struct prometheus_metric *metric)
Callback function to obtain the metric value.
struct prometheus_metric::@290 entry
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.
int64_t ast_tvdiff_sec(struct timeval end, struct timeval start)
Computes the difference (in seconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
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.