Can anyone see an issue with this?

Hi All.
Currently we have an app. that we send the CDR data too via a serial port. It runs as a service, and reads the Matser.csv file using Perl’s TAIL command.
This all works fine and has for quite some time, BUT the issue is we need an extra cable for the serial data.

So I got to thinking how I could get the data via TCP.
The solution I came up with was, when a hangup happens, run an app. (or PHP script in this case) that also uses tail to read the master.csv file, thens end the data via TCP.

This so far has worked, but before I get carried away, can anyone see an issue with this approach??

Thanks, Jeremy

if you are going to run it in the hangup macro, why tail the csv file, why not just pull it right out of the channel and send it where ever you need to, you have the CDR data at that time.

Thats true, and a good point…I was thinking that atleast my letting it go t the Master.csv that we will have a backup if data gets lost…but on the other hand, we of course COULD tailer the data to how we want it too…

So I guess you also dont see any issues??

Thanks, JEREMY

it will go to the Master.csv file either way if you have it configured to do so. Just not point in pulling it out of the file when you can get it from the channel.

Thanks Philippe.

I Will do some playing around and see what happens. Its looking pretty good so far from the testing I have done.


Hi again Philippe. I have it all working now. I did have a few issues getting the data to output correctly, but that was because I develop in to many prog. languages and just plan get confused some times :slight_smile:

One question tho, do you think I would be able to pass the CDR() array to a PHP script?
What I am thinking is, if I can pass the CDR array thru to a PHP script…or whatever script language…that I could format the data however I like rather than doing it in the .conf file.


that is what I was implying. Just call a PHP AGI script, you have access to the whole CDR data set and can do what you want with it.

well I did wonder if thats what you meant.
I took a look around, but didnt see anything to do with CDR in the AGI.
I saw MOST of the things like AGI->CallerID anf things like that.
Are you indicating I should have access to AGI->CDR(dst) as well? OR would I get agi->getvariable ?


a good number of the CDR variables are automatically passed into the AGI script and for those that are not, you can just pull them out as well. Take a look at something like dialparties.agi that pulls out various variables. The only difference, you will be pulling something like “CDR(disposition)” instead of an ordinary variable.

just got your message, and took a look at dialparties.

now I am just a little confussed :slight_smile:

so I WOULD uses AGI->get_variable[‘disposition’] instead of CDR(disposition) as I woudl in the .conf file …is this what you were meaning? (or rather the name of the variable that this is loaded into)

Sorry if its asilly question. It was a public holiday here yesterday…and today is SO like a monday …agh :wink:



OH !!! didnt think of THAT senario !! hahaha…told you it feels like a monday :slight_smile: It makes sense now…sigh…

I will let you know how it goes.


Hi again Philippe.
Got it all working just noice on Asterisk 1.4 (I am using Trxbox 2.4) and then went to another machine running Asterisk 1.2.24 (TB 2.3) and, the CDR() variables all return an mpty string. !
This is using PHP and the PHPagi.php (which I think you wrote) and so I tries some Perl that I had that also worked on my machine, and it too returned empty CDR() variables.

Do you happen to know why this would be the case?? I cant see I have done anything wrong anywhere. I just took my code and implemented it.


did you do it in a DeadAGI script? Did you do it after the CDR was reset? Hungup channels can be missing data sometimes. Did you check the variables that automatically get sent to the AGI script?

yes forgot to mention that I figured out all by myself that I needed to use DeadAGI…only because I looked it up once when I wondered what it was for :slight_smile:

Here are the lines from my extensions_custom.conf file :-

exten => s,1,ResetCDR(w)
exten => s,2,NoCDR()
exten => s,3,DeadAGI(dosomething.php)

like I say, works fine on my Asterisk ver 1.4
Oh, one other point I did forget to mention. IF I built up the a string in the extension_custom.conf, i.e.

exten => s,1,ResetCDR(w)
exten => s,2,NoCDR()
exten => s,3, Set(CDRDATA="${CDR(accountcode)},${CDR(src)},${CDR(dst)},${CDR(dcontext)},${CDR(clid)},${CDR(channel)},${CDR(dstchannel)},${CDR(lastapp)},${CDR(lastdata)},${CDR(start)},${CDR(answer)},${CDR(end)},${CDR(duration)},${CDR(billsec)},${CDR(disposition)},${CDR(amaflags)}")
exten => s,4, System(php dosomthingelse.php “${CDRDATA}”)
(syntax might be slightly wrong…was doing this from memory)

This DID apparently work. Of course my PHP script was looking at the argv[1] item to get what was passed in in CDRDATA.


The ResetCDR is going to reset all the relevant values (I think). You need to write out your values prior to resetting it.

Well…I must admit. when I embarked on this “journey” I DID wonder about this, but since it always worked, I just figured it was ok…but clearly not. But thats ok, by adding the DeadAGI to the first item, it all works on both versions…YAY.

Thanks again. Hopefully this should be the end of it…agh… :slight_smile: