Link to home
Start Free TrialLog in
Avatar of starhu
starhu

asked on

Asterisk how to monitor database

Hello,

My customer has an Asterisk 1.4. for Voip with X-Lite client.

He wants me to develop a Windows based Crm so as when there is an incoming call on a Pc, the Crm would find the customer automatically (by finding the incoming telephone number in the database of the Crm).

I can see 2 ways to solve this:

1.to constantly monitor the Asterisk database and get the actual phone number from it
in this case I need some guidance about the database structure and what tables to check

2.To get the information from X-Lite somehow

Maybe there are other ways I haven't thought about.
Please help me with this

Thank you


Avatar of noci
noci

Hm. asterisk can write the call detail records to any database / flat file you like.
So that is more or less up to you. to decide how:

cdr engines are there for: postgresql, mysql, syslog, sqlite, odbc, flatfile.

This might be usefull too.
http://www.loudhush.ro/tools/AsteriskCDRInspector.html

Avatar of starhu

ASKER

How can I check what database uses the existing Asterix? I am a newbie in Linux
First asterisk != linux.
In general config files in linux are kept /etc/..  but that may be different.
Most configuration files are normal ascii files that can be read.

In the asterisk configuration (mostly /etc/asterisk ) you have a number of cdr*.conf files.
and in modules.conf one of the modules is enabled.
(or rather no disabled).

Tools to read ascii files are 'less' or 'more'...
There are several ways to do this...but having agent software poll the DB is going to be very costly the more users you have.

Essentially you need to get ..either the phone number to the client, the complete record, or a path to get to the customer record.

I already do something similar to this on my system, so i'll give you a basic run down of how it works on my end.   Then i'll give you a much simpler.."quick and dirty" method.

Agent -
1.  Agent logs into agent software with user/pass, the extension for their machine is already prefilled from settings.
2.  Agent software sends a "timestamp" update to an agent table (mysql) on the Asterisk server every 6 seconds, while they are in "ready" mode.
3.  Agent software has a TcpClientListener running that only accepts connections from the Asterisk server on port 5039.
4.  Agent recieves "INCOMING:${tableid}/${recordid}" so that it can pull a record immediately upon recieving a call.
5.  Agent goes into status "not ready" until record is released.

Customer -
1.  Customer calls in.
2.  Asterisk attempts to lookup the customer record by phone number storing the table ID and record ID to variables if it finds it.
    2a.  If it's not found, the customer is prompted to enter the phone associated with their account and another lookup is attmpted.
    2b.  If not found after two tries they go to operators group
3.  If the customer record is found, Asterisk polls the agent table for all agents who's timestamp is greater than the current time plus (-) negative 6 seconds and whose "timeinstatus" is the oldest.
    3a.  If Agent is not available customer remains in queue looping until an Agent is free.
4.  Asterisk uses the Extension retrieved from the agent table to get the IPaddress ....using ${SIPPEER(${agentexten}:ip)})
5.  Asterisk runs netcat to send the information to the listening client app  ...System(nc ${AGENTIPADDRESS} 5039 <<< "INCOMING:${tableid}/${recordid}")



If all that is too tough for you, then try this method...
1. Asterisk recieves a call....
2. Asterisk chooses agent...(for example agent 3002)
3. Asterisk writes a file to a Samba share...    \\server\share\3002.txt   ..inside the file is the customer phone number
4. Each agent client is polling the samba share for a file that matches their own extension.  When they find it, they read the number inside of it, then delete the file,  and then search the db for the number.  
5. When they release the record they update the agent table to be "ready" again.

There other methods to acheive the same results... I suppose it depends on your expertise and resources and development time allowed.

Another method is to poll the AMI (Asterisk Manager Interface), service running on Asterisk...there are even .Net classes you can use to communicate with it.
Avatar of starhu

ASKER

xuserx2000: My customer uses a Linux Server for Asterix and Windows clients for X-Lite.

Can I get the incoming information directly from X-Lite?
ASKER CERTIFIED SOLUTION
Avatar of noci
noci

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of starhu

ASKER

it didn't completely solve my problem