[AsteriskBrasil] Variavel AGI

Listas - Anderson Morhy listas em morhy.com
Quarta Maio 16 13:09:58 BRT 2012


Irei procurar ser detalhado, e irei colocar alguns comentários iniciando 
com ==> #
Estou usando Elastix 2.2

Bom, o que estou fazendo e o seguinte

# # Neste momento eu "pego" a informação de quem está ligando e qual DDR 
e insiro em um DB

exten => 4641,1,Set(__FROM_DID=${EXTEN})
exten => 4641,n,MYSQL(Connect connid host userdb senhadb banco)
exten => 4641,n,MYSQL(Query resultid ${connid} INSERT INTO teste SET 
origem = ${CALLERID(num)}, data = NOW(), tronco = ${EXTEN})
exten => 4641,n,MYSQL(Fetch fetchid ${resultid} AGIScript)
exten => 4641,n,MYSQL(Clear ${resultid})
exten => 4641,n,MYSQL(Disconnect ${connid})
exten => 4641,n,Gosub(app-blacklist-check,s,1)
exten => 4641,n,ExecIf($[ "${CALLERID(name)}" = "" ] 
?Set(CALLERID(name)=${CALLERID(num)}))
exten => 4641,n,Set(__CALLINGPRES_SV=${CALLERPRES()})
exten => 4641,n,Set(CALLERPRES()=allowed_not_screened)
exten => 4641,n(dest-ext),Goto(ext-queues,5002,1)


##
## Aqui na primeira linha, observamos que o sistema Recebe o número 
originário ( 8488729215 ) e o DDR ( 4641

[May 16 13:01:43] VERBOSE[2977] sig_pri.c:     -- Accepting call from 
'8488729215' to '4641' on channel 0/1, span 1

##
## Aqui começa a execução do AGI

[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[4641 em from-pstn:1] Set("DAHDI/i1/-2539", "__FROM_DID=4641") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[4641 em from-pstn:2] MYSQL("DAHDI/i1/-2539", "Connect connid host userdb 
senhadb banco") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[4641 em from-pstn:3] MYSQL("DAHDI/i1/-2539", "Query resultid 1 INSERT INTO 
teste SET origem = "" <>, data = NOW(), tronco = 4641") in new stack

##Este erro aparece por que o campo origem = "" <> na Query SQL está 
vazio, já testei com outras variaveis e a sintaxe está correta.
##
[May 16 13:01:43] WARNING[21078] app_mysql.c: aMYSQL_query: mysql_query 
failed. Error: You have an error in your SQL syntax; check the manual 
that corresponds to your MySQL server version for the right syntax to 
use near ' data = NOW(), tronco = 4641' at line 1

## Continua a Execução

[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[4641 em from-pstn:4] MYSQL("DAHDI/i1/-2539", "Fetch fetchid  AGIScript") 
in new stack
[May 16 13:01:43] WARNING[21078] app_mysql.c: aMYSQL_fetch: missing some 
arguments
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[4641 em from-pstn:5] MYSQL("DAHDI/i1/-2539", "Clear ") in new stack
[May 16 13:01:43] WARNING[21078] app_mysql.c: Identifier 0, 
identifier_type 2 not found in identifier list
[May 16 13:01:43] WARNING[21078] app_mysql.c: Invalid result identifier 
0 passed in aMYSQL_clear
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[4641 em from-pstn:6] MYSQL("DAHDI/i1/-2539", "Disconnect 1") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[4641 em from-pstn:7] Gosub("DAHDI/i1/-2539", "app-blacklist-check,s,1") in 
new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em app-blacklist-check:1] GotoIf("DAHDI/i1/-2539", "0?blacklisted") in 
new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em app-blacklist-check:2] Set("DAHDI/i1/-2539", "CALLED_BLACKLIST=1") in 
new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em app-blacklist-check:3] Return("DAHDI/i1/-2539", "") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[4641 em from-pstn:8] ExecIf("DAHDI/i1/-2539", "1 ?Set(CALLERID(name)=)") 
in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[4641 em from-pstn:9] Set("DAHDI/i1/-2539", 
"__CALLINGPRES_SV=allowed_not_screened") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[4641 em from-pstn:10] Set("DAHDI/i1/-2539", 
"CALLERPRES()=allowed_not_screened") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[4641 em from-pstn:11] Goto("DAHDI/i1/-2539", "ext-queues,5002,1") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Goto (ext-queues,5002,1)
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[5002 em ext-queues:1] Macro("DAHDI/i1/-2539", "user-callerid,") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em macro-user-callerid:1] Set("DAHDI/i1/-2539", "AMPUSER=") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em macro-user-callerid:2] GotoIf("DAHDI/i1/-2539", "0?report") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em macro-user-callerid:3] ExecIf("DAHDI/i1/-2539", 
"1?Set(REALCALLERIDNUM=)") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em macro-user-callerid:4] Set("DAHDI/i1/-2539", "AMPUSER=") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em macro-user-callerid:5] Set("DAHDI/i1/-2539", "AMPUSERCIDNAME=") in 
new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em macro-user-callerid:6] GotoIf("DAHDI/i1/-2539", "1?report") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Goto 
(macro-user-callerid,s,10)
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em macro-user-callerid:10] GotoIf("DAHDI/i1/-2539", "0?continue") in new 
stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em macro-user-callerid:11] Set("DAHDI/i1/-2539", "__TTL=64") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em macro-user-callerid:12] GotoIf("DAHDI/i1/-2539", "1?continue") in new 
stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Goto 
(macro-user-callerid,s,19)

##
## Observei que neste ponto NEM AQUI onde não foi mexido o nº é identificado

[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em macro-user-callerid:19] Set("DAHDI/i1/-2539", "CALLERID(number)=") in 
new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em macro-user-callerid:20] Set("DAHDI/i1/-2539", "CALLERID(name)=") in 
new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[s em macro-user-callerid:21] NoOp("DAHDI/i1/-2539", "Using CallerID "" 
<>") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[5002 em ext-queues:2] Answer("DAHDI/i1/-2539", "") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[5002 em ext-queues:3] Set("DAHDI/i1/-2539", 
"__BLKVM_OVERRIDE=BLKVM/5002/DAHDI/i1/-2539") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[5002 em ext-queues:4] Set("DAHDI/i1/-2539", "__BLKVM_BASE=5002") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[5002 em ext-queues:5] Set("DAHDI/i1/-2539", 
"DB(BLKVM/5002/DAHDI/i1/-2539)=TRUE") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[5002 em ext-queues:6] ExecIf("DAHDI/i1/-2539", 
"1?Set(_DIAL_OPTIONS=trM(auto-blkvm))") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[5002 em ext-queues:7] Set("DAHDI/i1/-2539", "__NODEST=5002") in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[5002 em ext-queues:8] Set("DAHDI/i1/-2539", 
"MONITOR_FILENAME=/var/spool/asterisk/monitor/q5002-20120516-130143-1337184103.91783") 
in new stack
[May 16 13:01:43] VERBOSE[21078] pbx.c:     -- Executing 
[5002 em ext-queues:9] Playback("DAHDI/i1/-2539", "custom/audio-novo") in 
new stack
[May 16 13:01:43] VERBOSE[21078] file.c:     -- <DAHDI/i1/-2539> Playing 
'custom/audio-novo.gsm' (language 'en')



OBS: Não consegui em momento algum visualizar o nº de entrada em nenhum 
lugar, e como se a Placa/canal reconhecesse o nº e isso não fosse 
passado para o Asterisk.


Alguma sugestão? Ou Orientação?

Preciso apenas pegar o nº de entrada o Tronco (DDR) e inserir em um 
Banco de dados no momento da entrada da ligação. Nada além disso

Obrigado a todos


Att

Anderson Morhy


Em 16-05-2012 12:13, Leandro Alves escreveu:
> Pq não manda a parte do seu codigo AGI, pra ficar melhor pra todos?
>
> Nas varáveis globais do seu canal (vc enviou apenas as variáveis CDR), 
> o seu celular é exibido?
>
> Em 16 de maio de 2012 12:05, Mike Tesliuk <mike em tesliuk.com 
> <mailto:mike em tesliuk.com>> escreveu:
>
>     De acordo com o log abaixo é callerid(num) e exten
>
>      [May 15 20:34:05] VERBOSE[2977] sig_pri.c:     -- Accepting call from
>     '8494322145 <tel:8494322145>' to '4641' on channel 0/1, span 1
>
>     dentro do agi (no meu caso em perl), eu faria da seguinte forma
>
>
>      $callerid =  $agi->get_variable("CALLERID(num)");
>      $dnid = $agi->get_variable("EXTEN");
>
>     em todo caso, voce pode por no seu extension o seguinte
>
>      exten => 4641,1,NoOp(CALLERID: ${CALLERID(num)})
>
>     e voce deverá ver com a legenda na frente
>
>     se eu estiver falando algo que voce ja saiba peço deculpas mas como
>     re-assinei a lista agora não peguei o contexto todo.
>
>
>
>     _______________________________________________
>     KHOMP Inovação: External Board Series
>     Módulos de 1/2 rack e 1U para todas as interfaces e soluções
>     Asterisk e FreeSWITCH.
>     Tenha a External Series Experience na sua aplicação. Visite
>     www.khomp.com <http://www.khomp.com>
>     _______________________________________________
>     DIGIVOICE  Fabricante de Placas de Voz e Channel Bank
>     20 anos de experiência com E1(R2/ISDN), FXS, FXO e GSM
>     Centro Treinamento - Curso de PABX IP -  Asterisk  - Site
>     www.digivoice.com.br <http://www.digivoice.com.br>
>     ________
>     YEALINK: Telefones IP e VídeoPhones IP com o melhor
>     custo/benefício do mercado.
>     email: yealink em commlogik.com.br <mailto:yealink em commlogik.com.br>
>     | www.commlogik.com.br <http://www.commlogik.com.br> | (11)
>     5503-1011 <tel:%2811%29%205503-1011>
>     ______________________________________________
>     Para remover seu email desta lista, basta enviar um email em
>     branco para asteriskbrasil-unsubscribe em listas.asteriskbrasil.org
>     <mailto:asteriskbrasil-unsubscribe em listas.asteriskbrasil.org>
>
>
>
>
> -- 
> Att.,
>
> Leandro Alves
>
>
>
> _______________________________________________
> KHOMP Inovação: External Board Series
> Módulos de 1/2 rack e 1U para todas as interfaces e soluções Asterisk e FreeSWITCH.
> Tenha a External Series Experience na sua aplicação. Visite www.khomp.com
> _______________________________________________
> DIGIVOICE  Fabricante de Placas de Voz e Channel Bank
> 20 anos de experiência com E1(R2/ISDN), FXS, FXO e GSM
> Centro Treinamento - Curso de PABX IP -  Asterisk  - Site  www.digivoice.com.br
> ________
> YEALINK: Telefones IP e VídeoPhones IP com o melhor custo/benefício do mercado.
> email: yealink em commlogik.com.br | www.commlogik.com.br | (11) 5503-1011
> ______________________________________________
> Para remover seu email desta lista, basta enviar um email em branco para asteriskbrasil-unsubscribe em listas.asteriskbrasil.org
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: http://listas.asteriskbrasil.org/pipermail/asteriskbrasil/attachments/20120516/f8458b26/attachment-0001.htm 


Mais detalhes sobre a lista de discussão AsteriskBrasil