Database queues in Asterisk - timeout not being honored - database

I setup dynamic queues in Asterisk according to this: http://libryder.com/Ez7llN
The queues connect successfully and all members are recognized but it always rings to voicemail, never trying the next member.
+----+------------+-------------+----------+---------+---------+--------------+----------------+------------------+----------------+--------------------+----------------+---------------+---------------+----------------+----------------+------------------+--------------------+------------------------+-------------------+-------+------------+--------+--------------+----------+-----------+----------------+-------------------+-----------------+----------------+-------------+--------+----------------+-----------+-----------------+----------+-----------------+
| id | name | musiconhold | announce | context | timeout | monitor_join | monitor_format | queue_youarenext | queue_thereare | queue_callswaiting | queue_holdtime | queue_minutes | queue_seconds | queue_lessthan | queue_thankyou | queue_reporthold | announce_frequency | announce_round_seconds | announce_holdtime | retry | wrapuptime | maxlen | servicelevel | strategy | joinempty | leavewhenempty | eventmemberstatus | eventwhencalled | reportholdtime | memberdelay | weight | timeoutrestart | ringinuse | setinterfacevar | autofill | timeoutpriority |
+----+------------+-------------+----------+---------+---------+--------------+----------------+------------------+----------------+--------------------+----------------+---------------+---------------+----------------+----------------+------------------+--------------------+------------------------+-------------------+-------+------------+--------+--------------+----------+-----------+----------------+-------------------+-----------------+----------------+-------------+--------+----------------+-----------+-----------------+----------+-----------------+
| 5 | 4352754426 | NULL | NULL | NULL | 5 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | 0 | NULL | ringall | NULL | NULL | NULL | NULL | NULL | 0 | NULL | NULL | NULL | yes | yes | conf |
+----+------------+-------------+----------+---------+---------+--------------+----------------+------------------+----------------+--------------------+----------------+---------------+---------------+----------------+----------------+------------------+--------------------+------------------------+-------------------+-------+------------+--------+--------------+----------+-----------+----------------+-------------------+-----------------+----------------+-------------+--------+----------------+-----------+-----------------+----------+-----------------+
+----------+------------+------------+---------------------------+---------+--------+---------+
| uniqueid | membername | queue_name | interface | penalty | paused | hunt_id |
+----------+------------+------------+---------------------------+---------+--------+---------+
| 18 | agent1 | 4352754426 | local/4352151050#outbound | NULL | NULL | 5 |
| 19 | agent2 | 4352754426 | local/4352151052#outbound | NULL | NULL | 5 |
| 20 | agent3 | 4352754426 | local/4352151054#outbound | NULL | NULL | 5 |
+----------+------------+------------+---------------------------+---------+--------+---------+
Am I missing some option?

Please try with different ring strategy instead of ringall like random or rrmemory. And please also check timeout field it look too low ?

Related

compare two tables in a query taking so long time

I have a a query where i compare 350 rows with other tables which are having 50000 rows it takes 5 minutes to give result.Any faster way to retrieve values get earlier.
select lower(rtrim(substring(rt_queue, 3, 6))) + " Ticor - " + convert(varchar(4), sort_grp_id) + " " + rtrim(batch_no) + ".prn" as FILENAME from tprt_queue where cycle_date >= (select CYCLE from tb_jpachi_cycle) and batch_no <> 'JOBCTR-' and rt_queue not like '%CN%' and status = 'TINTED' and lower(rtrim(substring(prt_queue, 3, 6))) + " Bicor - " + convert(varchar(4), sort_grp_id) + " " + rtrim(batch_no) + ".prn" not in (
select FILENAME from tb_jpachi_filesprocess ) order by rt_dt
This one contains 100000 rows : select FILENAME from tb_jpachi_filesprocess
Later it will increase day by day.
Here is query plan :
QUERY PLAN FOR STATEMENT 1 (at line 1).
STEP 1
The type of query is EXECUTE.
Executing a newly cached statement (SSQL_ID = 230588804).
QUERY PLAN FOR STATEMENT 1 (at line 0).
STEP 1
The type of query is DECLARE.
QUERY PLAN FOR STATEMENT 2 (at line 1).
Optimized using Serial Mode
STEP 1
The type of query is SELECT.
10 operator(s) under root
|ROOT:EMIT Operator (VA = 10)
|
| |RESTRICT Operator (VA = 9)(0)(0)(0)(0)(9)
| |
| | |SEQUENCER Operator (VA = 8) has 2 children.
| | |
| | | |SCALAR AGGREGATE Operator (VA = 1)
| | | | Evaluate Ungrouped ONCE AGGREGATE.
| | | |
| | | | |SCAN Operator (VA = 0)
| | | | | FROM TABLE
| | | | | tb_jpachi_cycle
| | | | | Table Scan.
| | | | | Forward Scan.
| | | | | Positioning at start of table.
| | | | | Using I/O Size 2 Kbytes for data pages.
| | | | | With LRU Buffer Replacement Strategy for data pages.
| | |
| | | |SQFILTER Operator (VA = 7) has 2 children.
| | | |
| | | | |RESTRICT Operator (VA = 3)(0)(0)(0)(6)(0)
| | | | |
| | | | | |SCAN Operator (VA = 2)
| | | | | | FROM TABLE
| | | | | | tprt_queue
| | | | | | Using Clustered Index.
| | | | | | Index : pk_tprt_queue
| | | | | | Forward Scan.
| | | | | | Positioning at index start.
| | | | | | Using I/O Size 16 Kbytes for index leaf pages.
| | | | | | With LRU Buffer Replacement Strategy for index leaf pages.
| | | | | | Using I/O Size 16 Kbytes for data pages.
| | | | | | With LRU Buffer Replacement Strategy for data pages.
| | | |
| | | | Run subquery 1 (at nesting level 1).
| | | |
| | | | QUERY PLAN FOR SUBQUERY 1 (at nesting level 1 and at line 2).
| | | |
| | | | Correlated Subquery.
| | | | Subquery under an IN predicate.
| | | |
| | | | |SCALAR AGGREGATE Operator (VA = 6)
| | | | | Evaluate Ungrouped ANY AGGREGATE.
| | | | | Scanning only up to the first qualifying row.
| | | | |
| | | | | |RESTRICT Operator (VA = 5)(9)(0)(0)(15)(0)
| | | | | |
| | | | | | |SCAN Operator (VA = 4)
| | | | | | | FROM TABLE
| | | | | | | tb_jpachi_filesprocess
| | | | | | | Table Scan.
| | | | | | | Forward Scan.
| | | | | | | Positioning at start of table.
| | | | | | | Using I/O Size 16 Kbytes for data pages.
| | | | | | | With LRU Buffer Replacement Strategy for data pages.
| | | |
| | | | END OF QUERY PLAN FOR SUBQUERY 1.

How to place NULLs last in ascending order

I need to sort a table and I need to display the rows that include Nulls at the bottom. Whenever I run the below query
select * from t1
order by status, date;
Nulls show up in the first row which I don't want:
+--------+------------+--+
| Status | Date | |
+--------+------------+--+
| 1 | NULL | |
| 1 | 2011-12-01 | |
| 1 | 2011-12-21 | |
| 2 | NULL | |
| 2 | 2005-09-02 | |
| 3 | 2000-08-07 | |
| | | |
+--------+------------+--+
This is what I need:
+--------+------------+--+
| Status | Date | |
+--------+------------+--+
| 1 | 2011-12-01 | |
| 1 | 2011-12-21 | |
| 1 | NULL | |
| 2 | 2005-09-02 | |
| 2 | NULL | |
| 3 | 2000-08-07 | |
| | | |
+--------+------------+--+
How can I do it?
select * from t1
order by status,
date,
CASE WHEN date is NULL
THEN 1
ELSE 0
END;
Would this work: order by col asc nulls last?

Need to update "orderby" column

I have a table test
+----+--+------+--+--+----------+--+--------------+
| ID | | Name | | | orderby | | processgroup |
+----+--+------+--+--+----------+--+--------------+
| 1 | | ABC | | | 10 | | 1 |
| 10 | | DEF | | | 12 | | 1 |
| 15 | | LMN | | | 1 | | 1 |
| 44 | | JKL | | | 4 | | 1 |
| 42 | | XYZ | | | 3 | | 2 |
+----+--+------+--+--+----------+--+--------------+
I want to update the orderby column in the sequence, I am expecting output like
+----+--+------+--+--+----------+--+--------------+
| ID | | Name | | | orderby | | processgroup |
+----+--+------+--+--+----------+--+--------------+
| 1 | | ABC | | | 1 | | 1 |
| 10 | | DEF | | | 2 | | 1 |
| 15 | | LMN | | | 3 | | 1 |
| 44 | | JKL | | | 4 | | 1 |
| 42 | | XYZ | | | 5 | | 1 |
+----+--+------+--+--+----------+--+--------------+
Logic behind this is when we have procesgroup as 1, orderby column should update as 1,2,3,4 and when procesgroup is 2 then update orderby as 5.
This might help you
;WITH CTE AS (
SELECT ROW_NUMBER() OVER (ORDER BY processgroup, ID ) AS SNO, ID FROM TABLE1
)
UPDATE TABLE1 SET TABLE1.orderby= CTE.SNO FROM CTE WHERE TABLE1.ID = CTE.ID

How to get call info from Kamailio

I have setup a Kamailio server and am able to establish calls. I need a way to get call related information like from, to, duration,etc. I have enabled the dialog module in the config but no avail. I am not well versed with config files and I am not sure if I am doing something wrong in the config file.
You need to Modify the config file to log the call related information in kamailio database tables.Here's the link
You have to uncomment the lines in the config file those add columns to database tables.
In addition to this,a web interface siremis for monitoring server can also be installed
It's impossible to blindly know if config is good or bad. However, as general advise, be sure you use dlg_manage() before relaying the INVITE and the other SIP requests related to calls.
For troubleshooting, you can list active dialogs with 'kamctl mi dlg_list' to see if they are correctly tracked or not.
since the link you mentioned is no longer working, here is my suggestion. To get Call information you can best use CDRs , which can be done in 2 ways
set acc module CDR or
get dialog variable and send to external CDR processor.
If you want to obtain further more details about dialogs , its routes , scokets , tiemouts etc then use
dialog DB storage , which looks like
+------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| hash_entry | int(10) unsigned | NO | MUL | NULL | |
| hash_id | int(10) unsigned | NO | | NULL | |
| callid | varchar(255) | NO | | NULL | |
| from_uri | varchar(128) | NO | | NULL | |
| from_tag | varchar(64) | NO | | NULL | |
| to_uri | varchar(128) | NO | | NULL | |
| to_tag | varchar(64) | NO | | NULL | |
| caller_cseq | varchar(20) | NO | | NULL | |
| callee_cseq | varchar(20) | NO | | NULL | |
| caller_route_set | varchar(512) | YES | | NULL | |
| callee_route_set | varchar(512) | YES | | NULL | |
| caller_contact | varchar(128) | NO | | NULL | |
| callee_contact | varchar(128) | NO | | NULL | |
| caller_sock | varchar(64) | NO | | NULL | |
| callee_sock | varchar(64) | NO | | NULL | |
| state | int(10) unsigned | NO | | NULL | |
| start_time | int(10) unsigned | NO | | NULL | |
| timeout | int(10) unsigned | NO | | 0 | |
| sflags | int(10) unsigned | NO | | 0 | |
| iflags | int(10) unsigned | NO | | 0 | |
| toroute_name | varchar(32) | YES | | NULL | |
| req_uri | varchar(128) | NO | | NULL | |
| xdata | varchar(512) | YES | | NULL | |
+------------------+------------------+------+-----+---------+----------------+

Better data-structure design

Currently in my application I have a single table that is giving me a bit of trouble. The issue at hand is I have a value object that is mapped to this table. When the data is returned to me as an array of value objects, I have to then loop through this array and begin my recursion by matching the ParentID to parent ObjectID's.
The column ParentID is either null (acts a parent) or it holds the value of an ObjectID.
I know there has to be a better way to create this data structure so that I do not have to do recursive loops to match ParentID's with their ObjectID's.
Any help with this is greatly appreciated.
Here is the table in describe form:
+----------------+------------------+------+-----+---------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+------------------+------+-----+---------------------+-----------------------------+
| ObjectID | int(11) unsigned | NO | PRI | NULL | auto_increment |
| ObjectHeight | decimal(6,2) | NO | | NULL | |
| ObjectWidth | decimal(6,2) | NO | | NULL | |
| ObjectX | decimal(6,2) | NO | | NULL | |
| ObjectY | decimal(6,2) | NO | | NULL | |
| ObjectLabel | varchar(255) | NO | | NULL | |
| TemplateID | int(11) unsigned | NO | MUL | NULL | |
| ObjectTypeID | int(11) unsigned | NO | MUL | NULL | |
| ParentID | int(11) unsigned | YES | MUL | NULL | |
| CreationDate | datetime | YES | | 0000-00-00 00:00:00 | |
| LastModifyDate | timestamp | YES | | NULL | on update CURRENT_TIMESTAMP |
+----------------+------------------+------+-----+---------------------+-----------------------------+e
You could use a nested set model. See the very good explanation here: http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

Resources