[quote=“dalenoll”]This script monitors for the autopause and sets a custom device state to make a BLF on the agent phone blink(RINGING) if they were paused. What you would need to do would be to wait the 20 seconds and sent the correct CLI unpause command.
I am not sure how the POE engine would handle simply waiting the 20 seconds if another event came in during that time, for instance if the second set also went unanswered. You may want to set a POE alarm that would fire at time() + 20 and then issue the CLI command.
I hope this helps.
[code]
#! /usr/bin/perl
use POE qw( Component::Client::Manager );
$|++;
initialize();
$poe_kernel->run();
END of MAIN CODE
#######################################
Subroutines and functions
#######################################
initialize
sub initialize {
setupDefaults();
readConfigFile();
connectAMI();
# setup an anon shutdown function
$SIG{INT} = sub {
exit 0;
};
# Catch SIGUSR1 to force an abnormal shutdown
$SIG{USR1} = sub {
exit 255;
};
}
setupDefaults
sub setupDefaults {
$Config{ConfigFile}="queuewatch.conf";
$Config{AMIHost}="localhost";
$Config{AMIUser}="amiuser";
$Config{AMIPass}="amipass";
}
readConfigFile
sub readConfigFile {
print "Reading configuration file ", $Config{ConfigFile}, "\n";
# Open the config file
open(CONFIG,"$Config{ConfigFile}") || return;
my $Section="GENERAL";
my $CurrentSign="";
while(<CONFIG>) {
chomp();
s/[#;].*$//;
next if /^$/;
#
# define the sections
if (m/^\[\s*General\s*\]/i) {
$Section="GENERAL";
$CurrentSign="";
next;
}
#
# General Options
if( $Section eq "GENERAL" ) {
$Config{AMIHost} = $1 if m/AMIhost\s*=\s*(.*)/i;
$Config{AMIUser} = $1 if m/AMIUser\s*=\s*(.*)/i;
$Config{AMIPass} = $1 if m/AMIPass\s*=\s*(.*)/i;
}
}
close(CONFIG);
return;
}
Connect to AMI port
sub connectAMI {
my $manager = POE::Component::Client::Manager->new(
Username => $Config{AMIUser},
Password => $Config{AMIPass},
Alias => ‘monitor’,
RemoteHost => $Config{AMIHost},
RemotePort => 5038, # default port
CallBacks => {
input => ‘:all’, # catchall for all manager events
autopause => {
‘Event’ => ‘QueueMemberPaused’,
‘Paused’ => ‘1’,
‘Reason’ => ‘Auto-Pause’,
},
},
inline_states => {
input => sub {
my $input = $[ARG0];
# good for figuring out what manager events look like
require Data::Dumper;
# print $input->{Channel}, " ", $Config{AMIMonitoredChannel}, “\n”;
# print Data::Dumper->Dump([$input]);
# print Data::Dumper->Dump([$input]) if $input->{Channel} =~ m~$Config{AMIMonitoredChannel}~;
},
autopause => sub {
my $event = $[ARG0];
my $heap = $_[HEAP];
print “Autopause: $event->{MemberName} Queue: $event->{Queue}\n”;
my ($tech, $data) = split(///,$event->{MemberName});
$heap->{server}->put({‘Action’ => ‘Command’,‘Command’ => “dialplan set global DEVICE_STATE(Custom:PAUSE$data) RINGING”});
},
},
);
if( !$manager) {
print STDERR “Did not connect to AMI\n”;
exit;
}
}
[/code][/quote]
Thanks for sharing the script. I will try it in my environment.
Thx.