Asterisk - The Open Source Telephony Project
18.5.0
|
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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .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.
See also
Definition in file cdr_pgsql.c.
#define DATE_FORMAT "'%Y-%m-%d %T'" |
Definition at line 60 of file cdr_pgsql.c.
Referenced by pgsql_log().
#define LENGTHEN_BUF | ( | size, | |
var_sql | |||
) |
Definition at line 104 of file cdr_pgsql.c.
#define LENGTHEN_BUF1 | ( | size | ) | LENGTHEN_BUF(size, sql); |
Definition at line 119 of file cdr_pgsql.c.
Referenced by pgsql_log().
#define LENGTHEN_BUF2 | ( | size | ) | LENGTHEN_BUF(size, sql2); |
Definition at line 121 of file cdr_pgsql.c.
Referenced by pgsql_log().
#define PGSQL_MIN_VERSION_SCHEMA 70300 |
Definition at line 62 of file cdr_pgsql.c.
Referenced by config_module().
|
static |
Definition at line 810 of file cdr_pgsql.c.
|
static |
Definition at line 810 of file cdr_pgsql.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 810 of file cdr_pgsql.c.
|
static |
Definition at line 524 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, columns::list, 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, result, table, tmp(), columns::type, tz, unload_module(), and version.
Referenced by load_module(), and reload().
|
static |
Definition at line 486 of file cdr_pgsql.c.
References ast_free, AST_RWLIST_REMOVE_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and columns::list.
Referenced by config_module(), and unload_module().
|
static |
Handle the CLI command cdr show pgsql status.
Definition at line 125 of file cdr_pgsql.c.
References ast_cli_args::argc, 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, ast_cli_args::fd, NULL, pgdbname, pgdbport, pgdbuser, pghostname, records, status, table, totalrecords, and ast_cli_entry::usage.
|
static |
Definition at line 788 of file cdr_pgsql.c.
References ast_cdr_register(), ast_cli_register_multiple, AST_MODULE_LOAD_DECLINE, config_module(), ast_module_info::description, columns::name, and pgsql_log().
Referenced by reload().
|
static |
Definition at line 214 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, columns::list, 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 174 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 798 of file cdr_pgsql.c.
References AST_MODFLAG_LOAD_ORDER, AST_MODPRI_CDR_DRIVER, AST_MODULE_INFO(), AST_MODULE_SUPPORT_EXTENDED, ASTERISK_GPL_KEY, config_module(), load_module(), and unload_module().
|
static |
Definition at line 497 of file cdr_pgsql.c.
References ARRAY_LEN, ast_cdr_unregister(), ast_cli_unregister_multiple(), ast_free, conn, empty_columns(), encoding, columns::name, NULL, pgappname, pgdbname, pgdbport, pgdbuser, pghostname, pgpassword, table, and tz.
Referenced by config_module(), and reload().
|
static |
Definition at line 810 of file cdr_pgsql.c.
|
static |
Definition at line 810 of file cdr_pgsql.c.
|
static |
Definition at line 85 of file cdr_pgsql.c.
|
static |
Definition at line 65 of file cdr_pgsql.c.
Referenced by config_module().
|
static |
Definition at line 91 of file cdr_pgsql.c.
Referenced by config_module(), pgsql_log(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 80 of file cdr_pgsql.c.
Referenced by config_module(), handle_cdr_pgsql_status(), and pgsql_log().
|
static |
Definition at line 77 of file cdr_pgsql.c.
Referenced by config_module(), handle_cdr_pgsql_status(), and pgsql_log().
|
static |
Definition at line 74 of file cdr_pgsql.c.
Referenced by check_header(), config_module(), pgsql_log(), and unload_module().
|
static |
Definition at line 79 of file cdr_pgsql.c.
Referenced by pgsql_log().
|
static |
Definition at line 79 of file cdr_pgsql.c.
Referenced by pgsql_log().
|
static |
Definition at line 64 of file cdr_pgsql.c.
|
static |
Definition at line 71 of file cdr_pgsql.c.
Referenced by config_module(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 68 of file cdr_pgsql.c.
Referenced by config_module(), handle_cdr_pgsql_status(), pgsql_log(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 72 of file cdr_pgsql.c.
Referenced by config_module(), handle_cdr_pgsql_status(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 69 of file cdr_pgsql.c.
Referenced by config_module(), handle_cdr_pgsql_status(), pgsql_log(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 67 of file cdr_pgsql.c.
Referenced by config_module(), handle_cdr_pgsql_status(), pgsql_log(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 70 of file cdr_pgsql.c.
Referenced by config_module(), pgsql_log(), pgsql_reconnect(), and unload_module().
|
static |
Definition at line 89 of file cdr_pgsql.c.
Referenced by config_module(), and pgsql_log().
|
static |
|
static |
Definition at line 82 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(), pgsql_log(), and unload_module().
|
static |
Definition at line 81 of file cdr_pgsql.c.
Referenced by handle_cdr_pgsql_status(), and pgsql_log().
|
static |
Definition at line 75 of file cdr_pgsql.c.
Referenced by ast_get_indication_zone(), ast_tone_zone_ref(), ast_unregister_indication_country(), ast_var_indications(), ast_var_indications_table(), complete_country(), complete_indications(), config_module(), handle_cli_indication_add(), handle_cli_indication_remove(), handle_cli_indication_show(), pgsql_log(), and unload_module().