PDA

Voir la version complète : comment récupérer les variables d'asterisk



ylan
07/10/2010, 15h31
Bonjour la communauté,

Je voudrais juste savoir comment récupère-t-on toutes les variables asterisk pendant l'appel. En effet quand j'active le agi set debug on, je vois juste quelque variable arrivée mais sans plus.

Je voudrais par exemple récupérer ANSWERDTIME, DURATION,....

Merci pour vos lumières

ffossard
07/10/2010, 16h13
Peux-tu préciser l'endroit où tu veux les récupérer: dans le dialplan, dans la cli, dans un script agi ... ?

ylan
07/10/2010, 18h51
Bonjour ffossard et merci pour ta réponse,

En faite je voudrais les récupérer dans mon agi mais je ne connais pas la syntaxe exacte. Voici ce que je récupère quand j'éxécute mon agi de test:


== Using SIP RTP CoS mark 5
-- Executing [s@phone:1] Answer("SIP/ippi-00000000", "") in new stack
-- Executing [s@phone:2] AGI("SIP/ippi-00000000", "test.agi") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/test.agi
<SIP/ippi-00000000>AGI Tx >> agi_request: test.agi
<SIP/ippi-00000000>AGI Tx >> agi_channel: SIP/ippi-00000000
<SIP/ippi-00000000>AGI Tx >> agi_language: en
<SIP/ippi-00000000>AGI Tx >> agi_type: SIP
<SIP/ippi-00000000>AGI Tx >> agi_uniqueid: 1286462854.0
<SIP/ippi-00000000>AGI Tx >> agi_version: 1.6.2.12
<SIP/ippi-00000000>AGI Tx >> agi_callerid: Unknown
<SIP/ippi-00000000>AGI Tx >> agi_calleridname: Unknown
<SIP/ippi-00000000>AGI Tx >> agi_callingpres: 0
<SIP/ippi-00000000>AGI Tx >> agi_callingani2: 0
<SIP/ippi-00000000>AGI Tx >> agi_callington: 0
<SIP/ippi-00000000>AGI Tx >> agi_callingtns: 0
<SIP/ippi-00000000>AGI Tx >> agi_dnid: unknown
<SIP/ippi-00000000>AGI Tx >> agi_rdnis: unknown
<SIP/ippi-00000000>AGI Tx >> agi_context: phone
<SIP/ippi-00000000>AGI Tx >> agi_extension: s
<SIP/ippi-00000000>AGI Tx >> agi_priority: 2
<SIP/ippi-00000000>AGI Tx >> agi_enhanced: 0.0
<SIP/ippi-00000000>AGI Tx >> agi_accountcode:
<SIP/ippi-00000000>AGI Tx >> agi_threadid: -1212658800
<SIP/ippi-00000000>AGI Tx >>
<SIP/ippi-00000000>AGI Rx << STREAM FILE dir-welcome ""
-- Playing 'dir-welcome' (escape_digits=) (sample_offset 0)
<SIP/ippi-00000000>AGI Tx >> 200 result=0 endpos=13028
<SIP/ippi-00000000>AGI Rx << GET DATA dir-pls-enter 10000 10
-- <SIP/ippi-00000000> Playing 'dir-pls-enter.ulaw' (language 'en')
<SIP/ippi-00000000>AGI Tx >> 200 result=123456789
<SIP/ippi-00000000>AGI Rx << GET DATA conf-getpin 10000 4
-- <SIP/ippi-00000000> Playing 'conf-getpin.ulaw' (language 'en')
<SIP/ippi-00000000>AGI Tx >> 200 result=1234
<SIP/ippi-00000000>AGI Rx << GET DATA conf-getconfno 10000 14
-- <SIP/ippi-00000000> Playing 'conf-getconfno.ulaw' (language 'en')
<SIP/ippi-00000000>AGI Tx >> 200 result=1234
-- <SIP/ippi-00000000>AGI Script test.agi completed, returning 0
-- Executing [s@phone:3] Hangup("SIP/ippi-00000000", "") in new stack
== Spawn extension (phone, s, 3) exited non-zero on 'SIP/ippi-00000000'

Comdif
07/10/2010, 19h13
J'ai fait un post sur les logs via agi
il y a quelque temps pour exemple de syntaxe
http://www.asterisk-france.org/showthread.php/55-CDRS-nickel

ylan
07/10/2010, 23h42
Si j'ai bien compris en utilisant $AGI->get_variable je peux avoir tout ce que je veux d'asterisk?

asterisk*CLI> agi show commands topic get variable

-= Info about agi 'get variable' =-

[Syntax]
get variable <variablename>

[Description]
Returns '0' if <variablename> is not set. Returns '1' if <variablename> is
set and returns the variable in parentheses.
Example return code: 200 result=1 (testvariable)

[Synopsis]
Gets a channel variable.

[Runs Dead]
Yes

[See Also]
Not available


Que veut dire le "Runs Dead"

Merci

ffossard
08/10/2010, 00h50
Ca signifie que c'est utilisable dans des scripts agi lancés par la commande DeadAGI (voir doc: http://www.voip-info.org/wiki/index.php?page=Asterisk+cmd+DeadAGI )

ylan
09/10/2010, 02h10
merci