* You are viewing Posts Tagged ‘source’

“Problems” with System() application

The problem was the directory which i was writing the logs, i put the
log file in /var/log/asterisk and it worked.

Thanks.

On Wed, 2011-07-20 at 13:03 -0500, Jorge Gutiérrez wrote:

>
> Are you able to execute: log.sh through the asterisk user?
>
>
> On Wed, 20 Jul 2011 14:53:53 -0300, Antonio Modesto
> wrote:
> > Good afternoon,
> >
> > I am trying to use the System() application but it is always
> > returning APPERROR in the ${SYSTEMSTATUS} variable, I am trying to run
> > this command:
> >
> > System(/bin/sh /var/spool/asterisk/calllog/log.sh ${FromExt}
> > ${exten});
> >
> > This is the content of the /var/spool/asterisk/calllog/log.sh:
> >
> > #!/bin/sh
> > #
> > #
> >
> > TIME=$(date “+%d-%m-%Y-%HH-%MM”)
> >
> > SOURCE=”$1″
> > DST=”$2″
> >
> > echo “$TIME – $SOURCE – $DST” >> teste.log
> >
> > I tried to insert some info direct into the file using echo but i’ve got
> > the same error.
> >
> > Is there some secret to use this? haha
>
> –
> Jorge Gutiérrez
>
> –
> _____________________________________________________________________
> — Bandwidth and Colocation Provided by http://www.api-digital.com
> New to Asterisk? Join us for a live introductory webinar every Thurs:
> http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-users

“Problems” with System() application

Good afternoon,

I am trying to use the System() application but it is always
returning APPERROR in the ${SYSTEMSTATUS} variable, I am trying to run
this command:

System(/bin/sh /var/spool/asterisk/calllog/log.sh ${FromExt}
${exten});

This is the content of the /var/spool/asterisk/calllog/log.sh:

#!/bin/sh
#
#

TIME=$(date “+%d-%m-%Y-%HH-%MM”)

SOURCE=”$1″
DST=”$2″

echo “$TIME – $SOURCE – $DST” >> teste.log

I tried to insert some info direct into the file using echo but i’ve got
the same error.

Is there some secret to use this? haha

Benchmarking AGI performance in C, PHP, and Perl

This is a very interesting post made by Steve Edwards on the Asterisk Users mailing list. Basically he was demonstrating the difference in speed when working with AGI scripts in different programming languages. It says as follows:

Many times, I’ve made the statement that you can execute hundreds of AGIs written in C in the time it takes to load an interpreter and parse a script written in PHP or Perl.

Recently, a Doubting Thomas asked me to substantiate my claim.

I suspect nobody has made the effort to implement an AGI of any reasonable size and function in multiple languages.

I’m guessing it may not really be all that important and the results would be too task specific to be relevant.

I suspect once an AGI is executing, the choice of source language is unimportant. I’ll go out on a limb and say executing:

select prompt_path from foo where bar;
stream file prompt_path “1234*”
stream file you_entered “”
say digits selected “”

will execute in effectively the same time regardless of source language. Waiting for Asterisk to play a file or for your database to return a row is beyond the scope of your AGI.

It’s what you do between your AGI and database calls that will determine how much your choice of source language will impact the total execution time.

Unless you’re doing a lot of stuff in between these API calls, the only place you can make an impact is getting your code into memory and ready to execute.

I ‘wrote’ 2 different AGIs in C, PHP, and Perl.

The first AGI, ‘null-agi’ reads the AGI environment variables from STDIN and exits. To me, this is the bare minimum a program can do and call itself an AGI. Each AGI was less than 10 lines.

The second AGI, ‘neutered-agi’ is an AGI of ‘production length’ (around 1,600 lines) and supporting access to a MySQL database. The AGI is of ‘production length’ but still exits after reading the AGI environment variables because we are measuring program startup time.

For both AGIs, the C implementation used an AGI library I developed way too many years ago. The PHP implementation used PHPAGI. The Perl implementation used Asterisk::AGI.

The C version of neutered-agi was based on a ‘voicemail-like’ AGI I wrote many years ago that stored the user credentials and messages in MySQL.

The PHP version of neutered-agi was based on dialparties.agi (nicked from PIAF). dialparties.agi is only about 800 lines long, so I ‘doubled it’ by copying and pasting it into the same source file. While dialparties.agi does not use MySQL, MySQL is available in PHP without including additional header or class files.

The Perl version of neutered-agi was based on agi-VDAD_ALL_outbound.agi (nicked from Vicidial).

I ran the tests in 3 different environments:

|- – – – – – – – – -+ – – – -+ – – – -+ – – – – -|
| CPU               | RAM    | CentOS | Asterisk |
| – – – – – – – – – + – – – -+ – – – -+ – – – – -|
| Geode 500MHz      | 256 MB |    4.9 |   1.2.37 |
| Atom D525 1.80GHz | 4 GB   |    5.6 |  1.8.4.1 |
| Xeon 3.40GHz      | 2 GB   |    4.8 |   1.2.40 |
| – – – – – – – – – + – – – -+ – – – -+ – – – – -|

No swapping occurred during the tests.

My dialplan executed each AGI 1,000 times to make the cumulative execution time more measurable. I wrote the dialplan in both ‘inline dialplan’ and an AEL ‘for’ loop. The initial execution times were the same so the test runs were made with the AEL version because it is more manageable. (5 lines versus 1,000 lines.)

Here’s the results for executing each AGI 1,000 times on each host in seconds:

Geode:

| – – – – -+- – – – – + – – – – – – -|
| language | null-agi | neutered-agi |
| – – – – -+ – – – – -+ – – – – – – -|
| C        |        6 |            6 |
| PHP      |      116 |          160 |
| Perl     |       99 |          639 |
| – – – – -+ – – – – -+ – – – – – – -|

Atom:

| – – – – -+ – – – – -+ – – – – – – -|
| language | null-agi | neutered-agi |
| – – – – -+ – – – – -+ – – – – – – -|
| C        |        6 |            6 |
| PHP      |       52 |           65 |
| Perl     |       38 |          197 |
| – – – – -+ – – – – -+ – – – – – – -|

Xeon:

| – – – – -+ – – – – -+ – – – – – – -|
| language | null-agi | neutered-agi |
| – – – – -+ – – – – -+ – – – – – – -|
| C        |        2 |            2 |
| PHP      |       40 |           47 |
| Perl     |       10 |          107 |
| – – – – -+ – – – – -+ – – – – – – -|

Summary:

Geode – Perl / C: 106
Atom – Perl / C: 33
Xeon – Perl / C: 54

The C null-agi AGI was statically linked. I didn’t have all the libraries needed to statically link neutered-agi on these boxes, but the dynamically linked versions of null-agi and neutered-agi took the same time to execute (16 seconds on the Geode) so I’m assuming statically linked versions of null-agi and neutered-agi would also take the same time to execute. It also helps support my original statement :)

I guessing the Perl version of neutered-agi took a big hit from having to load the database code as well as the AGI framework (use DBI; use Asterisk::AGI;) while PHP only had to load the AGI framework (require_once “phpagi.php”;).

I’ll let you decide if the methodology is meaningful to your environment. I don’t consider myself to be a PHP or Perl expert, so if I’ve made some colossal blunder in my methodology, please let me know.

I’m guessing you’d have to resurrect a Soekris net4801 from the way-back-machine to substantiate my orignal claim of ‘hundreds.’ I’ll have to remind myself to say ‘dozens’ from now on.

(I don’t have a ‘thing’ against Soekris — I just bought 2 off Ebay to play with.)


Thanks in advance,
————————————————————————-
Steve Edwards       sedwards [at] sedwards [dot] com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000

Issue 0019268 Patch Asterisk

On 07/08/2011 05:01 PM, Mark Rosedale wrote:

> This is not working the source code of 1.8.4.4. I assume that the patch
> is for a different version. Any ideas about how to apply this patch to
> 1.8.4.4 so that I can avoid using the svn branch?

It’s a 2 line patch. If you look at the source it’s easy to spot why the
patch failed (some code was added). Line 5399 is removed and the
addition comes before line 5417:

http://svnview.digium.com/svn/asterisk/branches/1.8/channels/sig_pri.c?view=markup

Why don’t you try to apply it manually?

Regards,
Patrick

Cant find asterisk src dir for FreePBX full distro

It seems that the full distro package from FreePBX with Asterisk 1.8.1.4
someway hides (deletes?) the source directory for asterisk after
installation.

I cant find the directory under /usr/src/

I am trying to compile and install the conference module “app_konference”
and need to point a variable in Makefile to the src-dir of asterisk.

I think that FreePBX creates a user without root-access (named asterisk) and
installs the asterisk-distro with that user, is this correct? Can that be
the reason for not finding “/usr/src/asterisk” when logged in as root?

Best regards
Tobias

Asterisk 1.6.2.19 RPM

Hi All,

Asterisk 1.6.2.19 was released on the 28th, does anyone know if there a timescale for this reaching the RPM repository? We’re badly affected by a bug in previous versions that has only recently become apparent to us. It’s in a situation where rebuilding from source isn’t too practical so we need to rely on RPMs. Failing that, is there a way I can build an RPM for myself on another box and have the right compile-time options (i.e. matching what would be used for a real RPM)?

Thanks in advance..

Steve