<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.3790.2920" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Mauricio,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Eu segui o seguinte:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Faça download do site a2billing.org e salve o 
arquivo compactado na pasta /usr/src da seguinte forma:<BR>wget <A 
href="http://a2billing.net/downloads/A2Billing_versao.tar.gz">http://a2billing.net/downloads/A2Billing_versao.tar.gz</A></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Descompacte o arquivo com tar zxvf 
a2billing_versao.tar.gz.<BR>ele criará um diretório chamado trunk.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Instalando o database:<BR>cd 
trunk/DataBase/mysql/Mysql-3.x_4.x/</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>echo "GRANT ALL PRIVILEGES ON *.* TO <A 
href="mailto:'a2billinguser'@'localhost'">'a2billinguser'@'localhost'</A> 
IDENTIFIED BY 'a2billing' WITH GRANT OPTION;" | mysql -ppassw0rd</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>mysqladmin create mya2billing -u a2billinguser 
-pa2billing</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>mysql mya2billing -u a2billinguser -pa2billing &lt; 
a2billing-mysql-schema-MYSQL.3.X-4.X_v1.2.3.sql</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Instalando a interface de usuário:<BR>cd ..<BR>cd 
..<BR>cd ..</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>mv ./A2Billing_UI /var/www/html/a2billing <BR>mv 
./A2BCustomer_UI/ /var/www/html/a2customer</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Instalando o arquivo de configuração:<BR>mv 
a2billing.conf /etc/asterisk/a2billing.conf</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Instalando as AGIs:<BR>cd 
A2Billing_AGI</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>mv a2billing.php 
/var/lib/asterisk/agi-bin/a2billing.php</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>mv&nbsp; libs_a2billing 
/var/lib/asterisk/agi-bin<BR>&nbsp;<BR>Instalando os sons extras:<BR>cd ..<BR>cd 
/addons/sounds/</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>mv&nbsp; * /var/lib/asterisk/sounds/</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Criando os arquivos de configuração para clientes 
SIP e IAX:<BR>cd /etc/asterisk/<BR>touch additional_a2billing_iax.conf<BR>touch 
additional_a2billing_sip.conf<BR>touch extensions_a2billing.conf</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Para dar as permissões necessárias nos arquivos e 
diretórios:<BR>chmod 666 /etc/asterisk/additional_a2billing_iax.conf<BR>chmod 
666 /etc/asterisk/additional_a2billing_sip.conf<BR>chmod 666 
/etc/asterisk/extensions_a2billing.conf</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>chown -R asterisk:asterisk /etc/asterisk/<BR>chown 
-R asterisk:asterisk /var/www/html/<BR>chown -R asterisk:asterisk 
/var/lib/asterisk/</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Editando o arquivo a2billing.conf:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>A sessão de Database:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>comente a linha&nbsp; dbtype = 
postgres</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Remova o&nbsp; ; da linha ;dbtype = 
mysql</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Ficará assim:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>[database]<BR>hostname = localhost<BR>port = 
5432<BR>user = a2billinguser<BR>password = a2billing<BR>dbname = 
mya2billing<BR>;dbtype = postgres<BR>dbtype = mysql</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Na cessão de conexão do banco de dados ficará 
assim:<BR>; MANAGER CONNECTION PARAMETERS<BR>manager_host = 
localhost<BR>manager_username = a2billinguser<BR>manager_secret = 
a2billing</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Salve o arquivo.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Edite o arquivo /etc/asterisk/sip.conf e acrescente 
a linha include additional_a2billing_sip.conf do mesmo modo abaixo:<BR>; #, in 
this configuration file, is NOT A COMMENT. This is exactly<BR>; how it should 
be.<BR>#include sip_nat.conf<BR>#include sip_custom.conf<BR>#include 
sip_additional.conf<BR>#include additional_a2billing_sip.conf </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Faça o mesmo com o arquivo Iax.conf para que fique 
deste modo:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>#include iax_registrations_custom.conf<BR>#include 
iax_registrations.conf<BR>#include iax_custom.conf<BR>#include 
iax_additional.conf<BR>#include additional_a2billing_iax.conf</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Edite extensions_custom.conf e&nbsp; adicione 
#include extensions_a2billing.conf junto com os outros includes, para que fique 
deste modo:<BR>#include extensions_trixbox.conf<BR>#include 
extensions_hud.conf<BR>#include extensions_a2billing.conf</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>No arquivo extensions_a2billing.conf adicione o 
contexto:<BR>[a2billing]</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>exten =&gt; _X.,1,Answer<BR>exten =&gt; 
_X.,n,Wait(1)<BR>exten =&gt; _X.,n,DeadAGI(a2billing.php|1)<BR>exten =&gt; 
_X.,n,Hangup</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>e depois de instalado eu fiz o seguinte com o 
seguinte tutorial do Cassiano Moralles:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp; - Ao instalar o Trixbox ou Asterisk em Home 
o a2billing não vem automaticamente funcionando são necessarios alguns passos 
para a configuração e operação correta dele:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>1) Minha necessidade era de os clientes SIP(x-lite) 
acessarem o servidor autenticando com ramal e senha(método CALLERID) e começa a 
tarifar as <BR>ligações apenas para controle interno de gastos e para limitar o 
uso por créditos para os funcionários,&nbsp; tudo transparente para o usuário 
sem <BR>necessidade de digitar o nro PIN do a2billing ( PIN = 
ACCOUNTCODE).</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>2) Entrar em <A 
href="http://192.168.X.X/a2billing/">http://192.168.X.X/a2billing/</A> (usuário: 
root ; senha: myroot)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>3) Modificar o tronco padrão (default trunk) TRUNK 
-&gt; List Trunk -&gt; Edit, aqui no meu caso como tenh apenas linhas alocadas 
no asterisk e não vou usar outro provedor para distribuir coloquei como na 
figura trunk_01.jpg, ou seja as ligações vão sair por uma linha local conectada 
ao asterisk. Caso vc queira adicionar um provedor sip ou iax modifique conforme 
sua necessidade, e botão CONFIRM DATA click here.</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face=Arial size=2>
<DIV><BR>4) Criar o ratecard clique em RATECARD &gt; Create new RateCard , em 
tariffname coloquei teste, as datas deixei padrão mas vc pode alterar, o trunk 
deixei o default ateh pq no teste só tenho um mesmo, na descrição coloquei o nro 
de telefone dele em DNID deixei all , mas eh interessante vc alterar se 
<BR>precisar, e botão CONFIRM DATA click here.</DIV>
<DIV>&nbsp;</DIV>
<DIV>5) Criar um Rate clique em RATECARD -&gt; Add Rate</DIV>
<DIV>&nbsp;</DIV>
<DIV>campos</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;RATECARD teste<BR>&nbsp;DIALPREFIX 3,4,5,6 (todos os telefones q 
iniciarem em 3,4,5,6 serão tarifados conforme esta regra)<BR>&nbsp;DESTINATION 
local<BR>&nbsp;BUYING RATE 0.2<BR>BUYRATE INIT BLOCK 30<BR>RATEINITIAL 
0.15<BR>MIN DURATION 60<BR>BILLING BLOCK 6<BR>Marcar ratio YES em todos os dias 
da semana<BR>TRUNK default</DIV>
<DIV>&nbsp;</DIV>
<DIV>, e botão CONFIRM DATA click here.</DIV>
<DIV>&nbsp;</DIV>
<DIV>6) Criar um grupo de tarifação para associar os rates, RATECARD -&gt; 
Create TariffGroup em TARIFFGROUPNAME: testando e em TARIFFPLAN: colocar o nome 
do RateCard criado antes "teste" botaão ADD, e botão CONFIRM DATA click 
here.</DIV>
<DIV>&nbsp;</DIV>
<DIV>7)Criar um cliente CUSTOMERS -&gt; Create customer</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WEBUI PASSWORD&nbsp;&nbsp;&nbsp; 
123456<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CREDIT&nbsp; 
10<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TARIFFGROUP&nbsp; testando</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;CARD ALIAS 2000<BR>ACTIVATED YES</DIV>
<DIV>&nbsp;</DIV>
<DIV>8) Clique no botão SIP para o campo sip ficar YES</DIV>
<DIV>&nbsp;</DIV>
<DIV>9)Clique em "GENERATE ADDITIONAL_A2BILLING_SIP.CONF"</DIV>
<DIV>&nbsp;</DIV>
<DIV>10) Clique em "Click here to reload Asterisk Server"</DIV>
<DIV>&nbsp;</DIV>
<DIV>11) Entre em CUSTOMERS -&gt; List Customer, Clique em Edit ao lado do 
cartão,modifique os seguintes campos WEBUI PASSWORD coloquei 123456, CARD ALIAS 
coloquei 2000, CALLERID coloquei 2000 (número do ramal que ira usar o 
cartão)</DIV>
<DIV>&nbsp;</DIV>
<DIV>12) Para saber quantos créditos o usuário tem acesse Customer login:<BR><A 
href="http://192.168.X.X/a2customer">http://192.168.X.X/a2customer</A><BR>Usuário: 
Número do cartão e senha: WEBUI PASSWORD (em CUSTOMERS &gt; List customers &gt; 
clique em edit na esquerda do número do cartão desejado cartão)</DIV>
<DIV>&nbsp;</DIV>
<DIV>11 )&nbsp; Clique em CUSTOMERS &gt; List SIP-FRIEND &gt; EDIT e altere o 
CALLERID, USERNAME para 2000 e apague ACCOUINTCODE e em SECRET coloque 123456 = 
WEBUI PASSWORD em context tem que estar o contexto callingcard que vamos colocar 
no extensions.conf.</DIV>
<DIV>&nbsp;</DIV>
<DIV>12) Para atender as minhas necessidades de tarifar transparente alterei as 
seguintes configs de /etc/asterisk/a2billing/ dentro do contexto [agi-conf1] 
:</DIV>
<DIV>&nbsp;</DIV>
<DIV>[agi-conf1]</DIV>
<DIV>&nbsp;</DIV>
<DIV>; if YES it will catch the DNID and try to dial it out directly without 
asking for the phonenumber to call<BR>; value : YES, NO</DIV>
<DIV>&nbsp;</DIV>
<DIV>use_dnid=YES</DIV>
<DIV>&nbsp;</DIV>
<DIV>; Play the balance to the user after the authentication (values : yes - 
no)<BR>say_balance_after_auth=NO</DIV>
<DIV>&nbsp;</DIV>
<DIV>; Play the balance to the user after the call (values : yes - 
no)<BR>say_balance_after_call=NO</DIV>
<DIV>&nbsp;</DIV>
<DIV>; Play the time the user can call (values : yes - 
no)<BR>say_timetocall=NO</DIV>
<DIV>&nbsp;</DIV>
<DIV>; enable the callerid authentication<BR>; if this option is active the CC 
system will check the CID of caller<BR>;cid_enable=NO<BR>cid_enable=YES</DIV>
<DIV>&nbsp;</DIV>
<DIV>13) Inseri o contexto callingcard dentro de 
/etc/asterisk/extensions.conf</DIV>
<DIV>&nbsp;</DIV>
<DIV>[callingcard]<BR>;allow phones to access trunks<BR>include =&gt; 
outbound-allroutes<BR>exten =&gt; _X.,1,Answer<BR>exten =&gt; 
_X.,2,Wait,2<BR>exten =&gt; _X.,3,DeadAGI,a2billing.php<BR>exten =&gt; 
_X.,4,Wait,2<BR>exten =&gt; _X.,5,Hangup</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>14) Verificar se em sip.conf&nbsp; existe a linhas abaixo:</DIV>
<DIV>&nbsp;</DIV>
<DIV>#include additional_a2billing_sip.conf</DIV>
<DIV>&nbsp;</DIV>
<DIV>15) Configure o x-lite :</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; Menu &gt; ajuste do sistema &gt; Sip Proxy &gt; Default 
:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - enable : 
YES<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Username: 
2000<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Authentication user: 
2000<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Password: 
123456<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Domain/real: 
192.168.X.X<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Sip Proxy:&nbsp; 
192.168.X.X<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Out Bound Proxy: 
192.168.X.X</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>16) Abra o shell no asterisk como root;</DIV>
<DIV>&nbsp;</DIV>
<DIV>digite:</DIV>
<DIV>&nbsp;</DIV>
<DIV>[root em asterisk1 ~]# asterisk -r</DIV>
<DIV>&nbsp;</DIV>
<DIV>para conecar no shell do asterisk.</DIV>
<DIV>&nbsp;</DIV>
<DIV>digite para setar na tela os logs detalhados das ligações:</DIV>
<DIV>&nbsp;</DIV>
<DIV>asterisk1*CLI&gt; debug level 3 logs</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>LOGS:</DIV>
<DIV>&nbsp;</DIV>
<DIV>-- Executing Answer("SIP/2000-1143", "") in new stack<BR>&nbsp;&nbsp;&nbsp; 
-- Executing Wait("SIP/2000-1143", "2") in new stack<BR>&nbsp;&nbsp;&nbsp; -- 
Executing DeadAGI("SIP/2000-1143", "a2billing.php") in new 
stack<BR>&nbsp;&nbsp;&nbsp; -- Launched AGI Script 
/var/lib/asterisk/agi-bin/a2billing.php<BR>&nbsp; a2billing.php: IDCONFIG : 
1<BR>&nbsp; a2billing.php:<BR>&nbsp;&nbsp;&nbsp; -- AGI Script Executing 
Application: (SetLanguage) Options: (en)<BR>&nbsp;&nbsp;&nbsp; -- AGI Script 
Executing Application: (Dial) Options: 
<BR>(ZAP/g0/99XXXXXX|30|HL(19818000:61000:30000))<BR>&nbsp;&nbsp;&nbsp; -- Limit 
Data for this call:<BR>&nbsp;&nbsp;&nbsp; -- - timelimit&nbsp;&nbsp;&nbsp;&nbsp; 
= 19818000<BR>&nbsp;&nbsp;&nbsp; -- - play_warning&nbsp; = 
61000<BR>&nbsp;&nbsp;&nbsp; -- - play_to_caller= yes<BR>&nbsp;&nbsp;&nbsp; -- - 
play_to_callee= no<BR>&nbsp;&nbsp;&nbsp; -- - warning_freq&nbsp; = 
30000<BR>&nbsp;&nbsp;&nbsp; -- - start_sound&nbsp;&nbsp; = 
UNDEF<BR>&nbsp;&nbsp;&nbsp; -- - warning_sound = timeleft<BR>&nbsp;&nbsp;&nbsp; 
-- - end_sound&nbsp;&nbsp;&nbsp;&nbsp; = UNDEF<BR>&nbsp;&nbsp;&nbsp; -- Called 
g0/99XXXXXX<BR>&nbsp;&nbsp;&nbsp; -- Zap/4-1 answered 
SIP/2000-1143<BR>&nbsp;&nbsp;&nbsp; -- Hungup 'Zap/4-1'</DIV>
<DIV>&nbsp;</DIV>
<DIV>Obviamente o celular acima é o meu e troquei os nros finais por X.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Pelos logs acima ele encaminhou certo ao a2billing sem precisar de PIN ou 
informar o nro para o qual queria ligar e tarifou na base.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Espero ter te ajudado ok.</DIV>
<DIV>Abs.</DIV>
<DIV>Rodrigo</FONT></DIV></BODY></HTML>