[asterisk-users] .call file and logging
Vieri
rentorbuy at yahoo.com
Tue Aug 7 06:56:36 CDT 2007
I am writing a cron script to check if certain
extensions are online and if they aren't then Asterisk
creates a couple of .call files to notify another set
of extensions or external numbers.
It works fine except for logging information.
What I'm doing in the script is setting a "fake"
caller ID (as it's generated by Asterisk, not by a
user) and calling out real users.
So the user's extension is specified in the "Channel:
" field. When the user picks the phone up, asterisk
drops into the custom_NOTIFY context which plays a
menu.
My problem is that when I check the logs in /var/log
or in the MySQL CDR database, I can't always
demonstrate that Asterisk actually called a specific
number (in the code below, the number I need to log is
$alerts).
If I use a SIP extension in the Channel field then the
logging works for me because I can see that the
SIP/EXTEN was used (see below).
However, if I use a Zap extension then only the Zap
channel number is logged but the extension's number
isn't (in the example below, 7022 does not appear in
the logs).
Any suggestions as to how I can solve this?
Maybe by changing the "Extension:" line or setting
variables. A quick simple example would be
appreciated.
Thanks,
Vieri
Code snippet:
$ftime = time();
$fname = "/tmp/asterisk_".$ftime.".call";
$fname_call =
"/var/spool/asterisk/outgoing/asterisk_".$ftime.".call";
$fd = fopen($fname, 'w');
fwrite($fd, "Channel: ".$alerts."\n");
fwrite($fd, "Callerid: IT <7021>\n");
fwrite($fd, "Set: FHMNUM=".$FAILURES."\n");
fwrite($fd, "MaxRetries: 2\n");
fwrite($fd, "RetryTime: 20\n");
fwrite($fd, "WaitTime: 40\n");
fwrite($fd, "Context: custom-NOTIFY\n");
fwrite($fd, "Extension: s\n");
fwrite($fd, "Priority: 1\n");
fclose($fd);
chown($fname,"asterisk");
chgrp($fname,"asterisk");
rename($fname,$fname_call);
# cat cdr_custom.conf
;
; Mappings for custom config file
;
[mappings]
Master.csv =>
"${CDR(clid)}","${CDR(src)}","${CDR(dst)}","${CDR(dcontext)}","${CDR(channel)}","${CDR(dstchannel)}","${CDR(lastapp)}","${CDR(lastdata)}","${CDR(start)}","${CDR(answer)}","${CDR(end)}","${CDR(duration)}","${CDR(billsec)}","${CDR(disposition)}","${CDR(amaflags)}","${CDR(accountcode)}","${CDR(uniqueid)}","${CDR(userfield)}"
If $alerts is "Zap/g1/7022" Then:
# tail /var/log/asterisk/cdr-csv/Master.csv
"","7021","s","custom-NOTIFY","""IT""
<7021>","Zap/2-1","","Hangup","","2007-08-07
13:30:19","2007-08-07 13:30:19","2007-08-07
13:30:26",7,7,"ANSWERED","DOCUMENTATION"
If $alerts is "SIP/4053" Then:
# tail /var/log/asterisk/cdr-csv/Master.csv
"","7021","s","custom-NOTIFY","""IT""
<7021>","SIP/4053-0829b6a0","","Hangup","","2007-08-07
12:58:02","2007-08-07 12:58:02","2007-08-07
12:58:15",13,13,"ANSWERED","DOCUMENTATION"
(This is an Asterisk/FreePBX system)
____________________________________________________________________________________
Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/
More information about the asterisk-users
mailing list