Difference between revisions of "3rd party software/Asterisk"
Line 3: | Line 3: | ||
Asterisk can be used as <b><em>Soft Switch</em></b> (among many other things). Freeside can examine recorded CDR data for subscriber billing purposes. | Asterisk can be used as <b><em>Soft Switch</em></b> (among many other things). Freeside can examine recorded CDR data for subscriber billing purposes. | ||
− | ;CDR | + | == cdr_pgsql == |
− | : | + | |
− | : | + | Call detail records are stored by asterisk (by means of the cdr_pgsql extension) into a database of our choice. We will need to edit <code>/etc/asterisk/cdr_pgsql.conf</code>, add the asterisk user to [[postgres]], add rights for asterisk to access the cdr table, and verify settings actually work. |
+ | |||
+ | === cdr_pgsql.conf === | ||
+ | |||
+ | This is our example config file. You will need to change the password to suit your install. | ||
+ | |||
+ | <pre>; Sample Asterisk config file for CDR logging to PostgresSQL | ||
+ | |||
+ | [global] | ||
+ | hostname=postgres | ||
+ | port=5432 | ||
+ | dbname=freeside | ||
+ | password=FIXTHIS | ||
+ | user=asterisk | ||
+ | table=cdr ;SQL table where CDRs will be inserted | ||
+ | spool=pgsql.spool</pre> | ||
+ | |||
+ | === pg_hba.conf === | ||
+ | |||
+ | This pg_hba.conf sample is only a snippet of the ACL to permit asterisk to connect. | ||
+ | |||
+ | ;hostssl (or host) | ||
+ | :The connection type. | ||
+ | ;10.14.0.0/24 | ||
+ | :This example is a class C subnet. | ||
+ | ;md5 | ||
+ | :Password authentication required | ||
+ | |||
+ | <pre>hostssl asterisk freeside 10.14.0.0/24 md5</pre> | ||
+ | |||
+ | ;Check for sql access from the asterisk server | ||
+ | :pghostname is the postgres host where freeside is running. | ||
+ | <pre>pbx:~$ psql -h pghostname -U asterisk freeside | ||
+ | Password for user asterisk: | ||
+ | Welcome to psql 8.1.11, the PostgreSQL interactive terminal. | ||
+ | |||
+ | Type: \copyright for distribution terms | ||
+ | \h for help with SQL commands | ||
+ | \? for help with psql commands | ||
+ | \g or terminate with semicolon to execute query | ||
+ | \q to quit | ||
+ | |||
+ | SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256) | ||
+ | |||
+ | freeside=> | ||
+ | </pre> | ||
+ | |||
+ | Check for storage results in the sql table. | ||
+ | |||
+ | <pre>freeside=# SELECT acctid,calldate,src,dst,duration,billsec,disposition from cdr; | ||
+ | acctid | calldate | src | dst | duration | billsec | disposition | ||
+ | --------+------------------------+------------+-------------+----------+---------+------------- | ||
+ | 1 | 2008-02-20 15:40:00+00 | 8005551212 | 18004664411 | 19 | 0 | NO ANSWER | ||
+ | 2 | 2008-02-20 15:48:52+00 | 8005551212 | 18004664411 | 14 | 10 | ANSWERED | ||
+ | (2 rows) | ||
+ | |||
+ | freeside=#</pre> | ||
+ | |||
+ | If needed, /var/log/asterisk/messages or the asterisk interactive cli will provide reporting for any errors. | ||
+ | |||
+ | Error logs here were from insufficient <code>GRANT</code> permissions to <em>asterisk</em> (as a Pg user). | ||
+ | |||
+ | <pre>Feb 20 15:37:40 ERROR[3404]: cdr_pgsql.c:159 pgsql_log: cdr_pgsql: Failed to insert call detail record into database! | ||
+ | Feb 20 15:37:40 ERROR[3404]: cdr_pgsql.c:160 pgsql_log: cdr_pgsql: Reason: ERROR: permission denied for sequence cdr_acctid_seq | ||
+ | Feb 20 15:37:40 ERROR[3404]: cdr_pgsql.c:161 pgsql_log: cdr_pgsql: Connection may have been lost... attempting to reconnect. | ||
+ | Feb 20 15:37:40 ERROR[3404]: cdr_pgsql.c:164 pgsql_log: cdr_pgsql: Connection reestablished. | ||
+ | Feb 20 15:37:40 ERROR[3404]: cdr_pgsql.c:170 pgsql_log: cdr_pgsql: HARD ERROR! Attempted reconnection failed. DROPPING CALL RECORD! | ||
+ | Feb 20 15:37:40 ERROR[3404]: cdr_pgsql.c:171 pgsql_log: cdr_pgsql: Reason: ERROR: permission denied for sequence cdr_acctid_seq</pre> | ||
== See Also == | == See Also == | ||
* [http://en.wikipedia.org/w/index.php?title=Telephone_switch Telephone Switching] on Wikipedia. | * [http://en.wikipedia.org/w/index.php?title=Telephone_switch Telephone Switching] on Wikipedia. | ||
+ | * http://www.voip-info.org/wiki/view/Asterisk+cdr+pgsql |
Revision as of 08:55, 20 February 2008
Asterisk can be used as Soft Switch (among many other things). Freeside can examine recorded CDR data for subscriber billing purposes.
cdr_pgsql
Call detail records are stored by asterisk (by means of the cdr_pgsql extension) into a database of our choice. We will need to edit /etc/asterisk/cdr_pgsql.conf
, add the asterisk user to postgres, add rights for asterisk to access the cdr table, and verify settings actually work.
cdr_pgsql.conf
This is our example config file. You will need to change the password to suit your install.
; Sample Asterisk config file for CDR logging to PostgresSQL [global] hostname=postgres port=5432 dbname=freeside password=FIXTHIS user=asterisk table=cdr ;SQL table where CDRs will be inserted spool=pgsql.spool
pg_hba.conf
This pg_hba.conf sample is only a snippet of the ACL to permit asterisk to connect.
- hostssl (or host)
- The connection type.
- 10.14.0.0/24
- This example is a class C subnet.
- md5
- Password authentication required
hostssl asterisk freeside 10.14.0.0/24 md5
- Check for sql access from the asterisk server
- pghostname is the postgres host where freeside is running.
pbx:~$ psql -h pghostname -U asterisk freeside Password for user asterisk: Welcome to psql 8.1.11, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256) freeside=>
Check for storage results in the sql table.
freeside=# SELECT acctid,calldate,src,dst,duration,billsec,disposition from cdr; acctid | calldate | src | dst | duration | billsec | disposition --------+------------------------+------------+-------------+----------+---------+------------- 1 | 2008-02-20 15:40:00+00 | 8005551212 | 18004664411 | 19 | 0 | NO ANSWER 2 | 2008-02-20 15:48:52+00 | 8005551212 | 18004664411 | 14 | 10 | ANSWERED (2 rows) freeside=#
If needed, /var/log/asterisk/messages or the asterisk interactive cli will provide reporting for any errors.
Error logs here were from insufficient GRANT
permissions to asterisk (as a Pg user).
Feb 20 15:37:40 ERROR[3404]: cdr_pgsql.c:159 pgsql_log: cdr_pgsql: Failed to insert call detail record into database! Feb 20 15:37:40 ERROR[3404]: cdr_pgsql.c:160 pgsql_log: cdr_pgsql: Reason: ERROR: permission denied for sequence cdr_acctid_seq Feb 20 15:37:40 ERROR[3404]: cdr_pgsql.c:161 pgsql_log: cdr_pgsql: Connection may have been lost... attempting to reconnect. Feb 20 15:37:40 ERROR[3404]: cdr_pgsql.c:164 pgsql_log: cdr_pgsql: Connection reestablished. Feb 20 15:37:40 ERROR[3404]: cdr_pgsql.c:170 pgsql_log: cdr_pgsql: HARD ERROR! Attempted reconnection failed. DROPPING CALL RECORD! Feb 20 15:37:40 ERROR[3404]: cdr_pgsql.c:171 pgsql_log: cdr_pgsql: Reason: ERROR: permission denied for sequence cdr_acctid_seq