2010-11-10 58 views
5

我被要求開發一個腳本,可以通過H.323撥打需要更好監控的語音郵件系統。 (該設備以神祕的方式死亡,並提供snmp很少)。這個想法是打電話給一個號碼,看看這條線路是否得到了答覆。如果出現問題,語音信箱系統將響鈴或不響應。使用H.323測試傳統語音郵件系統

我的問題在於我對H.323或可用庫一無所知。 (Perl是我公司的選擇語言,但是對於這個特定的東西,我可能會用python或使用一些二進制程序逃脫。)

我找到了一個黑暗的兔子洞, H.323。我不知道C還是想作爲客戶端運行一個pbx,我找到了開放源代碼庫,但沒有「call()」函數。我沒有周期來學習每一個進出。

(如果這是不工作我會掛鉤蟒蛇幾行,並使用Twilio做所有繁重。)

我想我需要就如何解決問題的一些指導。

感謝

回答

1

有SIP測試工具,讓你產生SIP流量。我已經使用SIPp在過去作爲一個大學項目的一部分,也許這是對你有所幫助

**EDIT:**

快速搜索給人YateSeagull我沒有使用過他們,但也許他們解決您的問題。如果你發現一些東西確實發佈。

+0

這看起來很有希望! 「SIPp可用於運行一個呼叫並退出,提供通過/失敗的判決」 – reconbot 2010-11-10 17:07:32

+0

woops - 錯誤的協議不再適用= \你有一個用於h.323嗎? – reconbot 2010-11-10 20:16:15

3

發出測試H.323呼叫,你不能擊敗ohphone:

(sleep 30; echo q) | ohphone -s Default -n -u from_user [email protected] > /tmp/output.$$ 

通常,您可以找到ohphone作爲一個整體在你的Linux發行版:

apt-get install ohphone 

來源可以是發現在voxgratia 雖然年紀大了,它仍然出色地工作。

使用ohphone處理輸出有點棘手,但是您可以使用類似perl腳本的東西將其處理爲errno值。

這裏有一個快速和骯髒的例子就是這樣做的:

#!/usr/bin/env perl 

$delay=$ARGV[0]; 
if(! $delay) { $delay = 10; } 

$from=$ARGV[1]; 
if(! $from) { $from = "default_from_user"; } 

$to=$ARGV[2]; 
if(! $to) { $to = "default_to_user"; } 

$gateway=$ARGV[3]; 
if(! $gateway) { $gateway = "127.0.0.1"; } 

print "Running: (sleep $delay; echo q) | (ohphone -s Default -n -u $from $to\@$gateway)|\n"; 
open(IN,"(sleep $delay; echo q) | (ohphone -s Default -n -u $from $to\@$gateway)|"); 

my $call_started=false; 
my $call_completed=false; 

my @results; 

my $skip=1; 
while($line=<IN>) { 
if($line=~/Listening interfaces/) { 
    $skip=0; 
    next; 
} 
if($skip) { 
    next; 
} 
if($line=~/^Could not open sound device/) { 
    next; 
} 
chomp($line); 
push(@results,$line); 
if($line=~/was busy$/) { 
    print "$to: Called party busy\n"; 
    exit 1; 
} 
if($line=~/^Call with .* completed, duration (.*)$/) { 
    print "$to: Completed duration $1 call.\n"; 
    exit 0; 
} 
if($line=~/has cleared the call, duration (.*)$/) { 
    print "$to: Completed duration $1 call.\n"; 
    exit 0; 
} 
if($line=~/^Call with .* completed$/) { 
    print "$to: No call duration.\n"; 
    exit 2; 
} 
} 

close(IN); 

$result=join("\n",@results); 
print "$ARGV[0]: Unknown results:\n$result\n"; 
exit 255; 

這個腳本是一個相當幾年的歷史,但在這段時間裏的工作很適合我們。