TP-Link ADSL Sync Rate Script

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
dylan6000
Posts: 4
Joined: Tue May 19, 2015 12:34 am

TP-Link ADSL Sync Rate Script

Post by dylan6000 »

HI,

I am hoping that some genius can assist me. I have a perl script that that i got from here (http://blog.nobiscuit.com/2012/09/16/gr ... ing-cacti/)
to log in to dsl modem and display the sync rates. If i manually telnet into the modem i can get the sync rate displayed, however when the perl script runs the output is blank. I am not very good with perl and am hoping someone here can assist.
Perl Script

Code: Select all

#!/usr/bin/perl

use Expect;

# Example sesion:
#
# $ telnet x
# Trying x...
# Connected to x.
# Escape character is '^]'.
# 
# Password: **********
# Copyright (c) 2001 - 2012 TP-LINK TECHNOLOGIES CO., LTD
# TP-LINK> wan adsl c
# near-end interleaved channel bit rate: 10313 kbps
# near-end fast channel bit rate: 0 kbps
# far-end interleaved channel bit rate: 1293 kbps
# far-end fast channel bit rate: 0 kbps
# TP-LINK> exit

$timeout = 20;
$host = $ARGV[0];
$login_pass = $ARGV[1];
$prompt="TP-LINK>";
$command="wan adsl c";
my $exp = Expect->spawn("telnet $host")
 or die "Cannot spawn $command: $!\n";
$exp->log_user(0);
$exp->expect($timeout, "Password:");
$exp->send("$login_pass\r");
$exp->expect($timeout, $prompt);
$exp->send("$command\r");
$exp->expect($timeout, $prompt);
$out = $exp->before();
@rates;
$x = 0;
while ($out =~ /(\d+)/g) {
    $rates[$x] = $1;
    $x++;
}
print "dir:$rates[0] dfr:$rates[1] uir:$rates[2] ufr:$rates[3]\n";
$exp->send("exit\r");
$exp->soft_close();
The result that displays on screen is
dir: dfr: uir: ufr:

Any assistance would be greatly appreciated.
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Re: TP-Link ADSL Sync Rate Script

Post by phalek »

Is this the same process/prompt/text for your device:

Code: Select all

# Example sesion:
#
# $ telnet x
# Trying x...
# Connected to x.
# Escape character is '^]'.
# 
# Password: **********
# Copyright (c) 2001 - 2012 TP-LINK TECHNOLOGIES CO., LTD
# TP-LINK> wan adsl c
# near-end interleaved channel bit rate: 10313 kbps
# near-end fast channel bit rate: 0 kbps
# far-end interleaved channel bit rate: 1293 kbps
# far-end fast channel bit rate: 0 kbps
# TP-LINK> exit
If not, then please provide an example for your device
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
dylan6000
Posts: 4
Joined: Tue May 19, 2015 12:34 am

Re: TP-Link ADSL Sync Rate Script

Post by dylan6000 »

Hi,

Prompt looks the same. See below for my exact process, in case you see something I don't.

Code: Select all

dylanc@monitoring:~$ telnet 192.168.1.1
Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.

Password: *****
Copyright (c) 2001 - 2014 TP-LINK TECHNOLOGIES CO., LTD.
TP-LINK> wan adsl c
near-end interleaved channel bit rate: 10239 kbps
near-end fast channel bit rate: 0 kbps
far-end interleaved channel bit rate: 1022 kbps
far-end fast channel bit rate: 0 kbps
TP-LINK> exit
Connection closed by foreign host.
dylanc@monitoring:~$
Hope this helps.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest