Updated telnet login process to work with newer Asterisk versions in send-action-child, output, phone bin scripts
git-svn-id: svn://192.168.202.10@2960 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_output_update.pl version 2.12
|
||||
# AST_output_update.pl version 2.14
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# populates "show peers" output for SIP and IAX as well as tail of last 1000 lines of Asterisk output into database
|
||||
#
|
||||
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2018 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# 151229-1548 - first build
|
||||
# 180403-1546 - Updated telnet login process to work with newer Asterisk versions
|
||||
#
|
||||
|
||||
# constants
|
||||
@@ -175,16 +176,28 @@ if($DB){print "\n\nSIP SHOW PEERS:\n";}
|
||||
|
||||
### connect to asterisk manager through telnet
|
||||
$t = new Net::Telnet (Port => 5038,
|
||||
Prompt => '/.*[\$%#>] $/',
|
||||
Prompt => '/\r\n/',
|
||||
Output_record_separator => '',);
|
||||
#$fh = $t->dump_log("$telnetlog"); # uncomment for telnet log
|
||||
|
||||
##### uncomment both lines below for telnet log
|
||||
# $LItelnetlog = "$PATHlogs/output_telnet_log.txt";
|
||||
# $fh = $t->dump_log("$LItelnetlog");
|
||||
|
||||
if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;}
|
||||
else {$telnet_login = $ASTmgrUSERNAME;}
|
||||
|
||||
$t->open("$telnet_host");
|
||||
$t->waitfor('/[0123]\n$/'); # print login
|
||||
$t->waitfor('/Asterisk Call Manager\//');
|
||||
|
||||
# get the AMI version number
|
||||
$ami_version = $t->getline(Errmode => Return, Timeout => 1,);
|
||||
$ami_version =~ s/\n//gi;
|
||||
if ($DB) {print "----- AMI Version $ami_version -----\n";}
|
||||
|
||||
# Login
|
||||
$t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
|
||||
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
|
||||
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
|
||||
|
||||
$t->buffer_empty;
|
||||
|
||||
$sip_show_peers='';
|
||||
@list_channels=@MT;
|
||||
|
||||
+37
-12
@@ -1,17 +1,18 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_phone_update.pl version 2.12
|
||||
# AST_phone_update.pl version 2.14
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# checks the registered IP address of the phone and updates the phones table
|
||||
#
|
||||
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2018 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# 70521-1529 - first build
|
||||
# 100625-1220 - Added waitfors after logout to fix broken pipe errors in asterisk <MikeC>
|
||||
# 130625-0947 - Added --agent-lookup option for agent phone_ip population
|
||||
# 131210-1305 - Added Asterisk 1.8 compatibility
|
||||
# 150610-1200 - Added support for AMI version 1.3
|
||||
# 180403-1545 - Updated telnet login process to work with newer Asterisk versions
|
||||
#
|
||||
|
||||
# constants
|
||||
@@ -216,16 +217,28 @@ if ( ($sip_count > 0) || ($agent_lookup < 1) )
|
||||
|
||||
### connect to asterisk manager through telnet
|
||||
$t = new Net::Telnet (Port => 5038,
|
||||
Prompt => '/.*[\$%#>] $/',
|
||||
Prompt => '/\r\n/',
|
||||
Output_record_separator => '',);
|
||||
#$fh = $t->dump_log("$telnetlog"); # uncomment for telnet log
|
||||
|
||||
##### uncomment both lines below for telnet log
|
||||
# $LItelnetlog = "$PATHlogs/phone_telnet_log.txt";
|
||||
# $fh = $t->dump_log("$LItelnetlog");
|
||||
|
||||
if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;}
|
||||
else {$telnet_login = $ASTmgrUSERNAME;}
|
||||
|
||||
$t->open("$telnet_host");
|
||||
$t->waitfor('/[0123]\n$/'); # print login
|
||||
$t->waitfor('/Asterisk Call Manager\//');
|
||||
|
||||
# get the AMI version number
|
||||
$ami_version = $t->getline(Errmode => Return, Timeout => 1,);
|
||||
$ami_version =~ s/\n//gi;
|
||||
if ($DB) {print "----- AMI Version $ami_version -----\n";}
|
||||
|
||||
# Login
|
||||
$t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
|
||||
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
|
||||
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
|
||||
|
||||
$t->buffer_empty;
|
||||
|
||||
$i=0;
|
||||
foreach(@PTextensions)
|
||||
@@ -344,16 +357,28 @@ if ( ($iax_count > 0) || ($agent_lookup < 1) )
|
||||
|
||||
### connect to asterisk manager through telnet
|
||||
$t = new Net::Telnet (Port => 5038,
|
||||
Prompt => '/.*[\$%#>] $/',
|
||||
Prompt => '/\r\n/',
|
||||
Output_record_separator => '',);
|
||||
#$fh = $t->dump_log("$telnetlog"); # uncomment for telnet log
|
||||
|
||||
##### uncomment both lines below for telnet log
|
||||
# $LItelnetlog = "$PATHlogs/phone_telnet_log.txt";
|
||||
# $fh = $t->dump_log("$LItelnetlog");
|
||||
|
||||
if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;}
|
||||
else {$telnet_login = $ASTmgrUSERNAME;}
|
||||
|
||||
$t->open("$telnet_host");
|
||||
$t->waitfor('/[0123]\n$/'); # print login
|
||||
$t->waitfor('/Asterisk Call Manager\//');
|
||||
|
||||
# get the AMI version number
|
||||
$ami_version = $t->getline(Errmode => Return, Timeout => 1,);
|
||||
$ami_version =~ s/\n//gi;
|
||||
if ($DB) {print "----- AMI Version $ami_version -----\n";}
|
||||
|
||||
# Login
|
||||
$t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
|
||||
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
|
||||
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
|
||||
|
||||
$t->buffer_empty;
|
||||
|
||||
$i=0;
|
||||
foreach(@PTextensions)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# AST_send_action_child.pl version 2.12
|
||||
# AST_send_action_child.pl version 2.14
|
||||
#
|
||||
# Part of the Asterisk Central Queue System (ACQS)
|
||||
#
|
||||
@@ -14,7 +14,7 @@
|
||||
# to be executed. connect to the manager interface, send the action and logoff
|
||||
# then exit.
|
||||
#
|
||||
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2018 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# CHANGES
|
||||
# 50810-1547 - Added database server variable definitions lookup
|
||||
@@ -32,6 +32,7 @@
|
||||
# 100625-1206 - Use strict is a performance hit and should only be uncommented for debugging <MikeC>
|
||||
# 130108-1714 - Changes for Asterisk 1.8 compatibility
|
||||
# 150610-1200 - Added support for AMI version 1.3
|
||||
# 180403-1544 - Updated telnet login process to work with newer Asterisk versions
|
||||
#
|
||||
|
||||
$|++;
|
||||
@@ -161,20 +162,27 @@ if ($action) {
|
||||
|
||||
### connect to asterisk manager through telnet
|
||||
my $tn = new Net::Telnet (Port => $telnet_port,
|
||||
Prompt => '/.*[\$%#>] $/',
|
||||
Prompt => '/\r\n/',
|
||||
Output_record_separator => '',
|
||||
Errmode => "return");
|
||||
#$fh = $tn->dump_log("$PATHlogs/SAC_telnet_log.txt"); # uncomment for telnet log
|
||||
my $telnet_login;
|
||||
if ($ASTmgrUSERNAMEsend) {
|
||||
$telnet_login = $ASTmgrUSERNAMEsend;
|
||||
} else {
|
||||
$telnet_login = $ASTmgrUSERNAME;
|
||||
}
|
||||
$tn->open($telnet_host);
|
||||
$tn->waitfor('/[0123]\n$/'); # print login
|
||||
|
||||
##### uncomment both lines below for telnet log
|
||||
# $LItelnetlog = "$PATHlogs/send_child_telnet_log.txt";
|
||||
# $fh = $tn->dump_log("$LItelnetlog");
|
||||
|
||||
if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;}
|
||||
else {$telnet_login = $ASTmgrUSERNAME;}
|
||||
$tn->open("$telnet_host");
|
||||
$tn->waitfor('/Asterisk Call Manager\//');
|
||||
|
||||
# get the AMI version number
|
||||
$ami_version = $tn->getline(Errmode => Return, Timeout => 1,);
|
||||
$ami_version =~ s/\n//gi;
|
||||
if ($DB) {print "----- AMI Version $ami_version -----\n";}
|
||||
|
||||
# Login
|
||||
$tn->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
|
||||
$tn->waitfor('/Authentication accepted/'); # waitfor auth accepted
|
||||
$tn->waitfor('/Authentication accepted/'); # waitfor auth accepted
|
||||
|
||||
$tn->buffer_empty;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user