Perl script to retrieve queue information

(Laurent Protti) #1


I need to migrate an old version of Freepbx (2.8.01). It used a perl script to retrieve queue status via AMI command queues and create a web page to display the result.

the command output was as such

402020 has 0 calls (max unlimited) in ‘ringall’ strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0%, SL2:0.0% within 60s


  Local/4039@from-queue/n (ringinuse enabled) (Not in use) has taken no calls yet

  Local/4042@from-queue/n (ringinuse enabled) (Not in use) has taken no calls yet

  Local/4077@from-queue/n (ringinuse enabled) (Not in use) has taken no calls yet

No Callers

and was interpreted in the perl script

Login and get our booty from Asterisk

$logres = send_cmd(“Action: Login${EOL}Username: $user${EOL}Secret: $secret$BLANK”);
#$qinfo = send_cmd(“Events: off”);
$qinfo = send_cmd(“Action: queues$BLANK$EOL”);
$logres = send_cmd(“Action: Logoff$BLANK”);
close $remote; # Close socket

Detection de queue sans membre

$qinfo =~ s/No Members/Members:\n Aucun membre ! \n/g;

my %qcalls = map { /(\S+)\s+has (\d+) calls.?\n/sg; } $qinfo;
my %qmax = map { /(\S+)\s+has \d+ calls (max (\S+)).
?\n/sg; } $qinfo;
my %qstrat = map { /(\S+)\s+has \d+ calls (max \S+) in (\S+) strategy.?\n/sg; } $qinfo;
my %qmems = map { /(\S+)\s+has \d+ calls.
?Members:.?\s{6}(.?)\s{3}\S*?\s*?Callers/sg; } $qinfo;
my %qcallers = map { /(\S+)\s+has \d+ calls.*?([No ]Callers.?)\n/sg; } $qinfo;

Now, the AMI command has changed (queuestatus) and the format is like this

Event: QueueParams
Queue: 278500
Max: 0
Strategy: ringall
Calls: 0
Holdtime: 3
TalkTime: 11
Completed: 24
Abandoned: 8
ServiceLevel: 60
ServicelevelPerf: 100.0
ServicelevelPerf2: 100.0
Weight: 0

Has anyone heard of an updated version of this perl script that would treat the received data correctly ?

I’m no perl developper so digging into this would mean lots of time and frustration on my side.

thanks and have a good day

(Simon Telephonics) #2

Please post your Perl script either in markdown code tags (use the ``` code block ``` format) or put it online somewhere (pastebin, github gist). The fix might be trivial, or if not, you could find a perl expert who could fix it up for you at a small cost.

(TheJames) #3

One major effort was to minimize the languages used in FreePBX. Most shell and perl scripts were moved to PHP. Some newer stuff is in javascript (njs)

I think the last perl was removed 3 or 4 releases ago.

(Simon Telephonics) #4

I misunderstood; thought OP had a custom script he was using and not a FreePBX component.

Isn’t there a present-day equivalent to that older perl script then?

(system) closed #5

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.