return ($conn);
}
+# Send a command to switch and return the data recvied from the switch
+sub switch_exec($$) {
+ my ($cmd, $conn) = @_;
+
+ # Send the command and get data from switch
+ my @data = $conn->cmd($cmd);
+ my @lines = ();
+ foreach my $line (@data) {
+ # Remove escape-7 sequence
+ $line =~ s/\x1b\x37//g;
+ push (@lines, $line);
+ }
+
+ return @lines;
+}
+
1;
or die "Could not prepare sgetip";
my $sgid = $dbh->prepare("SELECT nextval('squeue_group_sequence') as gid");
-# Send a command to switch and return the data recvied from the switch
-sub switch_exec($$) {
- my ($cmd, $conn) = @_;
-
- # Send the command and get data from switch
- my @data = $conn->cmd($cmd);
- my @lines = ();
- foreach my $line (@data) {
- # Remove escape-7 sequence
- $line =~ s/\x1b\x37//g;
- push (@lines, $line);
- }
-
- return @lines;
-}
-
sub parse_range($) {
my $switches = $_;
my @range;
my $delaytime = 30;
my $poll_frequency = 60;
-# Send a command to switch and return the data recvied from the switch
-sub switch_exec($$) {
- my ($cmd, $conn) = @_;
-
- # Send the command and get data from switch
- my @data = $conn->cmd($cmd);
- my @lines = ();
- foreach my $line (@data) {
- # Remove escape-7 sequence
- $line =~ s/\x1b\x37//g;
- push (@lines, $line);
- }
-
- return @lines;
-}
-
sub mylog {
my $msg = shift;
my $time = POSIX::ctime(time);
# }
# }
# else {
- my @data = switch_exec($cmd, $conn);
+ my @data = nms::switch_exec($cmd, $conn);
foreach my $line (@data) {
$line =~ s/[\r\n]+//g;
print "$line\n";
if (!defined($conn)) {
print "Could not connect to switch ".$switch->{'switch'}."\n";
}
- my @data = switch_exec('sys monitor status', $conn);
+ my @data = nms::switch_exec('sys monitor status', $conn);
my @fields = split(/\s+/, $data[2]);
# The temp fields are 6, 7, 8
my $avgtemp = ($fields[6] + $fields[7] + $fields[8]) / 3;
$dbh->commit;
}
-sub switch_exec {
- my ($cmd, $conn) = @_;
-
- # Send the command and get data from switch
- my @data = $conn->cmd($cmd);
- my @lines = ();
- foreach my $line (@data) {
- # Remove escape-7 sequence
- $line =~ s/\x1b\x37//g;
- push (@lines, $line);
- }
-
- return @lines;
-}
-
sub mylog {
my $msg = shift;
my $time = POSIX::ctime(time);