our $db_password = "nms";
our $zyxel_password = "removed";
+our $telnet_timeout = 15;
1;
use strict;
use warnings;
use DBI;
+use Net::Telnet;
package nms;
BEGIN {
return $dbh;
}
+sub switch_connect($) {
+ my ($ip) = @_;
+
+# Dump_Log => '/tmp/dumplog-queue',
+ my $conn = new Net::Telnet( Timeout => $nms::config::telnet_timeout,
+ Errmode => 'return',
+ Prompt => '/(es3024|e\d+\-\dsw)>/i');
+ my $ret = $conn->open( Host => $ip);
+ if (!$ret || $ret != 1) {
+ return (undef);
+ }
+ # XXX: Just send the password as text, I did not figure out how to
+ # handle authentication with only password through $conn->login().
+ #$conn->login(»·Prompt => '/password[: ]*$/i',
+ # Name => $password,
+ # Password => $password);
+ $conn->cmd($nms::config::zyxel_password);
+ # Get rid of banner
+ $conn->get;
+ return ($conn);
+}
+
1;
#!/usr/bin/perl
-use lib '../include';
-use nms;
-
-# Seconds to wait for connection
-my $timeout = 15;
-
-
use warnings;
use strict;
-use Switch;
use CGI;
-use Net::Telnet;
use DBI;
use Data::Dumper;
+use lib '../include';
+use nms;
# Grab from .htaccess-authentication
my $user = $ENV{'REMOTE_USER'};
return @lines;
}
-sub switch_connect($) {
- my ($ip) = @_;
-
- my $conn = new Net::Telnet( Timeout => $timeout,
- Errmode => 'return',
- Prompt => '/(es3024|e\d+\-\dsw)>/i');
- my $ret = $conn->open( Host => $ip);
- if (!$ret || $ret != 1) {
- return (0);
- }
- # XXX: Just send the password as text, I did not figure out how to
- # handle authentication with only password through $conn->login().
- #$conn->login( Prompt => '/password[: ]*$/i',
- # Name => $password,
- # Password => $password);
- $conn->cmd($nms::config::zyxel_password);
- # Get rid of banner
- $conn->get;
- return ($conn);
-}
-
sub parse_range($) {
my $switches = $_;
my @range;
#!/usr/bin/perl
-#
-#
-
use warnings;
use strict;
-use Net::Telnet;
+use lib '../include';
use POSIX;
-my $timeout = 15;
my $delaytime = 30;
my $poll_frequency = 60;
return @lines;
}
-sub switch_connect($) {
- my ($ip) = @_;
-
-# Dump_Log => '/tmp/dumplog-queue',
- my $conn = new Net::Telnet( Timeout => $timeout,
- Errmode => 'return',
- Prompt => '/(es3024|e\d+\-\dsw)>/i');
- my $ret = $conn->open( Host => $ip);
- if (!$ret || $ret != 1) {
- return (undef);
- }
- # XXX: Just send the password as text, I did not figure out how to
- # handle authentication with only password through $conn->login().
- #$conn->login(»·Prompt => '/password[: ]*$/i',
- # Name => $password,
- # Password => $password);
- $conn->cmd($nms::config::zyxel_password);
- # Get rid of banner
- $conn->get;
- return ($conn);
-}
-
sub mylog {
my $msg = shift;
my $time = POSIX::ctime(time);
"./ssendfile.pl addr configfile\n");
}
-my $conn = switch_connect($ARGV[0]);
+my $conn = nms::switch_connect($ARGV[0]);
if (!defined($conn)) {
die("Could not connect to switch.\n");
}
# print "New ip: $1\n";
# $conn->cmd( String => $cmd,
# Timeout => 3);
-# $conn = switch_connect($1);
+# $conn = nms::switch_connect($1);
# if (!defined($conn)) {
# die "Could not connect to new ip: $1\n";
# }
use lib '../include';
use nms;
-# Seconds to wait for connection
-my $timeout = 15;
-
use warnings;
use strict;
use Switch;
use CGI;
-use Net::Telnet;
use DBI;
# Grab from .htaccess-authentication
#use BER;
use Data::Dumper;
use DBI;
-use Net::Telnet;
use POSIX;
use Time::HiRes;
use lib '../include';
use warnings;
# Tweak timeouit og sjekk med :support||:net hva passord vil bli
-my $timeout = 25;
my $location = 'skipet';
my $dbh = nms::db_connect();
my $ip = $switch->{'ip'};
my $start = [Time::HiRes::gettimeofday];
eval {
- my $conn = switch_connect($ip);
+ my $conn = nms::switch_connect($ip);
if (!defined($conn)) {
print "Could not connect to switch ".$switch->{'switch'}."\n";
}
return @lines;
}
-sub switch_connect {
- my ($ip) = @_;
-
- my $conn = new Net::Telnet( Timeout => $timeout,
- Dump_Log => '/tmp/dumplog',
- Errmode => 'return',
- Prompt => '/(es3024|e\d+\-\dsw)>/i');
- my $ret = $conn->open( Host => $ip);
- if (!$ret || $ret != 1) {
- return (0);
- }
- # XXX: Just send the password as text, I did not figure out how to
- # handle authentication with only password through $conn->login().
- #$conn->login( Prompt => '/password[: ]*$/i',
- # Name => $password,
- # Password => $password);
- my @data = $conn->cmd($nms::config::zyxel_password);
- # Get rid of banner
- $conn->get;
- return ($conn);
-}
-
-
sub mylog {
my $msg = shift;
my $time = POSIX::ctime(time);