58 #include "beanstalk.h" 62 static const char CONF_FILE[] =
"cel_beanstalkd.conf";
65 #define CEL_BEANSTALK_ENABLED_DEFAULT 0 70 #define CEL_SHOW_USERDEF_DEFAULT 0 72 #define CEL_BACKEND_NAME "Beanstalk Event Logging" 74 #define BEANSTALK_JOB_SIZE 4096 75 #define BEANSTALK_JOB_PRIORITY 99 76 #define BEANSTALK_JOB_TTR 60 77 #define BEANSTALK_JOB_DELAY 0 78 #define DEFAULT_BEANSTALK_HOST "127.0.0.1" 79 #define DEFAULT_BEANSTALK_PORT 11300 80 #define DEFAULT_BEANSTALK_TUBE "asterisk-cel" 113 if (bs_use(bs_socket,
bs_tube) != BS_STATUS_OK) {
124 t_cel_json =
ast_json_pack(
"{s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s, s:s}",
137 "EventTime",
S_OR(start_time,
""),
155 ast_log(
LOG_DEBUG,
"Successfully created job %d with %s\n", bs_id, cel_buffer);
160 bs_disconnect(bs_socket);
166 const char *cat =
NULL;
178 ast_log(
LOG_WARNING,
"Configuration file '%s' is invalid. CEL Beanstalkd Module not activated.\n",
182 ast_log(
LOG_WARNING,
"Failed to load configuration file. CEL Beanstalkd Module not activated.\n");
204 if (strcasecmp(cat,
"general")) {
209 if (!strcasecmp(v->
name,
"enabled")) {
211 }
else if (!strcasecmp(v->
name,
"host")) {
214 }
else if (!strcasecmp(v->
name,
"port")) {
216 }
else if (!strcasecmp(v->
name,
"tube")) {
219 }
else if (!strcasecmp(v->
name,
"priority")) {
223 "for CEL beanstalk backend.\n", v->
name);
const char * account_code
struct ast_variable * next
const char * caller_id_name
Helper struct for getting the fields out of a CEL event.
#define ast_rwlock_rdlock(a)
Asterisk main include file. File version handling, generic pbx functions.
#define AST_RWLOCK_DEFINE_STATIC(rwlock)
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
static const char CONF_FILE[]
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
int ast_cel_backend_register(const char *name, ast_cel_backend_cb backend_callback)
Register a CEL backend.
#define CEL_BEANSTALK_ENABLED_DEFAULT
Beanstalk CEL is off by default.
const char * application_data
const char * application_name
#define CONFIG_STATUS_FILEINVALID
void ast_json_free(void *p)
Asterisk's custom JSON allocator. Exposed for use by unit tests.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
Structure for variables, used for configurations and for channel variables.
#define ast_json_dump_string(root)
Encode a JSON value to a compact string.
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
const char * caller_id_num
#define ast_strdup(str)
A wrapper for strdup()
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
#define ast_rwlock_unlock(a)
#define DEFAULT_BEANSTALK_PORT
Configuration File Parser.
#define ast_config_load(filename, flags)
Load a config file.
General Asterisk PBX channel definitions.
Asterisk JSON abstraction layer.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
uint32_t version
struct ABI version
int ast_cel_backend_unregister(const char *name)
Unregister a CEL backend.
#define CONFIG_STATUS_FILEUNCHANGED
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
const char * caller_id_rdnis
#define BEANSTALK_JOB_PRIORITY
static ast_rwlock_t config_lock
#define BEANSTALK_JOB_DELAY
Module has failed to load, may be in an inconsistent state.
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 * caller_id_ani
#define AST_CEL_EVENT_RECORD_VERSION
struct ABI version
Structure used to handle boolean flags.
static int load_config(int reload)
Support for logging to various files, console and syslog Configuration in file logger.conf.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
#define ast_rwlock_wrlock(a)
const char * peer_account
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
#define BEANSTALK_JOB_TTR
Abstract JSON element (object, array, string, int, ...).
const char * caller_id_dnid
const char * channel_name
static int unload_module(void)
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define DEFAULT_BEANSTALK_HOST
Asterisk module definitions.
#define DEFAULT_BEANSTALK_TUBE
struct timeval event_time
int ast_cel_fill_record(const struct ast_event *event, struct ast_cel_event_record *r)
Fill in an ast_cel_event_record from a CEL event.
static int load_module(void)
static void cel_bs_put(struct ast_event *event)
static const char DATE_FORMAT[]