Asterisk - The Open Source Telephony Project GIT-master-0644429
|
PostgreSQL CDR logger. More...
#include "asterisk.h"
#include <libpq-fe.h>
#include "asterisk/config.h"
#include "asterisk/channel.h"
#include "asterisk/cdr.h"
#include "asterisk/cli.h"
#include "asterisk/module.h"
Go to the source code of this file.
Data Structures | |
struct | columns |
struct | psql_columns |
Macros | |
#define | DATE_FORMAT "'%Y-%m-%d %T'" |
#define | LENGTHEN_BUF(size, var_sql) |
#define | LENGTHEN_BUF1(size) LENGTHEN_BUF(size, sql); |
#define | LENGTHEN_BUF2(size) LENGTHEN_BUF(size, sql2); |
#define | PGSQL_MIN_VERSION_SCHEMA 70300 |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static int | config_module (int reload) |
static void | empty_columns (void) |
static char * | handle_cdr_pgsql_status (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
Handle the CLI command cdr show pgsql status. More... | |
static int | load_module (void) |
static int | pgsql_log (struct ast_cdr *cdr) |
static void | pgsql_reconnect (void) |
static int | reload (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PostgreSQL CDR Backend" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CDR_DRIVER, .requires = "cdr", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_cli_entry | cdr_pgsql_status_cli [] |
static const char | config [] = "cdr_pgsql.conf" |
static PGconn * | conn = NULL |
static time_t | connect_time = 0 |
static int | connected = 0 |
static char * | encoding |
static int | maxsize = 512 |
static int | maxsize2 = 512 |
static const char | name [] = "pgsql" |
static char * | pgappname |
static char * | pgdbname |
static char * | pgdbport |
static char * | pgdbuser |
static char * | pghostname |
static char * | pgpassword |
static ast_mutex_t | pgsql_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
static struct psql_columns | psql_columns = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static int | records |
static char * | table |
static int | totalrecords = 0 |
static char * | tz |
PostgreSQL CDR logger.
Definition in file cdr_pgsql.c.
#define DATE_FORMAT "'%Y-%m-%d %T'" |
Definition at line 56 of file cdr_pgsql.c.
#define LENGTHEN_BUF | ( | size, | |
var_sql | |||
) |
Definition at line 100 of file cdr_pgsql.c.
#define LENGTHEN_BUF1 | ( | size | ) | LENGTHEN_BUF(size, sql); |
Definition at line 115 of file cdr_pgsql.c.
#define LENGTHEN_BUF2 | ( | size | ) | LENGTHEN_BUF(size, sql2); |
Definition at line 117 of file cdr_pgsql.c.
#define PGSQL_MIN_VERSION_SCHEMA 70300 |
Definition at line 58 of file cdr_pgsql.c.
|
static |
Definition at line 817 of file cdr_pgsql.c.
|
static |
Definition at line 817 of file cdr_pgsql.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 817 of file cdr_pgsql.c.
|
static |
Definition at line 520 of file cdr_pgsql.c.
References ast_alloca, ast_calloc, ast_config_destroy(), ast_config_load, ast_debug, ast_free, ast_log, AST_MODULE_LOAD_DECLINE, ast_mutex_lock, ast_mutex_unlock, AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strdup, ast_strdupa, ast_strlen_zero(), ast_variable_browse(), ast_variable_retrieve(), config, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, conn, connect_time, connected, DEBUG_ATLEAST, empty_columns(), encoding, columns::hasdefault, columns::len, LOG_DEBUG, LOG_ERROR, LOG_NOTICE, LOG_WARNING, columns::name, columns::notnull, NULL, pgappname, pgdbname, pgdbport, pgdbuser, pghostname, pgpassword, pgsql_lock, PGSQL_MIN_VERSION_SCHEMA, pgsql_reconnect(), records, reload(), result, table, tmp(), columns::type, tz, unload_module(), and version.
Referenced by load_module(), and reload().
|
static |
Definition at line 482 of file cdr_pgsql.c.
References ast_free, AST_RWLIST_REMOVE_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, current, and columns::list.
Referenced by config_module(), and unload_module().
|
static |
Handle the CLI command cdr show pgsql status.
Definition at line 121 of file cdr_pgsql.c.
References a, ast_cli_entry::args, ast_cli(), ast_cli_print_timestr_fromseconds(), buf, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, connect_time, connected, NULL, pgdbname, pgdbport, pgdbuser, pghostname, records, status, table, totalrecords, and ast_cli_entry::usage.
|
static |
Definition at line 784 of file cdr_pgsql.c.
References ARRAY_LEN, ast_cdr_register(), ast_cli_register_multiple, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, cdr_pgsql_status_cli, config_module(), ast_module_info::description, name, pgsql_log(), and unload_module().
|
static |
Definition at line 210 of file cdr_pgsql.c.
References ast_cdr::answer, ast_cdr_format_var(), ast_debug, ast_free, ast_localtime(), ast_log, ast_malloc, ast_mutex_lock, ast_mutex_unlock, ast_realloc, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_set(), ast_str_strlen(), ast_strftime(), ast_tvdiff_us(), ast_tvzero(), buf, conn, connect_time, connected, DATE_FORMAT, encoding, ast_cdr::end, columns::hasdefault, LENGTHEN_BUF1, LENGTHEN_BUF2, LOG_ERROR, LOG_WARNING, maxsize, maxsize2, columns::name, columns::notnull, NULL, pgdbname, pgdbuser, pghostname, pgpassword, pgsql_lock, pgsql_reconnect(), records, result, ast_cdr::start, table, totalrecords, columns::type, tz, and value.
Referenced by load_module().
|
static |
Definition at line 170 of file cdr_pgsql.c.
References ast_free, ast_log, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_strlen(), ast_strlen_zero(), conn, LOG_ERROR, NULL, pgappname, pgdbname, pgdbport, pgdbuser, pghostname, and pgpassword.
Referenced by config_module(), and pgsql_log().
|
static |
Definition at line 805 of file cdr_pgsql.c.
References config_module().
Referenced by config_module().
|
static |
Definition at line 493 of file cdr_pgsql.c.
References ARRAY_LEN, ast_cdr_unregister(), ast_cli_unregister_multiple(), ast_free, cdr_pgsql_status_cli, conn, empty_columns(), encoding, name, NULL, pgappname, pgdbname, pgdbport, pgdbuser, pghostname, pgpassword, table, and tz.
Referenced by config_module(), and load_module().
|
static |
Definition at line 817 of file cdr_pgsql.c.
|
static |
Definition at line 817 of file cdr_pgsql.c.
|
static |
Definition at line 81 of file cdr_pgsql.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 61 of file cdr_pgsql.c.
Referenced by config_module().
|
static |
Definition at line 87 of file cdr_pgsql.c.
Referenced by config_module(), load_mysql_config(), mysql_reconnect(), pgsql_log(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 76 of file cdr_pgsql.c.
Referenced by config_module(), handle_cdr_pgsql_status(), and pgsql_log().
|
static |
Definition at line 73 of file cdr_pgsql.c.
Referenced by config_module(), handle_cdr_pgsql_status(), and pgsql_log().
|
static |
Definition at line 70 of file cdr_pgsql.c.
Referenced by check_header(), config_module(), custom_prepare(), pgsql_log(), and unload_module().
|
static |
Definition at line 75 of file cdr_pgsql.c.
Referenced by pgsql_log().
|
static |
Definition at line 75 of file cdr_pgsql.c.
Referenced by pgsql_log().
|
static |
Definition at line 60 of file cdr_pgsql.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 67 of file cdr_pgsql.c.
Referenced by config_module(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 64 of file cdr_pgsql.c.
Referenced by config_module(), handle_cdr_pgsql_status(), pgsql_log(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 68 of file cdr_pgsql.c.
Referenced by config_module(), handle_cdr_pgsql_status(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 65 of file cdr_pgsql.c.
Referenced by config_module(), handle_cdr_pgsql_status(), pgsql_log(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 63 of file cdr_pgsql.c.
Referenced by config_module(), handle_cdr_pgsql_status(), pgsql_log(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 66 of file cdr_pgsql.c.
Referenced by config_module(), pgsql_log(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 85 of file cdr_pgsql.c.
Referenced by config_module(), and pgsql_log().
|
static |
|
static |
Definition at line 78 of file cdr_pgsql.c.
Referenced by AST_TEST_DEFINE(), config_module(), dns_naptr_sort(), handle_cdr_pgsql_status(), invalid_record_test(), nominal_test(), off_nominal_test(), and pgsql_log().
|
static |
Definition at line 69 of file cdr_pgsql.c.
Referenced by config_module(), handle_cdr_pgsql_status(), pgsql_log(), and unload_module().
|
static |
Definition at line 77 of file cdr_pgsql.c.
Referenced by handle_cdr_pgsql_status(), and pgsql_log().
|
static |
Definition at line 71 of file cdr_pgsql.c.
Referenced by __ast_callerid_generate(), ast_callerid_callwaiting_full_tz_generate(), ast_callerid_full_tz_generate(), ast_get_indication_zone(), ast_tone_zone_ref(), ast_tone_zone_unref(), ast_unregister_indication_country(), ast_var_indications(), ast_var_indications_table(), callerid_full_tz_generate(), callerid_genmsg(), complete_country(), complete_indications(), config_module(), handle_cli_indication_add(), handle_cli_indication_remove(), handle_cli_indication_show(), iax2_datetime(), in_band_indication(), pgsql_log(), and unload_module().