· KLDP.org · KLDP.net · KLDP Wiki · KLDP BBS ·
Asterisk Source/My Sql

AsteriskSource/MySql


* asterisk-addons-1.0.1
  • cdr_addon_mysql.c 에 있는 함수
    • handle_cdr_mysql_status수
    • mysql_log
    • load_module
      • my_load_module
  • app_addon_sql_mysql.c 의 내용
static char *descrip =
"MYSQL():  Do several mySQLy things\n"
"Syntax:\n"
"  MYSQL(Connect connid dhhost dbuser dbpass dbname)\n"
"    Connects to a database.  Arguments contain standard MySQL parameters\n"
"    passed to function mysql_real_connect.  Connection identifer returned\n"
"    in ${var}\n"
"  MYSQL(Query resultid ${connid} query-string)\n"
"    Executes standard MySQL query contained in query-string using established\n"
"    connection identified by ${connection_identifier}. Result of query is\n"
"    is stored in ${var}.\n"
"  MYSQL(Fetch fetchid ${resultid} var1 var2 ... varN)\n"
"    Fetches a single row from a result set contained in ${result_identifier}.\n"
"    Assigns returned fields to ${var1} ... ${varn}.  ${fetchid} is set TRUE\n"
"    if additional rows exist in result set.\n"
"  MYSQL(Clear ${resultid})\n"
"    Frees memory and datastructures associated with result set.\n"
"  MYSQL(Disconnect ${connid})\n"
"    Disconnects from named connection to MySQL.\n" ;

/*
EXAMPLES OF USE :

exten => s,2,MYSQL(Connect connid localhost asterisk mypass credit)
exten => s,3,MYSQL(Query resultid ${connid} SELECT username,credit FROM credit WHERE callerid=${CALLERIDNUM})
exten => s,4,MYSQL(Fetch fetchid ${resultid} datavar1 datavar2)
exten => s,5,GotoIf(${fetchid}?6:8)
exten => s,6,Festival("User ${datavar1} currently has credit balance of ${datavar2} dollars.")
exten => s,7,Goto(s,4)
exten => s,8,MYSQL(Clear ${resultid})
exten => s,9,MYSQL(Disconnect ${connid})
*/

asterisk-addons-1.4.9


* cdr/cdr_addon_mysql.c
  • load_module
  • my_load_module();
  • res = ast_cdr_register(name, desc, mysql_log);

* main/asterisk.c
  • ast_cdr_engine_init()
    • term_quit()
  • ast_cdr_engine_term(); qdr 의 경우 없어도 될 듯.

* main/cdr.c
  • int ast_cdr_engine_init(void)
    • sched = sched_context_create();
    • ast_cli_register(&cli_status);
    • res = do_reload();
    • if (res)
      • res = init_batch();

  • ast_cdr_register(const char *name, const char *desc, ast_cdrbe be)
    • struct ast_cdr_beitem *i;
    • i->be = be;
  • do_batch_backend_process(void *data)
    • post_cdr(batchitem->cdr);
  • post_cdr(struct ast_cdr *cdr)
    • i->be(cdr);
  • ast_cdr_merge : not used
    • ast_cdr_append(to, zcdr);
  • app_forkcdr.c
    • ast_cdr_fork
      • ast_cdr_append
By default, asterisk will write or post your call detail record (CDR) at the end of every calls. This help keeping track of all calls including bill seconds. But if you have too many calls, the load of your server writing CDR or inserting in the database can become enormous.

You can add some options in /etc/asterisk/cdr.conf. For example, asterisk can just collect the cdr and after 10 calls ou 5 minutes, write the call details in a file or insert them in the database.

* asterisk
  • cdr/cdr_csv.c
    • res = ast_cdr_register(name, ast_module_info->description, csv_log);
  • cdr/cdr_custom.c
    • res = ast_cdr_register(name, ast_module_info->description, custom_log);
  • cdr/cdr_manager.c
    • res = ast_cdr_register(name, "Asterisk Manager Interface CDR Backend", manager_log);
  • cdr/cdr_odbc.c
    • res = ast_cdr_register(name, ast_module_info->description, odbc_log);
  • cdr_pgsql.c, cdr_radius.c, cdr_sqlite.c, cdr_tds.c

call detailed record (CDR)

* main
  • ast_cdr_engine_init() : main/cdr.c
    • ast_pthread_create_background(&cdr_thread, NULL, do_cdr, NULL)
      • do_cdr
        • ast_cond_timedwait(&cdr_pending_cond, &cdr_pending_lock, &timeout);
        • numevents = ast_sched_runq(sched);

* ast_cdr_detach
  • submit_unscheduled_batch(void)
    • ast_cond_signal(&cdr_pending_cond);

* handle_cli_submit
  • submit_unscheduled_batch(void)
    • cdr_sched = ast_sched_add(sched, 1, submit_scheduled_batch, NULL);
    • ast_cond_signal(&cdr_pending_cond);

* static int submit_scheduled_batch(const void *data)
  • ast_cdr_submit_batch(0);
  • cdr_sched = ast_sched_add(sched, batchtime * 1000, submit_scheduled_batch, NULL);



sponsored by andamiro
sponsored by cdnetworks
sponsored by HP

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-09-26 16:11:36
Processing time 0.0117 sec