74static const char app[] =
"StatsD";
88 double numerical_value = strtod(
value,
NULL);
90 if (numerical_value < pow(-2, 63) || numerical_value > pow(2, 63)) {
110 double numerical_value = strtod(
value,
NULL);
112 if (numerical_value < 0 || numerical_value > pow(2, 64)) {
133 const char *valid_metrics[] = {
"g",
"s",
"ms",
"c"};
141 for (i = 0; i <
ARRAY_LEN(valid_metrics); i++) {
142 if (!strcmp(valid_metrics[i], metric)) {
165 int decimal_counter = 0;
169 if (!isdigit(*num++)) {
170 if (strstr(numeric_value,
".") !=
NULL && decimal_counter == 0) {
195 const char *actual_value;
197 if ((raw_value[0] ==
'+') || (raw_value[0] ==
'-')) {
198 actual_value = &raw_value[1];
201 " operator.\n", raw_value);
205 actual_value = &raw_value[0];
227 " character.\n",
name);
340 " in a set metric.\n",
value);
350 double numerical_rate = 1.0;
361 "StatsD(metric_type,statistic_name,value[,sample_rate]). Sample rate is the "
362 "only optional parameter.\n");
373 if (!strcmp(
args.metric_type,
"g")) {
379 else if (!strcmp(
args.metric_type,
"c")) {
385 else if (!strcmp(
args.metric_type,
"ms")) {
391 else if (!strcmp(
args.metric_type,
"s")) {
398 if (
args.sample_rate) {
404 numerical_rate = strtod(
args.sample_rate,
NULL);
427 .
requires =
"res_statsd",
static int validate_metric_type_gauge(const char *statistic_name, const char *value)
Calls the appropriate functions to validate a gauge metric.
static int statsd_exec(struct ast_channel *chan, const char *data)
static int determine_actual_value(const char *raw_value)
Determines the actual value of a number by looking for a leading + or -.
static int validate_numeric(const char *numeric_value)
Check to ensure that a numeric value is valid.
static int validate_metric_type_set(const char *statistic_name, const char *value)
Calls the appropriate functions to validate a set metric.
static int validate_metric_type_timer(const char *statistic_name, const char *value)
Calls the appropriate functions to validate a timer metric.
static int non_neg_value_range(const char *value)
Check to ensure the value is within the allowed range.
static int validate_name(const char *name)
Check to ensure the statistic name is valid.
static int value_in_range(const char *value)
Check to ensure the value is within the allowed range.
static int load_module(void)
static int validate_metric(const char *metric)
Check to ensure the metric type is a valid metric type.
static int validate_metric_type_counter(const char *statistic_name, const char *value)
Calls the appropriate functions to validate a counter metric.
static int unload_module(void)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
Support for logging to various files, console and syslog Configuration in file logger....
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_EXTENDED
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Core PBX routines and definitions.
void ast_statsd_log_string(const char *metric_name, const char *metric_type, const char *value, double sample_rate)
Send a stat to the configured statsd server.
String manipulation functions.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Main Channel structure associated with a channel.