38 e->
command =
"prometheus show metrics";
40 "Usage: prometheus show metrics\n" 41 " Displays the current metrics and their values,\n" 42 " without counting as an actual scrape.\n";
54 ast_cli(a->
fd,
"Egads! An unknown error occurred getting the metrics\n");
67 struct ast_tm last_scrape_local;
68 struct timeval last_scrape_time;
69 int64_t scrape_duration;
72 e->
command =
"prometheus show status";
74 "Usage: prometheus show status\n" 75 " Displays the status of metrics collection.\n";
87 ast_cli(a->
fd,
"Prometheus Metrics Status:\n");
93 if (last_scrape_time.tv_sec == 0 && last_scrape_time.tv_usec == 0) {
94 snprintf(time_buffer,
sizeof(time_buffer),
"%s",
"(N/A)");
97 ast_strftime(time_buffer,
sizeof(time_buffer),
"%Y-%m-%d %H:%M:%S", &last_scrape_local);
101 ast_cli(a->
fd,
"\tLast Scrape Duration: ");
103 if (scrape_duration < 0) {
106 ast_cli(a->
fd,
"%" PRIu64
" ms\n", scrape_duration);
static char * prometheus_show_metrics(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define AST_CLI_DEFINE(fn, txt,...)
Asterisk main include file. File version handling, generic pbx functions.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Prometheus general configuration.
descriptor for a cli entry.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
#define ast_cli_register_multiple(e, len)
Register multiple commands.
void ast_cli(int fd, const char *fmt,...)
int cli_init(void)
Initialize CLI command.
#define ast_strlen_zero(foo)
static void cli_unload_cb(void)
int64_t prometheus_last_scrape_duration_get(void)
Retrieve the amount of time it took to perform the last scrape.
Custom localtime functions for multiple timezones.
struct timeval prometheus_last_scrape_time_get(void)
Retrieve the timestamp when the last scrape occurred.
#define ao2_ref(o, delta)
static struct prometheus_metrics_provider provider
void prometheus_metrics_provider_register(const struct prometheus_metrics_provider *provider)
Register a metrics provider.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
const char * name
Handy name of the provider for debugging purposes.
const ast_string_field uri
The HTTP URI we register ourselves to.
struct ast_str * prometheus_scrape_to_string(void)
Get the raw output of what a scrape would produce.
Standard Command Line Interface.
static char * prometheus_show_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
A function table for a metrics provider.
static struct ast_cli_entry cli_prometheus[]
struct prometheus_general_config * prometheus_general_config_get(void)
Retrieve the current configuration of the module.
const ast_string_field auth_username
Auth username for Basic Auth.
unsigned int enabled
Whether or not the module is enabled.