NumminorihSF / ami-io

Use node.js or io.js to manage Asterisk through AMI
MIT License
30 stars 16 forks source link

AmiIo.Action.Queues() is faild #1

Closed Seafnox closed 9 years ago

Seafnox commented 9 years ago

Code: client.on('connected', function(){ client.logger.info('Connected'); client.send(new AmiIo.Action.Queues(), function(err, data){ if (err){ //in current time - may be without error. need test //err === null if ami response match(/success/i), else response will pass as error } client.logger.info('response:', err, data); }); });

Console: Send: { variables: {}, id: 2, ActionID: 2, Action: 'Queues' } Data: QUEUE1 has 0 calls (max unlimited) in 'ringall' strategy (2s holdtime, 4s talktime), W:0, C:2, A:3, SL:100.0% within 60s Members: 111 (Local/222@from-internal/n from Local/111@from-internal/n) with penalty 2 (ringinuse disabled) (realtime) (paused) (Not in use) has taken no calls yet 222 (Local/111@from-internal/n from Local/222@from-internal/n) with penalty 3 (ringinuse disabled) (realtime) (Not in use) has taken 2 calls (last was 14 secs ago) No Callers

QUEUE2 has 0 calls (max unlimited) in 'ringall' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s No Members No Callers

Message:QUEUE1 has 0 calls (max unlimited) in 'ringall' strategy (2s holdtime, 4s talktime), W:0, C:2, A:3, SL:100.0% within 60s Members: 111 (Local/222@from-internal/n from Local/111@from-internal/n) with penalty 2 (ringinuse disabled) (realtime) (paused) (Not in use) has taken no calls yet 222 (Local/111@from-internal/n from Local/222@from-internal/n) with penalty 3 (ringinuse disabled) (realtime) (Not in use) has taken 2 calls (last was 14 secs ago) No Callers Unexpected: << QUEUE1 has 0 calls (max unlimited) in 'ringall' strategy (2s holdtime, 4s talktime), W:0, C:2, A:3, SL:100.0% within 60s Members: 111 (Local/222@from-internal/n from Local/111@from-internal/n) with penalty 2 (ringinuse disabled) (realtime) (paused) (Not in use) has taken no calls yet 222 (Local/111@from-internal/n from Local/222@from-internal/n) with penalty 3 (ringinuse disabled) (realtime) (Not in use) has taken 2 calls (last was 14 secs ago) No Callers >> Message: QUEUE2 has 0 calls (max unlimited) in 'ringall' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s No Members No Callers Unexpected: << QUEUE2 has 0 calls (max unlimited) in 'ringall' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s No Members No Callers >>

NumminorihSF commented 9 years ago

Hello. Sorry for this bug, AMI surprise me with this nonstandard messages. Check version 0.1.10. I checked it with our asterisk, seems it's ok. But I think it would better if you would use QueueSummary and QueueStatus. This actions are formatted by AMI to standard messages, but Queues is not.

Seafnox commented 9 years ago

{ variables: {}, event: 'Queues', queue: 'QUEUE1', members: '202 (Local/202@from-internal/n from Local/202@from-internal/n);201 (Local/201@from-internal/n from Local/201@from-internal/n)', strategy: 'ringall', calls: '0', callers: '', weight: '0', callsanswered: '2', holdtime: '2', talktime: '4', callsabandoned: '3', servicelevel: '100.0% within 60s', actionid: '2', incomingData: [Object] },

Such a bad parsing servicelevel must be splitted.

memberRegExp = "^([0-9_-]+) [\(]([A-Za-z0-9]+[\/][A-Za-z0-9_-]+@.+) from ([^\)\(]+)[\)]( with penalty ([0-9]+))?" +
                    " [\(]ringinuse ([^\)\(]+)[\)]" +
                    "( [\(]([^\)\(]+)[\)])?" + "( [\(]([^\)\(]+)[\)])?" + "( [\(]([^\)\(]+)[\)])?" + "( [\(]([^\)\(]+)[\)])?" + "( [\(]([^\)\(]+)[\)])?" +
                    " has taken (no calls yet|[0-9]+ calls)+( [\(]last was ([0-9]+))?";
Seafnox commented 9 years ago

it's only way to get list of members for each queue on server, "Agents" don't work on my server

NumminorihSF commented 9 years ago

If service level would be splitted, then it will be another field in object, because time should not be constant on every queue (I splitted it to servicelevel and servicelevelperf). We doesn't use Agents. Your regexp doesn't work at my server because Queues command for me returns members in format like

memberName (sip/520) with penalty 1 (dynamic) (Unavailable) has taken no calls yet
or
memberName (sip/605) with penalty 1 (dynamic) (paused) (Not in use) has taken 59 calls (last was 555 secs ago)
or
SIP/300 with penalty 1 (Not in use) has taken 455 calls (last was 3329 secs ago)

That transforms to

membername1 (location1);membername2 (location2);...

Unfortunately, your AMI returns it in another format. And some AMI can returns it in third format. So the only way to returns members for every AMI is returning joined strings (like 'memberName (sip/520) with penalty 1 (dynamic) (Unavailable) has taken no calls yet') without formatting.

So better way will be use QueueStatus action. QueueStatus returning status of every queue and members of this queue with them statuses, so it really returns same data, but in AMI format. There are 2 types of messages:

//first
event: 'QueueStatus',
queue: 'q9',
members: 'crym2$666 (sip/656)',
strategy: 'rrmemory',
calls: '0',
callers: '',
weight: '0',
callsanswered: '22',
holdtime: '119',
talktime: '236',
callsabandoned: '13',
servicelevel: '60',
servicelevelperf: '72.7',
actionid: '2',

//second
event: 'QueueMember',
queue: 'q8',
name: 'SIP/300',
location: 'SIP/300',
membership: 'static',
penalty: '1',
callstaken: '455',
lastcall: '1432892520',
status: '1',
paused: '0',
actionid: '2',
Seafnox commented 9 years ago

It don't work in another plugin too :D TNX