Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

[asterisk-users] AGI - calling functions, CHANNEL STATUS bro


 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> Asterisk Users
View previous topic :: View next topic  
Author Message
kevin at kdegraaf.net
Guest





PostPosted: Tue Mar 11, 2008 6:19 pm    Post subject: [asterisk-users] AGI - calling functions, CHANNEL STATUS bro Reply with quote

Greetings,

I am writing an AGI script that needs to check on the idle/busy status
of a number of SIP peers (mostly SPA9xx phones, with a few Polycoms and
Snoms thrown in for fun).

Is it possible to call Asterisk functions (e.g. SIPPEER) from AGI
scripts? Based on my Googling, I would guess in the negative. I have
tried various permutations of Set() and Eval() without success.

I have also tried to use the "CHANNEL STATUS" AGI command, but that
doesn't seem to work, as indicated by these results:

exten => 610,1,NoOp()
exten => 610,n,Set(CC_200=${SIPPEER(200:curcalls)})
exten => 610,n,Set(CC_221=${SIPPEER(221:curcalls)})
exten => 610,n,Set(CC_231=${SIPPEER(231:curcalls)})
exten => 610,n,AGI(test.agi)

$cc[0] = $AGI->get_variable('CC_200');
$cc[1] = $AGI->get_variable('CC_221');
$cc[2] = $AGI->get_variable('CC_231');
$AGI->verbose("Test using Set(): $cc[0] $cc[1] $cc[2]");
$AGI->verbose("Status of 200: " . $AGI->channel_status('SIP/200'));
$AGI->verbose("Status of 221: " . $AGI->channel_status('SIP/221'));
$AGI->verbose("Status of 231: " . $AGI->channel_status('SIP/231'));

test.agi: Test using Set(): 0 1 0 ; Exactly as expected
test.agi: Status of 200: -1
test.agi: Status of 221: -1
test.agi: Status of 231: -1

Any advice?

--
Kevin DeGraaf
Back to top
matt at venturevoip.com
Guest





PostPosted: Tue Mar 11, 2008 8:04 pm    Post subject: [asterisk-users] AGI - calling functions, CHANNEL STATUS bro Reply with quote

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kevin DeGraaf wrote:
Quote:
$AGI->verbose("Test using Set(): $cc[0] $cc[1] $cc[2]");
$AGI->verbose("Status of 200: " . $AGI->channel_status('SIP/200'));
$AGI->verbose("Status of 221: " . $AGI->channel_status('SIP/221'));
$AGI->verbose("Status of 231: " . $AGI->channel_status('SIP/231'));

I may be off base here as I haven't used the channel status via AGI, but
SIP/200 seems like an account to me rather than a channel.

- --
Kind Regards,

Matt Riddell
Director
_______________________________________________

http://www.venturevoip.com (Great new VoIP end to end solution)
http://www.venturevoip.com/news.php (Daily Asterisk News - html)
http://www.venturevoip.com/newrssfeed.php (Daily Asterisk News - rss)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH1ywwDQNt8rg0Kp4RAkYcAJwKBYJOUVgz0ii5Ky2DZtwFWvCtHwCfX/+r
1HFlsDnMHVHKfELEGyZgk/s=
=21xo
-----END PGP SIGNATURE-----
Back to top
asterisk.org at sedwar...
Guest





PostPosted: Wed Mar 12, 2008 11:53 am    Post subject: [asterisk-users] AGI - calling functions, CHANNEL STATUS bro Reply with quote

On Wed, 12 Mar 2008, Kevin DeGraaf wrote:

Quote:
Quote:
I am writing an AGI script that needs to check on the idle/busy status
of a number of SIP peers (mostly SPA9xx phones, with a few Polycoms and
Snoms thrown in for fun).

I ended up grabbing this info from the manager interface, within an AGI
script. A little back-asswards, but it works.

I still would like to know whether it's possible to call Asterisk
functions from within AGI scripts...

The AGI executes as a separate process and does not have full access to
the Asterisk memory or code. Since the only interface between Asterisk and
the AGI is through STDIN and STDOUT (and STDERR), you can only execute
functions defined in the AGI API. For 1.2 this means:

fs> show agi
answer Answer channel
channel status Returns status of the connected channel
database del Removes database key/value
database deltree Removes database keytree/value
database get Gets database value
database put Adds/updates database value
exec Executes a given Application
get data Prompts for DTMF on a channel
get full variable Evaluates a channel expression
get option Stream file, prompt for DTMF, with timeout
get variable Gets a channel variable
hangup Hangup the current channel
noop Does nothing
receive char Receives one character from channels supporting it
receive text Receives text from channels supporting it
record file Records to a given file
say alpha Says a given character string
say digits Says a given digit string
say number Says a given number
say phonetic Says a given character string with phonetics
say date Says a given date
say time Says a given time
say datetime Says a given time as specfied by the format given
send image Sends images to channels supporting it
send text Sends text to channels supporting it
set autohangup Autohangup channel in some time
set callerid Sets callerid for the current channel
set context Sets channel context
set extension Changes channel extension
set music Enable/Disable Music on hold generator
set priority Set channel dialplan priority
set variable Sets a channel variable
stream file Sends audio file on channel
control stream file Sends audio file on channel and allows the listner to control the stream
tdd mode Toggles TDD mode (for the deaf)
verbose Logs a message to the asterisk verbose log
wait for digit Waits for a digit to be pressed

For 1.4 or 1.6, use the obtuse replacement for "show agi" to see your
options.

Thanks in advance,
------------------------------------------------------------------------
Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
Back to top
kevin at kdegraaf.net
Guest





PostPosted: Wed Mar 12, 2008 12:27 pm    Post subject: [asterisk-users] AGI - calling functions, CHANNEL STATUS bro Reply with quote

Quote:
I am writing an AGI script that needs to check on the idle/busy status
of a number of SIP peers (mostly SPA9xx phones, with a few Polycoms and
Snoms thrown in for fun).

I ended up grabbing this info from the manager interface, within an AGI
script. A little back-asswards, but it works.

I still would like to know whether it's possible to call Asterisk
functions from within AGI scripts...

--
Kevin DeGraaf
Back to top
davevg at gmail.com
Guest





PostPosted: Wed Mar 12, 2008 1:05 pm    Post subject: [asterisk-users] AGI - calling functions, CHANNEL STATUS bro Reply with quote

Kevin DeGraaf wrote:
Quote:
Quote:
I am writing an AGI script that needs to check on the idle/busy status
of a number of SIP peers (mostly SPA9xx phones, with a few Polycoms and
Snoms thrown in for fun).


I ended up grabbing this info from the manager interface, within an AGI
script. A little back-asswards, but it works.

I still would like to know whether it's possible to call Asterisk
functions from within AGI scripts...


This worked for me on * 1.6 where 1223 is the sip peer I wanted to get
status from.
#!/usr/bin/perl
use strict;
use Asterisk::AGI;
my $AGI = new Asterisk::AGI;
my %input = $AGI->ReadParse();
my $peer = $AGI->get_variable("SIPPEER(1223,status)");
$AGI->verbose("We Received $peer",3);
exit;
Back to top
kevin at kdegraaf.net
Guest





PostPosted: Wed Mar 12, 2008 1:39 pm    Post subject: [asterisk-users] AGI - calling functions, CHANNEL STATUS bro Reply with quote

Quote:
This worked for me on * 1.6 where 1223 is the sip peer I wanted to get
status from.

Quote:
use Asterisk::AGI;
my $AGI = new Asterisk::AGI;
my $peer = $AGI->get_variable("SIPPEER(1223,status)");

It didn't work (for me) on 1.4.18. An empty string was returned, even
though I gave a it a valid peer number. Oh, well. Smile

Thanks.

--
Kevin DeGraaf
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> Asterisk Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services