60#define DATE_FORMAT "%Y-%m-%d %T"
61#define CONF_FILE "cdr_beanstalkd.conf"
62#define BEANSTALK_JOB_SIZE 4096
63#define BEANSTALK_JOB_PRIORITY 99
64#define BEANSTALK_JOB_TTR 60
65#define BEANSTALK_JOB_DELAY 0
66#define DEFAULT_BEANSTALK_HOST "127.0.0.1"
67#define DEFAULT_BEANSTALK_PORT 11300
68#define DEFAULT_BEANSTALK_TUBE "asterisk-cdr"
70static const char name[] =
"cdr_beanstalkd";
122 if (!strcasecmp(cat,
"general")) {
126 if (!strcasecmp(v->
name,
"enabled")) {
128 }
else if (!strcasecmp(v->
name,
"host")) {
131 }
else if (!strcasecmp(v->
name,
"port")) {
133 }
else if (!strcasecmp(v->
name,
"tube")) {
136 }
else if (!strcasecmp(v->
name,
"priority")) {
153 }
else if (newenablecdr) {
164 char strAnswerTime[80] =
"";
165 char strStartTime[80];
179 if (bs_use(bs_socket,
bs_tube) != BS_STATUS_OK) {
198 t_cdr_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:i, s:i, s:s, s:s, s:s, s:s}",
201 "Destination",
S_OR(cdr->
dst,
""),
208 "StartTime",
S_OR(strStartTime,
""),
209 "AnswerTime",
S_OR(strAnswerTime,
""),
210 "EndTime",
S_OR(strEndTime,
""),
225 ast_log(
LOG_DEBUG,
"Successfully created job %d with %s\n", bs_id, cdr_buffer);
230 bs_disconnect(bs_socket);
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
int ast_cdr_backend_unsuspend(const char *name)
Unsuspend a CDR backend.
int ast_cdr_unregister(const char *name)
Unregister a CDR handling engine.
const char * ast_cdr_disp2str(int disposition)
Disposition to a string.
int ast_cdr_register(const char *name, const char *desc, ast_cdrbe be)
Register a CDR handling engine.
int ast_cdr_backend_suspend(const char *name)
Suspend a CDR backend temporarily.
static int beanstalk_put(struct ast_cdr *cdr)
#define DEFAULT_BEANSTALK_HOST
static ast_rwlock_t config_lock
#define BEANSTALK_JOB_DELAY
#define DEFAULT_BEANSTALK_TUBE
static int load_module(void)
static int unload_module(void)
static int load_config(int reload)
#define BEANSTALK_JOB_PRIORITY
#define DEFAULT_BEANSTALK_PORT
#define BEANSTALK_JOB_TTR
General Asterisk PBX channel definitions.
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
Configuration File Parser.
#define ast_config_load(filename, flags)
Load a config file.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
@ CONFIG_FLAG_FILEUNCHANGED
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Asterisk JSON abstraction layer.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
void ast_json_free(void *p)
Asterisk's custom JSON allocator. Exposed for use by unit tests.
#define ast_json_dump_string(root)
Encode a JSON value to a compact string.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
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...
#define ast_rwlock_wrlock(a)
#define ast_rwlock_rdlock(a)
#define AST_RWLOCK_DEFINE_STATIC(rwlock)
#define ast_rwlock_unlock(a)
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
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.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Core PBX routines and definitions.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Responsible for call detail data.
char dstchannel[AST_MAX_EXTENSION]
char lastdata[AST_MAX_EXTENSION]
char userfield[AST_MAX_USER_FIELD]
char channel[AST_MAX_EXTENSION]
char src[AST_MAX_EXTENSION]
char dst[AST_MAX_EXTENSION]
char clid[AST_MAX_EXTENSION]
char uniqueid[AST_MAX_UNIQUEID]
char accountcode[AST_MAX_ACCOUNT_CODE]
char lastapp[AST_MAX_EXTENSION]
char dcontext[AST_MAX_EXTENSION]
Structure used to handle boolean flags.
Abstract JSON element (object, array, string, int, ...).
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
Time-related functions and macros.