50 #include "beanstalk.h" 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" 70 static 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);
struct ast_variable * next
#define ast_rwlock_rdlock(a)
int ast_cdr_backend_suspend(const char *name)
Suspend a CDR backend temporarily.
char accountcode[AST_MAX_ACCOUNT_CODE]
Asterisk main include file. File version handling, generic pbx functions.
int ast_cdr_unregister(const char *name)
Unregister a CDR handling engine.
#define AST_RWLOCK_DEFINE_STATIC(rwlock)
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
char dstchannel[AST_MAX_EXTENSION]
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
Time-related functions and macros.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
int ast_cdr_backend_unsuspend(const char *name)
Unsuspend a CDR backend.
#define CONFIG_STATUS_FILEINVALID
void ast_json_free(void *p)
Asterisk's custom JSON allocator. Exposed for use by unit tests.
char dcontext[AST_MAX_EXTENSION]
#define DEFAULT_BEANSTALK_HOST
static int unload_module(void)
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.
#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)
char lastdata[AST_MAX_EXTENSION]
Configuration File Parser.
#define ast_config_load(filename, flags)
Load a config file.
int ast_cdr_register(const char *name, const char *desc, ast_cdrbe be)
Register a CDR handling engine.
General Asterisk PBX channel definitions.
Asterisk JSON abstraction layer.
static int beanstalk_put(struct ast_cdr *cdr)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
char uniqueid[AST_MAX_UNIQUEID]
char dst[AST_MAX_EXTENSION]
char channel[AST_MAX_EXTENSION]
Core PBX routines and definitions.
#define BEANSTALK_JOB_TTR
#define CONFIG_STATUS_FILEUNCHANGED
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
Responsible for call detail data.
char lastapp[AST_MAX_EXTENSION]
const char * ast_cdr_disp2str(int disposition)
Disposition to a string.
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".
#define BEANSTALK_JOB_PRIORITY
static ast_rwlock_t config_lock
#define DEFAULT_BEANSTALK_PORT
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...
Structure used to handle boolean flags.
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",)
char src[AST_MAX_EXTENSION]
#define ast_rwlock_wrlock(a)
#define BEANSTALK_JOB_DELAY
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
#define DEFAULT_BEANSTALK_TUBE
static int load_config(int reload)
Abstract JSON element (object, array, string, int, ...).
char clid[AST_MAX_EXTENSION]
static int load_module(void)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
char userfield[AST_MAX_USER_FIELD]