A python script that extracts call data from Asterisk CDR database and sends a tabulated email.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
HTML.py Basic data extraction and email-sending functionality. Jun 23, 2014



Its a python script that collects caller ID, call time, call source and destination, disposition and duration from CDR database of all outbound and inbound calls from and to PSTN network. After arranging the data it sends a report of the calls and sends a tabulated email to a user defined email address.

The script uses MySQLdb to extract data from the CDR database and uses HTML.py to tabualte the data in an HTML table.

smtplib is used to send email. Dependencies

Apart from standard python installation, the script requires HTML.py which is already included and MySQLdb library. You can install MySQLdb as follows:


apt-get install python-mysqldb


yum install MySQL-python


cd /usr/ports/databases/py-MySQLdb
make install clean


This script is intended to be used as a cron that runs at 23:59 everyday.

Known Issues

At the moment the script is hard-coded to do things such as:

  • Connecting to database.
  • Counting length of numbers to distinguish PSTN from SIP extensions. (if conditions under for loop under processcdr() function)
  • Sending authenticated email (sendemail() function)


Saad Ali - Linux/BSD Admin

Philippe Lagadec - Author of HTML.py


  • The script AsteriskCDReporter.py is licensed under MIT License.
  • HTML.py is licensed under CeCILL license.