Require additional login but where to place it

Hi, I am attempting to place additional log in into the extensions_custom.conf to capture the number of calls going on when an outbound call is placed.

I have an issue with my telco and am trying to produce more evidence to hopefully prove them wrong.

I have created the following:

exten => _X.,n,Set(Number Of Active Calls=${SHELL(/usr/sbin/asterisk -rx ‘core show channels’ | grep ‘active call’)})

Can anyone suggest the best place to add this too. I have tried adding this to from_internal-xfer it worked however it caused my call recording to stop working.

Has anyone done this before and have any advice on how to do this with out effecting any other services, or can see where I am going wrong, unfortunately I am really stuck.

I am running the following setup not from a distribution.
FreePBX: 2.11.0
Asterisk: 11.8.1
Dahdi: 2.9.0
Centos: 6.5

current - extensions_custom.conf
;[from-internal-xfer]
;include => from-internal-custom
;include => from-internal-additional ; auto-generated
;exten => s,1,Macro(hangupcall)
;exten => h,1,Macro(hangupcall)
;exten => _X.,n,Set(Number Of Active Calls=${SHELL(/usr/sbin/asterisk -rx ‘core show channels’ | grep ‘active call’)})

My extensions.conf currently looks like this http://pastebin.com/Kjghu7AE

My extensions_additional.conf looks like this http://pastebin.com/JgAJEtZJ

The context “macro-dialout-trunk-predial-hook” exists for users to execute custom code on all outbound calls. Use like this with the ‘s’ extension:

[macro-dialout-trunk-predial-hook] 
exten => s,1,Set(Number_Of_Active_Calls=${SHELL(/usr/sbin/asterisk -rx 'core show channels' | grep 'active call')})
exten => s,n,Set(CDR(userfield)=${Number_Of_Active_Calls})

You probably don’t want spaces in the new variable name. The second line above will record the result in the CDR ‘userfield’, which you may want to do if it isn’t already in use for some other reason.

passing though
t…

#!/usr/bin/env php
<?php
if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
      include_once('/etc/asterisk/freepbx.conf');
}
require_once "/var/lib/asterisk/agi-bin/phpagi.php";
if($astman->connected()) {
    $out = $astman->Command('core show channels');
    preg_match("/([0-9]+)\s+active calls/", $out['data'], $matches);
    $active = $matches[1];
} else {
    echo "not asterisk manager connection";
}
$agi = new AGI();
$agi->set_variable('Number_Of_Active_Calls', $active);
return 0;
[macro-dialout-trunk-predial-hook] 
exten => s,1,AGI(callcount.php)
exten => s,n,Set(CDR(userfield)=${Number_Of_Active_Calls})

Note this should be considered psuedo code as it is untested and un-proven. It should be used only as a reference and not as a drop in solution.

Both look promising I will give them a go out of hours tonight and let you know how I get on. Thanks for your thoughts.

Thanks I went back to the telco and got a result based on the log in produced.

Thanks again for your help.