- Mitglied seit
- 14 Dez 2009
- Beiträge
- 108
- Punkte für Reaktionen
- 0
- Punkte
- 0
Hi liebe Asterisk-Gurus
Ich stehe schon wieder einmal vor einem seltsamen Phänomen und weiß mir leider nicht mehr weiterzuhelfen.
Ich habe hier einen Asterisk stehen, der für ISDN konzipiert wurde und soweit auch schön vor sich hin schnurrt.
Momentan sitzt hinter dem Asterisk noch ein Fax-Server auf den ich einfach die MSN durchleite. Dieser soll aber nun ausgemustert werden.
So kam ich auf den Gedanken, den Faxserver sozusagen direkt in den Asterisk zu integrieren mit dem Debian Paket: asterisk-app-fax.
Soweit so gut. Nun hab ich mal die ganze Konfig durchgemacht und auch schon versucht Faxe über ISDN zu empfangen und hier beginnen meine Probleme!
Um mein Problem aufzuzeigen hier mal die confs und logs:
/var/log/asterisk/messages:
Diese Fehlermeldung bringt er mir 20-30x am laufenden Band zur selben Zeit.
/var/log/asterisk/misdn.log:
[EXTERN] = Ankommende Faxnummer
[INTERN] = interne Faxnummer
/usr/share/asterisk/agi-bin/receive_fax:
/etc/asterisk/extensions.ael: (relevanter Teil)
/var/lib/asterisk/scripts/fax2mail.sh:
Fehlt sonst noch was?
Wär euch SEHR verbunden, wenn Ihr mir in dieser Problematik eventuell weiter helfen könntet
Grüße denny
Ich stehe schon wieder einmal vor einem seltsamen Phänomen und weiß mir leider nicht mehr weiterzuhelfen.
Ich habe hier einen Asterisk stehen, der für ISDN konzipiert wurde und soweit auch schön vor sich hin schnurrt.
Momentan sitzt hinter dem Asterisk noch ein Fax-Server auf den ich einfach die MSN durchleite. Dieser soll aber nun ausgemustert werden.
So kam ich auf den Gedanken, den Faxserver sozusagen direkt in den Asterisk zu integrieren mit dem Debian Paket: asterisk-app-fax.
Soweit so gut. Nun hab ich mal die ganze Konfig durchgemacht und auch schon versucht Faxe über ISDN zu empfangen und hier beginnen meine Probleme!
Um mein Problem aufzuzeigen hier mal die confs und logs:
/var/log/asterisk/messages:
Code:
[May 21 10:19:55] ERROR[7248] utils.c: write() returned error: Broken pipe
[May 21 10:19:55] WARNING[7248] res_agi.c: Running DeadAGI on a live channel will cause problems, please use AGI
/var/log/asterisk/misdn.log:
Code:
Fri May 21 10:19:55 2010: P[ 1] I IND :NEW_CHANNEL oad:[EXTERN] dad:[INTERN] pid:8 state:none
Fri May 21 10:19:55 2010: P[ 1] --> channel:1 mode:TE cause:16 ocause:16 rad: cad:
Fri May 21 10:19:55 2010: P[ 1] --> info_dad: onumplan:2 dnumplan:4 rnumplan: cpnnumplan:0
Fri May 21 10:19:55 2010: P[ 1] Chan not existing at the moment bc->l3id:20045 bc:0x81b43bc event:NEW_CHANNEL port:1 channel:1
Fri May 21 10:19:55 2010: P[ 1] NO USERUESRINFO
Fri May 21 10:19:55 2010: P[ 1] --> TRANSPARENT Mode
Fri May 21 10:19:55 2010: P[ 1] I IND :SETUP oad:[EXTERN] dad:[INTERN] pid:8 state:none
Fri May 21 10:19:55 2010: P[ 1] --> channel:1 mode:TE cause:16 ocause:16 rad: cad:
Fri May 21 10:19:55 2010: P[ 1] --> info_dad: onumplan:2 dnumplan:4 rnumplan: cpnnumplan:0
Fri May 21 10:19:55 2010: P[ 1] --> Bearer: 3.1KHz Audio
Fri May 21 10:19:55 2010: P[ 1] --> Codec: Alaw
Fri May 21 10:19:55 2010: P[ 0] --> * NEW CHANNEL dad:[INTERN] oad:[EXTERN]
Fri May 21 10:19:55 2010: P[ 1] read_config: Getting Config
Fri May 21 10:19:55 2010: P[ 1] --> CTON: Unknown
Fri May 21 10:19:55 2010: P[ 1] --> PRES: Allowed (0)
Fri May 21 10:19:55 2010: P[ 1] --> SCREEN: Unscreened (0)
Fri May 21 10:19:55 2010: P[ 1] I SEND:PROCEEDING oad:[EXTERN] dad:[INTERN] pid:8
Fri May 21 10:19:55 2010: P[ 1] --> channel:1 mode:TE cause:16 ocause:16 rad: cad:
Fri May 21 10:19:55 2010: P[ 1] --> info_dad: onumplan:2 dnumplan:4 rnumplan: cpnnumplan:0
Fri May 21 10:19:55 2010: P[ 1] * ANSWER:
Fri May 21 10:19:55 2010: P[ 1] --> empty cad using dad
Fri May 21 10:19:55 2010: P[ 1] I SEND:CONNECT oad:[EXTERN] dad:[INTERN] pid:8
Fri May 21 10:19:55 2010: P[ 1] --> channel:1 mode:TE cause:16 ocause:16 rad: cad:[INTERN]
Fri May 21 10:19:55 2010: P[ 1] --> info_dad: onumplan:2 dnumplan:4 rnumplan: cpnnumplan:0
Fri May 21 10:19:55 2010: P[ 1] --> * IND : -1! (stop indication) pid:8
Fri May 21 10:19:55 2010: P[ 1] * IND : HANGUP pid:8 ctx:isdn-extern dad:[INTERN] oad:0[EXTERN] State:CONNECTED
Fri May 21 10:19:55 2010: P[ 1] --> out_cause:16
Fri May 21 10:19:55 2010: P[ 1] I SEND:DISCONNECT oad:[EXTERN] dad:[INTERN] pid:8
Fri May 21 10:19:55 2010: P[ 1] --> channel:1 mode:TE cause:16 ocause:16 rad: cad:[INTERN]
Fri May 21 10:19:55 2010: P[ 1] --> info_dad: onumplan:2 dnumplan:4 rnumplan: cpnnumplan:0
Fri May 21 10:19:56 2010: P[ 1] I IND :RELEASE oad:[EXTERN] dad:[INTERN] pid:8 state:CLEANING
Fri May 21 10:19:56 2010: P[ 1] --> channel:1 mode:TE cause:16 ocause:16 rad: cad:[INTERN]
Fri May 21 10:19:56 2010: P[ 1] --> info_dad: onumplan:2 dnumplan:4 rnumplan: cpnnumplan:0
Fri May 21 10:19:56 2010: P[ 1] --> No need to queue hangup
Fri May 21 10:19:56 2010: P[ 1] Cannot hangup chan, no ast
Fri May 21 10:19:56 2010: P[ 1] $$$ Cleaning up bc with stid :10010100 pid:8
Fri May 21 10:19:56 2010: P[ 0] handle_bchan: BC not found for prim:f2481 with addr:55010180 dinfo:0
[INTERN] = interne Faxnummer
/usr/share/asterisk/agi-bin/receive_fax:
Code:
#!/usr/bin/perl
#
# asterisk-faxreceive - handles reception of faxes using app_rxfax and
# dispatches the received faxes via email
#
# Copyright (C) 2005 Florian Zumbiehl <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: receive_fax 77 2005-09-05 19:16:10Z florz $
#
use strict;
use Fcntl ':flock';
use File::Sync 'fsync';
use File::Temp qw(tempdir);
use File::Path;
use MIME::Lite;
use Config::Tiny;
use Storable qw(nstore retrieve);
use POSIX qw(setlocale);
use Locale::gettext;
my $fax_counter_dir='/var/lib/asterisk/faxreceive/counters';
my $config_file='/etc/asterisk/faxreceive.conf';
$|=1;
textdomain('asterisk-faxreceive')||die();
my $config=Config::Tiny->read($config_file)||die(Config::Tiny::errstr());
my $email_from;
my $email_to;
my $deadx;
my $deady;
my $dmw;
my $dmh;
my $email_locale;
while(1){
defined($_=<stdin>)||die();
chomp();
length($_)||last;
};
#"Uses LOCALSTATIONID to identify itself to the remote end\n"
#"Sets REMOTESTATIONID to the sender CSID\n"
#" FAXPAGES to the number of pages received\n"
#" FAXBITRATE to the transmition rate\n"
#" FAXRESOLUTION to the resolution\n"
if($ARGV[0] eq 'receive'){
my $recipient=agi_get_var('FAXRECIPIENT');
$recipient eq 'new'&&die();
$recipient eq 'lock'&&die();
my $temp_dir;
my $config_defaults={
'paper_name'=>'',
'margin_vertical'=>0.25,
'margin_horizontal'=>0.25
};
defined(my $recipient_config=$config->{"recipient $recipient"})||die();
for my $c($config_defaults,$config->{_},$recipient_config){
config_get($email_from,'email_from',$c);
config_get($email_to,'email_to',$c);
($dmw,$dmh)=resolve_papername($c->{paper_name})if(defined($c->{paper_name}));
config_get($dmw,'paper_width',$c);
config_get($dmh,'paper_height',$c);
config_get($deadx,'margin_vertical',$c);
config_get($deady,'margin_horizontal',$c);
config_get($temp_dir,'temp_dir',$c);
config_get($email_locale,'locale',$c);
}
my($recv_counter,$fax_counter)=inc_fetch_counters($recipient,'recv');
my $recv_dirname=tempdir("asterisk_faxreceive.$recipient.".sprintf('%05d.%05d',$recv_counter,$fax_counter+1).'.XXXXXX',
$temp_dir ne ''?(DIR=>$temp_dir):(TMPDIR=>1))||die();
{
no strict 'refs';
nstore({
'version'=>1,
map({$_=>eval("\$$_")} (
'recipient',
'email_from',
'email_to',
'dmw',
'dmh',
'deadx',
'deady',
'email_locale'
))
},"$recv_dirname/info")||die();
}
agi_cmd("SET VARIABLE FAXRECVFILE \"$recv_dirname/fax.tiff\"",1);
agi_cmd("EXEC RxFAX \"$recv_dirname/fax.tiff\"",0);
agi_cmd("HANGUP",1);
}elsif($ARGV[0] eq 'deliver'){
my $remotecallerid=agi_get_var('MY_CALLERIDNUM');
my $recv_filename=agi_get_var('FAXRECVFILE');
my $remotestationid=agi_get_var('REMOTESTATIONID');
my $faxpages=agi_get_var('FAXPAGES');
$recv_filename=~s/\.tiff$//||die();
my $recv_dirname=$recv_filename;
$recv_dirname=~m,.*/,||die();
$recv_dirname=$&;
my $recipient;
(my %info_data=%{retrieve("$recv_dirname/info")})||die();
$info_data{version}==1||die();
{
no strict 'refs';
for(
'recipient',
'email_from',
'email_to',
'dmw',
'dmh',
'deadx',
'deady',
'email_locale'
){
my $x=$info_data{$_};
eval("\$$_=\$x");
}
}
system("tiff2ps -2az $recv_filename.tiff > $recv_filename.ps")&&die();
$dmw-=2*$deadx;
$dmh-=2*$deady;
open(my $ps_file,'<',"$recv_filename.ps")||die();
my $count;
while(defined($_=<$ps_file>)){
m/^(\d+\.\d+) (\d+\.\d+) scale$/||next;
my $sw=$1/72*2.54;
my $sh=$2/72*2.54;
my $scale;
if($dmw/$dmh>$sw/$sh){
$scale=$dmh/$sh;
}else{
$scale=$dmw/$sw;
}
my $dw=$sw*$scale;
my $dh=$sh*$scale;
my $xoff=($dmw-$dw)/2+$deadx;
my $yoff=$dmh-$dh+$deady;
$count++;
system("psselect -p$count $recv_filename.ps | pstops -w${sw}cm -h${sh}cm '0\@$scale(${xoff}cm,${yoff}cm)' >> $recv_filename.resized.ps")&&die();
}
close($ps_file)||die();
system("ps2pdf $recv_filename.resized.ps $recv_filename.pdf 1>&2")&&die();
my($fax_counter)=(inc_fetch_counters($recipient,'fax'))[1];
$email_to||die();
if($email_locale ne ''){
defined(setlocale(LC_MESSAGES,$email_locale))||die();
defined(setlocale(LC_CTYPE,$email_locale))||die();
}
my $mail=new MIME::Lite(
From => $email_from,
To => $email_to,
Type => 'text/plain; charset=iso-8859-1',
Subject => sprintf(gettext('Fax from %s (%s)'),$remotestationid,$faxpages==1?gettext('one page'):sprintf(gettext('%d pages'),$faxpages)),
Data => sprintf(gettext(<<EOD),$remotestationid,$remotecallerid eq 'CID withheld'?gettext('CID withheld'):$remotecallerid,$faxpages)
Fax station ID of the sender..: %s
Caller-ID of the sender.......: %s
Number of pages...............: %d
EOD
);
$mail->attach(
Type => 'application/pdf',
Filename => sprintf(sprintf(gettext('fax%s.pdf'),'%05d'),$fax_counter),
Path => "$recv_filename.pdf"
);
defined(setlocale(LC_MESSAGES,'C'))||die();
defined(setlocale(LC_CTYPE,'C'))||die();
$mail->send()||die();
rmtree($recv_dirname,0,1);
}else{
die();
}
exit(0);
sub config_get{
my($x,$name,$config)=@_;
$_[0]=$config->{$name}if(defined($config->{$name}));
}
sub resolve_papername{
my $name=shift();
open(my $paperconf,'-|',"paperconf -csz $name")||die();
defined(my $paperdims=<$paperconf>)||die();
close($paperconf)||die();
($paperdims=~/^\s*(\d+(?:\.\d+)?|\.\d+)\s*cm\s*(\d+(?:\.\d+)?|\.\d+)\s*cm\s*$/)||die();
my $width=$1;
my $height=$2;
return($width,$height);
}
sub agi_get_var{
my $var=shift();
print("GET VARIABLE $var\n")||die();
defined(my $r=<stdin>)||die();
$r=~/^200 result=1 \((.*)\)$/||die();
return($1);
}
sub agi_cmd{
my($cmd,$correct_result)=@_;
print("$cmd\n")||die();
defined(my $r=<stdin>)||die();
$r=~/^200 result=$correct_result$/||die();
}
sub inc_fetch_counters{
my($recipient,$which)=@_;
open(my $fax_cnt_lock,'>',"$fax_counter_dir/lock")||die();
flock($fax_cnt_lock,LOCK_EX)||die();
unlink("$fax_counter_dir/$recipient.new"); # just in case an old version of this script left one of those lying around ...
if(stat("$fax_counter_dir/$recipient.new2")){
commit_counters($recipient);
}elsif(!$!{ENOENT}){
die();
}
my $recv_counter=0;
my $fax_counter=0;
if(open(my $fax_cnt,'<',"$fax_counter_dir/$recipient.cnt")){
defined(my $cnt_file_version=<$fax_cnt>)||die();
$cnt_file_version==1||die();
defined($recv_counter=<$fax_cnt>)||die();
defined($fax_counter=<$fax_cnt>)||die();
$recv_counter+=0;
$fax_counter+=0;
close($fax_cnt)||die();
}elsif(!$!{ENOENT}){
die();
}
if($which eq 'recv'){
++$recv_counter;
}elsif($which eq 'fax'){
++$fax_counter;
}else{
die();
}
open(my $fax_cnt,'>',"$fax_counter_dir/$recipient.new1")||die();
print($fax_cnt "1\n")||die();
print($fax_cnt "$recv_counter\n")||die();
print($fax_cnt "$fax_counter\n")||die();
close($fax_cnt)||die();
open($fax_cnt,'<',"$fax_counter_dir/$recipient.new1")||die();
fsync($fax_cnt)||die();
close($fax_cnt)||die();
rename("$fax_counter_dir/$recipient.new1","$fax_counter_dir/$recipient.new2")||die();
commit_counters($recipient);
flock($fax_cnt_lock,LOCK_UN)||die();
close($fax_cnt_lock)||die();
return($recv_counter,$fax_counter);
}
sub commit_counters{
my($recipient)=@_;
open(my $fax_cnt_dir,'<',$fax_counter_dir)||die();
fsync($fax_cnt_dir)||die();
unlink("$fax_counter_dir/$recipient.cnt")||$!{ENOENT}||die();
link("$fax_counter_dir/$recipient.new2","$fax_counter_dir/$recipient.cnt")||die();
fsync($fax_cnt_dir)||die();
unlink("$fax_counter_dir/$recipient.new2")||die();
close($fax_cnt_dir)||die();
}
/etc/asterisk/extensions.ael: (relevanter Teil)
Code:
******* => {
NoOp(Ankommendes Fax);
Set(MAILEMPF=*@a-bit-more.de);
Set(FAXFILE=/var/spool/asterisk/fax/${UNIQUEID});
Answer();
AGI(receive_fax,receive);
DeadAGI(receive_fax,deliver);
Hangup();
System(/var/lib/asterisk/scripts/fax2mail.sh "${FAXFILE}" "${FAXID}" "${FAXPAGES}" "${FAXRATE}" "${MAILEMPF}");
// Hangup();
}
/var/lib/asterisk/scripts/fax2mail.sh:
Code:
#!/bin/bash
#
# *******************************************************************
# $1 FAXFILE
# $2 FAXID
# $3 FAXPAGES
# $4 FAXRATE
# $5 MAILADRESSE
# *******************************************************************
# *************************************
# Format date and time
# *************************************
heute=$(date +"%d.%m.%Y %H:%M:%S")
# *************************************
# An entry in the log-file
# *************************************
echo $heute $1 von $2 mit $3 Seiten fuer $5 empfangen >> /var/log/asterisk/fax2mail.log
# *************************************
# Switch from sff to Multipage-TIFF
# *************************************
sfftobmp -tx $1 $1
# *************************************
# PDF is possible, too
# *************************************
# sff2misc -p $1 $1.ps
# ps2pdf -sPAPERSIZE=a4 $1.ps $1.pdf
# *************************************
# Create filename for Mailbody
# *************************************
MAILBODY=$1.txt
# *************************************
# Create Mailbody
# *************************************
echo >> $MAILBODY
echo "Empfangen: ........ " $heute >> $MAILBODY
echo "Absender: ......... " $2 >> $MAILBODY
echo "Anzahl Seiten: .... " $3 >> $MAILBODY
echo "Geschwindigkeit: .. " $4 >> $MAILBODY
echo >> $MAILBODY
echo "Das Faxdokument finden Sie im Dateianhang als TIFF-Datei." >> $MAILBODY
echo "Alle Seiten befinden sich innerhalb dieser einer Datei..." >> $MAILBODY
echo >> $MAILBODY
echo "Ihr Asterisk" >> $MAILBODY
# *************************************
# send mail with file-attachment
# *************************************
cat $MAILBODY | nail -r "asterisk" -s "Fax von $2" -a "$1.tif" $5
# *************************************
# Delete files
# *************************************
# rm $1.pdf
# rm $1.ps
rm $MAILBODY
rm $1.tif
rm $1
# *************************************
# Another entry in the logfile
# *************************************
echo $heute $1.pdf an $5 verschickt >> /var/log/asterisk/fax2mail.log
Fehlt sonst noch was?
Wär euch SEHR verbunden, wenn Ihr mir in dieser Problematik eventuell weiter helfen könntet
Grüße denny
Zuletzt bearbeitet: