I've been asked to develop a script that can via H.323 dial a voicemail system that needs better monitoring. (The device dies in mysterious ways and offers very little over snmp). The idea is to call a number, and see if it the line gets answered. The Voice Mail system will ring busy or not answer if there's a problem.
My problem lies in the fact that I know nothing开发者_如何学C about H.323 or the available libraries. (Perl is the language of choice at my company, but for something this specific I could probably get away with python or a the use of some binary programs.)
I've found a dark rabbit hole of dispare when searching for H.323. I don't know C or want to run a pbx as a client, I've found open source libaries but there is no such thing as a "call()" function. I don't have the cycles to learn every in and out.
(If this wasn't for work I'd hook up a few lines of python and use Twilio to do all the heavy lifting.)
I think I need some guidance on how to solve the problem.
Thanks
To place test H.323 calls, you can't beat ohphone:
(sleep 30; echo q) | ohphone -s Default -n -u from_user to_user@gateway > /tmp/output.$$
You can typically find ohphone as a package in your linux distribution:
apt-get install ohphone
The source can be found on voxgratia While older, it still works splendidly.
Processing the output is a tad tricky with ohphone, but you can use something like a perl script to process it into an errno value.
Here's a quick and dirty example does just that:
#!/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;
This script is a quite a few years old, but it has worked well for us during that time.
There are SIP Testing tools that allow you to generate SIP Traffic. I have used SIPp in the past as part of a university project maybe this is of help to you
**EDIT:**
A quick search gives Yate Seagull I have not used them but maybe they solve your issues. If you find something do post it definitely.
精彩评论