Mitel 5000 SMDR Script

The Mitel 5000 is a great system but the base licensed setup has a bit to be desired as far as reporting is concerned. I wanted to know who was making making and receiving calls and how long they were taking. I found some Mitel documentation on how to enable SMDR on the system and sent ahead and enabled it.

Mitel 5000 SMDR Setting

The Mitel 5000 SMDR Setting

After enabling SMDR on the Mitel (and rebooting it) you can run the script below on a Linux machine to collect live call data from the system. The SMDR data exchange is very simple. If you have any issues with it I suggest looking at the exchange with wireshark to see what is wrong. IO:Socket should take care of everything you need for the TCP connection. The script and phone system do the rest. I suppose this could be turned into a daemon fairly easily and used to log to a database. As always, the sky is the limit…

use strict;
use IO::Socket;
use POSIX;
my $host = ''; # replace with your Mitel's IP address
my $port = 4000;
my $sock;  #variable for connection socket
### Never ending loop
	my $data;
	print $data;
	undef $data;
	$sock = &connect($host, $port);
#easy now... don't loop so fast...
#Connection to the Mitel system
sub connect{
	my($host, $port) = @_;
	#Create Socket
	my $sock = new IO::Socket::INET(
		PeerAddr => $host,
		PeerPort => $port,
		Proto => "tcp",
		Type =>SOCK_STREAM) or die "Cannot connect to PBX at address: $host port: $port: $!";
	return $sock;
This entry was posted in PERL, Scripts, Telephony and tagged , . Bookmark the permalink.

2 Responses to Mitel 5000 SMDR Script

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.