SlideShare uma empresa Scribd logo
1 de 18
Baixar para ler offline
Call Data Analysis
for Asterisk & FreeSWITCH
      with MongoDB

     Arezqui Belaid @areskib
     <info@star2billing.com>
Problems to solve

             - Millions of Call records
             - Multiple sources
             - Multiple data formats
             - Replication
             - Fast Analytics
             - Multi-Tenant
             - Realtime
             - Fraud detection
Why MongoDB
- NoSQL - Schema-Less
- Capacity / Sharding
- Upserts
- Replication : Increase read capacity
- Async writes : Millions of entries / acceptable losses
- Compared to CouchDB - native drivers
What does it look like?   Dashboard
Hourly / Daily / Monthly reporting
Compare call traffic
World Map
Realtime
Under the hood
- FreeSWITCH (freeswitch.org)
- Asterisk (asterisk.org)
- Django (djangoproject.com)
- Celery (celeryproject.org)
- RabbitMQ (rabbitmq.com)
- Socket.IO (socket.io)
- MongoDB (mongo.org)
- PyMongo (api.mongo.org)
- and more...
Our Data - Call Detail Record (CDR)
1) Call info :



2) BSON :    CDR = {                                                'hangup_cause_q850':'20',
               ...                                                  'hangup_cause':'NORMAL_CLEARING',
               'callflow':{                                         'sip_received_ip':'192.168.1.21',
                 'caller_profile':{                                 'sip_from_host':'127.0.0.1',
                                                                    'tts_voice':'kal',7',
                   'username':'1000',
                                                                    'accountcode':'1000',
                   'destination_number':'5578193435',               'sip_user_agent':'Blink 0.2.8 (Linux)',
                   'ani':'71737224',                                'answerusec':'0',
                   'caller_id_name':'71737224',                     'caller_id':'71737224',
                   ...                                              'call_uuid':'adee0934-a51b-11e1-a18c-
                 },                                             00231470a30c',
                 ...                                                'answer_stamp':'2012-05-23 15:45:09.856463',
               },                                                   'outbound_caller_id_name':'FreeSWITCH',
               'variables':{                                        'billsec':'66',
                 'mduration':'12960',                               'progress_uepoch':'0',
                 'effective_caller_id_name':'Extension 1000',       'answermsec':'0',
                                                                    'sip_via_rport':'60536',
                 'outbound_caller_id_number':'0000000000',
                                                                    'uduration':'12959984',
                 'duration':'3',                                    'sip_local_sdp_str':'v=0no=FreeSWITCH
                 'end_stamp':'2012-05-23 15:45:12.856527',      1327491731n'
                 'answer_uepoch':'1327521953952257',              },
                 'billmsec':'12960',                            ...
             ...
3) Insert Mongo : db.cdr.insert(CDR);
Pre-Aggregate
Pre-Aggregate - Daily Collection
Produce data easier to manipulate :
              current_y_m_d = datetime.strptime(str(start_uepoch)[:10], "%Y-%m-%d")
              CDR_DAILY.update({
                       'date_y_m_d': current_y_m_d,
                       'destination_number': destination_number,
                       'hangup_cause_id': hangup_cause_id,
                       'accountcode': accountcode,
                       'switch_id': switch.id,
                   },{
                       '$inc':
                          {'calls': 1,
                           'duration': int(cdr['variables']['duration']) }
                   }, upsert=True)

Output db.CDR_DAILY.find() :
{ "_id" : ..., "date_y_m_d" : ISODate("2012-04-30T00:00:00Z"), "accountcode" : "1000", "calls" : 1, "destination_number"
: "0045277522", "duration" : 23, "hangup_cause_id" :9, "switch_id" :1 }
...


                                                                           - Faster to query pre-aggregate data
                                                           - Upsert is your friend / update if exists - insert if not
Map-Reduce - Emit Step
- MapReduce is a batch processing of data
- Applying to previous pre-aggregate collection (Faster / Less data)

             map = mark_safe(u'''
                 function(){
                      emit( {
                           a_Year: this.date_y_m_d.getFullYear(),
                           b_Month: this.date_y_m_d.getMonth() + 1,
                           c_Day: this.date_y_m_d.getDate(),
                           f_Switch: this.switch_id
                         },
                         {calldate__count: 1, duration__sum: this.duration} )
                 }''')
Map-Reduce - Reduce Step
Reduce Step is trivial, it simply sums up and counts :

             reduce = mark_safe(u'''
                 function(key,vals) {
                    var ret = {
                                calldate__count : 0,
                                duration__sum: 0,
                                duration__avg: 0
                            };

                         for (var i=0; i < vals.length; i++){
                            ret.calldate__count += parseInt(vals[i].calldate__count);
                            ret.duration__sum += parseInt(vals[i].duration__sum);
                         }
                         return ret;
                  }
                  ''')
Map-Reduce
Query :
                  out = 'aggregate_cdr_daily'
                  calls_in_day = daily_data.map_reduce(map, reduce, out, query=query_var)


Output db.aggregate_cdr_daily.find() :
{ "_id" : { "a_Year" : 2012, "b_Month" : 5, "c_Day" : 13, "f_Switch" :1 }, "value" : { "calldate__count" : 91,
"duration__sum" : 5559, "duration__avg" : 0 } }
{ "_id" : { "a_Year" : 2012, "b_Month" : 5, "c_Day" : 14, "f_Switch" :1 }, "value" : { "calldate__count" : 284,
"duration__sum" : 13318, "duration__avg" : 0 } }
...
Roadmap

- Quality monitoring
- Audio recording
- Add support for other telecoms switches
- Improve - refactor (Beta)
- Testing
- Listen and Learn
WAT else...?

- Website : http://www.cdr-stats.org

- Code : github.com/star2billing/cdr-stats

- FOSS / Licensed MPLv2

- Get started : Install script
  Try it, it's easy!!!
Questions ?

  Twitter : @areskib
Email : areski@gmail.com

Mais conteúdo relacionado

Mais procurados

Cynara co2
Cynara co2Cynara co2
Cynara co2
NFPA
 

Mais procurados (11)

Rapport Bende van Nijvel onderzoeksrechter Guy Wezel
Rapport Bende van Nijvel onderzoeksrechter Guy WezelRapport Bende van Nijvel onderzoeksrechter Guy Wezel
Rapport Bende van Nijvel onderzoeksrechter Guy Wezel
 
[Maxiprocesso di Palermo, Istruttoria] - Volume 24
[Maxiprocesso di Palermo, Istruttoria] - Volume 24[Maxiprocesso di Palermo, Istruttoria] - Volume 24
[Maxiprocesso di Palermo, Istruttoria] - Volume 24
 
Hoyer IE3 Electric Motors
Hoyer IE3 Electric MotorsHoyer IE3 Electric Motors
Hoyer IE3 Electric Motors
 
Strategic Management of Costa Navarino
Strategic Management of Costa NavarinoStrategic Management of Costa Navarino
Strategic Management of Costa Navarino
 
TinyML - 4 speech recognition
TinyML - 4 speech recognition TinyML - 4 speech recognition
TinyML - 4 speech recognition
 
Cynara co2
Cynara co2Cynara co2
Cynara co2
 
Mobile Phone Cloning
Mobile Phone CloningMobile Phone Cloning
Mobile Phone Cloning
 
Snake game ai presentation
Snake game ai presentationSnake game ai presentation
Snake game ai presentation
 
Koning Boudewijn viel uit rol bij Vlaamse school Komen
Koning Boudewijn viel uit rol bij Vlaamse school KomenKoning Boudewijn viel uit rol bij Vlaamse school Komen
Koning Boudewijn viel uit rol bij Vlaamse school Komen
 
SFO15-406: ARM FDPIC toolset, kernel & libraries for Cortex-M & Cortex-R mmul...
SFO15-406: ARM FDPIC toolset, kernel & libraries for Cortex-M & Cortex-R mmul...SFO15-406: ARM FDPIC toolset, kernel & libraries for Cortex-M & Cortex-R mmul...
SFO15-406: ARM FDPIC toolset, kernel & libraries for Cortex-M & Cortex-R mmul...
 
Guiggiani ruote dentate
Guiggiani ruote dentateGuiggiani ruote dentate
Guiggiani ruote dentate
 

Destaque

Storage Characteristics Of Call Data Records In Column Store Databases
Storage Characteristics Of Call Data Records In Column Store DatabasesStorage Characteristics Of Call Data Records In Column Store Databases
Storage Characteristics Of Call Data Records In Column Store Databases
David Walker
 
Customizing the Django Admin
Customizing the Django AdminCustomizing the Django Admin
Customizing the Django Admin
Lincoln Loop
 
Monetizing Big Data at Telecom Service Providers
Monetizing Big Data at Telecom Service ProvidersMonetizing Big Data at Telecom Service Providers
Monetizing Big Data at Telecom Service Providers
DataWorks Summit
 

Destaque (20)

Big Data CDR Analyzer - Kanthaka
Big Data CDR Analyzer - KanthakaBig Data CDR Analyzer - Kanthaka
Big Data CDR Analyzer - Kanthaka
 
Kanthaka - High Volume CDR Analyzer
Kanthaka - High Volume CDR AnalyzerKanthaka - High Volume CDR Analyzer
Kanthaka - High Volume CDR Analyzer
 
telecom analytics ppt
telecom analytics ppttelecom analytics ppt
telecom analytics ppt
 
Benefiting from Big Data - A New Approach for the Telecom Industry
Benefiting from Big Data - A New Approach for the Telecom Industry  Benefiting from Big Data - A New Approach for the Telecom Industry
Benefiting from Big Data - A New Approach for the Telecom Industry
 
Predictive Analytics in Telecommunication
Predictive Analytics in TelecommunicationPredictive Analytics in Telecommunication
Predictive Analytics in Telecommunication
 
Storage Characteristics Of Call Data Records In Column Store Databases
Storage Characteristics Of Call Data Records In Column Store DatabasesStorage Characteristics Of Call Data Records In Column Store Databases
Storage Characteristics Of Call Data Records In Column Store Databases
 
Connecting the Dots—How a Graph Database Enables Discovery
Connecting the Dots—How a Graph Database Enables DiscoveryConnecting the Dots—How a Graph Database Enables Discovery
Connecting the Dots—How a Graph Database Enables Discovery
 
Nikola, a static blog & site generator python meetup 19 feb2014
Nikola, a static blog & site generator   python meetup 19 feb2014Nikola, a static blog & site generator   python meetup 19 feb2014
Nikola, a static blog & site generator python meetup 19 feb2014
 
Newfies dialer - autodialer : freeswitch weekly conference 13 march2013
Newfies dialer - autodialer : freeswitch weekly conference 13 march2013Newfies dialer - autodialer : freeswitch weekly conference 13 march2013
Newfies dialer - autodialer : freeswitch weekly conference 13 march2013
 
Whitepaper newfies-dialer Autodialer
Whitepaper newfies-dialer AutodialerWhitepaper newfies-dialer Autodialer
Whitepaper newfies-dialer Autodialer
 
Newfies dialer Brief Introduction
Newfies dialer Brief IntroductionNewfies dialer Brief Introduction
Newfies dialer Brief Introduction
 
Newfies dialer Auto dialer Software
Newfies dialer Auto dialer SoftwareNewfies dialer Auto dialer Software
Newfies dialer Auto dialer Software
 
Ativ1 4 rafaelaam
Ativ1 4 rafaelaamAtiv1 4 rafaelaam
Ativ1 4 rafaelaam
 
Data Science Strategy
Data Science StrategyData Science Strategy
Data Science Strategy
 
Customer insights from telecom data using deep learning
Customer insights from telecom data using deep learning Customer insights from telecom data using deep learning
Customer insights from telecom data using deep learning
 
Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python Meetup
 
Big Data Telecom
Big Data TelecomBig Data Telecom
Big Data Telecom
 
Customizing the Django Admin
Customizing the Django AdminCustomizing the Django Admin
Customizing the Django Admin
 
Monetizing Big Data at Telecom Service Providers
Monetizing Big Data at Telecom Service ProvidersMonetizing Big Data at Telecom Service Providers
Monetizing Big Data at Telecom Service Providers
 
Deep Learning for Fraud Detection
Deep Learning for Fraud DetectionDeep Learning for Fraud Detection
Deep Learning for Fraud Detection
 

Semelhante a CDR-Stats : VoIP Analytics Solution for Asterisk and FreeSWITCH with MongoDB

Mongo db world 2014 billrun
Mongo db world 2014   billrunMongo db world 2014   billrun
Mongo db world 2014 billrun
MongoDB
 
Operational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB WebinarOperational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB Webinar
MongoDB
 
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
doughellmann
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
MongoDB
 
Describe the complete pipeline in ML using programming through PyTorch.pdf
Describe the complete pipeline in ML using programming through PyTorch.pdfDescribe the complete pipeline in ML using programming through PyTorch.pdf
Describe the complete pipeline in ML using programming through PyTorch.pdf
BorisdFHFraserk
 
Fido u2 f in 10 minutes (cis 2015)
Fido u2 f in 10 minutes (cis 2015)Fido u2 f in 10 minutes (cis 2015)
Fido u2 f in 10 minutes (cis 2015)
CloudIDSummit
 
Viki Big Data Meetup 2013_10
Viki Big Data Meetup 2013_10Viki Big Data Meetup 2013_10
Viki Big Data Meetup 2013_10
ishanagrawal90
 

Semelhante a CDR-Stats : VoIP Analytics Solution for Asterisk and FreeSWITCH with MongoDB (20)

Cdr stats-vo ip-analytics_solution_mongodb_meetup
Cdr stats-vo ip-analytics_solution_mongodb_meetupCdr stats-vo ip-analytics_solution_mongodb_meetup
Cdr stats-vo ip-analytics_solution_mongodb_meetup
 
Mongo db world 2014 billrun
Mongo db world 2014   billrunMongo db world 2014   billrun
Mongo db world 2014 billrun
 
MongoDB World 2014 - BillRun, Billing on top of MongoDB
MongoDB World 2014 - BillRun, Billing on top of MongoDBMongoDB World 2014 - BillRun, Billing on top of MongoDB
MongoDB World 2014 - BillRun, Billing on top of MongoDB
 
Map/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDBMap/Confused? A practical approach to Map/Reduce with MongoDB
Map/Confused? A practical approach to Map/Reduce with MongoDB
 
Assignment7.pdf
Assignment7.pdfAssignment7.pdf
Assignment7.pdf
 
UDP.yash
UDP.yashUDP.yash
UDP.yash
 
Operational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB WebinarOperational Intelligence with MongoDB Webinar
Operational Intelligence with MongoDB Webinar
 
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
[Pgday.Seoul 2021] 2. Porting Oracle UDF and Optimization
 
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
 
Der perfekte 12c trigger
Der perfekte 12c triggerDer perfekte 12c trigger
Der perfekte 12c trigger
 
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...How I Built a Power Debugger Out of the Standard Library and Things I Found o...
How I Built a Power Debugger Out of the Standard Library and Things I Found o...
 
odoo json rpc.docx
odoo json rpc.docxodoo json rpc.docx
odoo json rpc.docx
 
How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6How to leverage what's new in MongoDB 3.6
How to leverage what's new in MongoDB 3.6
 
MongoDB Performance Tuning
MongoDB Performance TuningMongoDB Performance Tuning
MongoDB Performance Tuning
 
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
 
Describe the complete pipeline in ML using programming through PyTorch.pdf
Describe the complete pipeline in ML using programming through PyTorch.pdfDescribe the complete pipeline in ML using programming through PyTorch.pdf
Describe the complete pipeline in ML using programming through PyTorch.pdf
 
MongoDB dla administratora
MongoDB dla administratora MongoDB dla administratora
MongoDB dla administratora
 
CIS 2015b FIDO U2F in 10 minutes - Dirk Balfanz
CIS 2015b FIDO U2F in 10 minutes - Dirk BalfanzCIS 2015b FIDO U2F in 10 minutes - Dirk Balfanz
CIS 2015b FIDO U2F in 10 minutes - Dirk Balfanz
 
Fido u2 f in 10 minutes (cis 2015)
Fido u2 f in 10 minutes (cis 2015)Fido u2 f in 10 minutes (cis 2015)
Fido u2 f in 10 minutes (cis 2015)
 
Viki Big Data Meetup 2013_10
Viki Big Data Meetup 2013_10Viki Big Data Meetup 2013_10
Viki Big Data Meetup 2013_10
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

CDR-Stats : VoIP Analytics Solution for Asterisk and FreeSWITCH with MongoDB

  • 1. Call Data Analysis for Asterisk & FreeSWITCH with MongoDB Arezqui Belaid @areskib <info@star2billing.com>
  • 2. Problems to solve - Millions of Call records - Multiple sources - Multiple data formats - Replication - Fast Analytics - Multi-Tenant - Realtime - Fraud detection
  • 3. Why MongoDB - NoSQL - Schema-Less - Capacity / Sharding - Upserts - Replication : Increase read capacity - Async writes : Millions of entries / acceptable losses - Compared to CouchDB - native drivers
  • 4. What does it look like? Dashboard
  • 5. Hourly / Daily / Monthly reporting
  • 9. Under the hood - FreeSWITCH (freeswitch.org) - Asterisk (asterisk.org) - Django (djangoproject.com) - Celery (celeryproject.org) - RabbitMQ (rabbitmq.com) - Socket.IO (socket.io) - MongoDB (mongo.org) - PyMongo (api.mongo.org) - and more...
  • 10. Our Data - Call Detail Record (CDR) 1) Call info : 2) BSON : CDR = { 'hangup_cause_q850':'20', ... 'hangup_cause':'NORMAL_CLEARING', 'callflow':{ 'sip_received_ip':'192.168.1.21', 'caller_profile':{ 'sip_from_host':'127.0.0.1', 'tts_voice':'kal',7', 'username':'1000', 'accountcode':'1000', 'destination_number':'5578193435', 'sip_user_agent':'Blink 0.2.8 (Linux)', 'ani':'71737224', 'answerusec':'0', 'caller_id_name':'71737224', 'caller_id':'71737224', ... 'call_uuid':'adee0934-a51b-11e1-a18c- }, 00231470a30c', ... 'answer_stamp':'2012-05-23 15:45:09.856463', }, 'outbound_caller_id_name':'FreeSWITCH', 'variables':{ 'billsec':'66', 'mduration':'12960', 'progress_uepoch':'0', 'effective_caller_id_name':'Extension 1000', 'answermsec':'0', 'sip_via_rport':'60536', 'outbound_caller_id_number':'0000000000', 'uduration':'12959984', 'duration':'3', 'sip_local_sdp_str':'v=0no=FreeSWITCH 'end_stamp':'2012-05-23 15:45:12.856527', 1327491731n' 'answer_uepoch':'1327521953952257', }, 'billmsec':'12960', ... ... 3) Insert Mongo : db.cdr.insert(CDR);
  • 12. Pre-Aggregate - Daily Collection Produce data easier to manipulate : current_y_m_d = datetime.strptime(str(start_uepoch)[:10], "%Y-%m-%d") CDR_DAILY.update({ 'date_y_m_d': current_y_m_d, 'destination_number': destination_number, 'hangup_cause_id': hangup_cause_id, 'accountcode': accountcode, 'switch_id': switch.id, },{ '$inc': {'calls': 1, 'duration': int(cdr['variables']['duration']) } }, upsert=True) Output db.CDR_DAILY.find() : { "_id" : ..., "date_y_m_d" : ISODate("2012-04-30T00:00:00Z"), "accountcode" : "1000", "calls" : 1, "destination_number" : "0045277522", "duration" : 23, "hangup_cause_id" :9, "switch_id" :1 } ... - Faster to query pre-aggregate data - Upsert is your friend / update if exists - insert if not
  • 13. Map-Reduce - Emit Step - MapReduce is a batch processing of data - Applying to previous pre-aggregate collection (Faster / Less data) map = mark_safe(u''' function(){ emit( { a_Year: this.date_y_m_d.getFullYear(), b_Month: this.date_y_m_d.getMonth() + 1, c_Day: this.date_y_m_d.getDate(), f_Switch: this.switch_id }, {calldate__count: 1, duration__sum: this.duration} ) }''')
  • 14. Map-Reduce - Reduce Step Reduce Step is trivial, it simply sums up and counts : reduce = mark_safe(u''' function(key,vals) { var ret = { calldate__count : 0, duration__sum: 0, duration__avg: 0 }; for (var i=0; i < vals.length; i++){ ret.calldate__count += parseInt(vals[i].calldate__count); ret.duration__sum += parseInt(vals[i].duration__sum); } return ret; } ''')
  • 15. Map-Reduce Query : out = 'aggregate_cdr_daily' calls_in_day = daily_data.map_reduce(map, reduce, out, query=query_var) Output db.aggregate_cdr_daily.find() : { "_id" : { "a_Year" : 2012, "b_Month" : 5, "c_Day" : 13, "f_Switch" :1 }, "value" : { "calldate__count" : 91, "duration__sum" : 5559, "duration__avg" : 0 } } { "_id" : { "a_Year" : 2012, "b_Month" : 5, "c_Day" : 14, "f_Switch" :1 }, "value" : { "calldate__count" : 284, "duration__sum" : 13318, "duration__avg" : 0 } } ...
  • 16. Roadmap - Quality monitoring - Audio recording - Add support for other telecoms switches - Improve - refactor (Beta) - Testing - Listen and Learn
  • 17. WAT else...? - Website : http://www.cdr-stats.org - Code : github.com/star2billing/cdr-stats - FOSS / Licensed MPLv2 - Get started : Install script Try it, it's easy!!!
  • 18. Questions ? Twitter : @areskib Email : areski@gmail.com