diff options
Diffstat (limited to 'clients')
-rwxr-xr-x | clients/ping.pl | 4 | ||||
-rwxr-xr-x | clients/portnames.pl | 2 | ||||
-rwxr-xr-x | clients/smanagrun.pl | 65 | ||||
-rwxr-xr-x | clients/snmpfetch.pl | 12 |
4 files changed, 47 insertions, 36 deletions
diff --git a/clients/ping.pl b/clients/ping.pl index b41febd..3bbdd8a 100755 --- a/clients/ping.pl +++ b/clients/ping.pl @@ -36,6 +36,7 @@ while (1) { $ping->host_add($secondary_ip); $secondary_ip_to_switch{$secondary_ip} = $switch; } + print "ip: $ip\n"; } my $result = $ping->ping(); die $ping->get_error if (!defined($result)); @@ -61,7 +62,7 @@ while (1) { $dbh->pg_putcopyend(); $dbh->commit; - + if (0) { # ping linknets $ping = Net::Oping->new; $ping->timeout(0.2); @@ -86,6 +87,7 @@ while (1) { $dbh->pg_putcopyend(); $dbh->commit; + } sleep 1; } diff --git a/clients/portnames.pl b/clients/portnames.pl index 2b29189..52e433a 100755 --- a/clients/portnames.pl +++ b/clients/portnames.pl @@ -2,7 +2,7 @@ my ($host,$switchtype,$community) = @ARGV; -open SNMP, "snmpwalk -Os -c $community -v 2c $host ifDescr |" +open SNMP, "snmpwalk -Os -c $community -v 2c $host -mALL ifDescr |" or die "snmpwalk: $!"; print "begin;\n"; diff --git a/clients/smanagrun.pl b/clients/smanagrun.pl index 0546901..9f8efab 100755 --- a/clients/smanagrun.pl +++ b/clients/smanagrun.pl @@ -90,38 +90,43 @@ while (1) { } mylog("Connecting to $switch->{sysname} on $switch->{addr}"); - my $conn = switch_connect($switch->{addr}); - if (!defined($conn)) { - mylog("Could not connect to ".$switch->{sysname}."(".$switch->{addr}.")"); - $sdelay->execute("Could not connect to switch, delaying...", $switch->{sysname}); - $sunlock->execute($switch->{sysname}); - $dbh->commit(); - next; - } - my $error; - $error = $sgetallpoll->execute($switch->{sysname}); - if (!$error) { - print "Could not execute sgetallpoll\n".$dbh->errstr(); - $conn->close; - next; - } - while (my $row = $sgetallpoll->fetchrow_hashref()) { - print "sysname: ".$row->{sysname}." cmd: ".$row->{cmd}."\n"; - my @data; - my @commands = split(/[\r\n\000]+/, $row->{cmd}); - for my $cmd (@commands) { - next unless $cmd =~ /\S/; # ignorer linjer med kun whitespace - push @data, "# $cmd"; - if ($cmd =~ s/^!//) { - push @data, switch_exec($cmd, $conn, 1); - } else { - push @data, switch_exec($cmd, $conn); + eval { + #my $conn = switch_connect($switch->{addr}); + my $telnet = switch_connect_ssh($switch->{addr}); + my $conn = $telnet->{telnet}; + if (!defined($conn)) { + mylog("Could not connect to ".$switch->{sysname}."(".$switch->{addr}.")"); + $sdelay->execute("Could not connect to switch, delaying...", $switch->{sysname}); + $sunlock->execute($switch->{sysname}); + $dbh->commit(); + next; + } + my $error; + $error = $sgetallpoll->execute($switch->{sysname}); + if (!$error) { + print "Could not execute sgetallpoll\n".$dbh->errstr(); + $conn->close; + next; + } + while (my $row = $sgetallpoll->fetchrow_hashref()) { + print "sysname: ".$row->{sysname}." cmd: ".$row->{cmd}."\n"; + my @data; + my @commands = split(/[\r\n\000]+/, $row->{cmd}); + for my $cmd (@commands) { + next unless $cmd =~ /\S/; # ignorer linjer med kun whitespace + push @data, "# $cmd"; + if ($cmd =~ s/^!//) { + push @data, switch_exec($cmd, $conn, 1); + } else { + push @data, switch_exec($cmd, $conn); + } } + my $result = join("\n", @data); + $sresult->execute($result, $row->{id}); } - my $result = join("\n", @data); - $sresult->execute($result, $row->{id}); + $conn->close(); + waitpid($telnet->{pid}, 0); + $sunlock->execute($switch->{sysname}); } - $conn->close(); - $sunlock->execute($switch->{sysname}); } diff --git a/clients/snmpfetch.pl b/clients/snmpfetch.pl index 968ace8..d696fc9 100755 --- a/clients/snmpfetch.pl +++ b/clients/snmpfetch.pl @@ -144,8 +144,8 @@ sub poll_loop { for my $port (@ports) { my @vars = (); - push @vars, ["ifHCInOctets", $port]; - push @vars, ["ifHCOutOctets", $port]; + push @vars, ["ifInOctets", $port]; + push @vars, ["ifOutOctets", $port]; push @vars, ["ifInErrors", $port]; push @vars, ["ifOutErrors", $port]; my $varlist = SNMP::VarList->new(@vars); @@ -193,9 +193,9 @@ sub callback { if ($port != $var->[1]) { die "Response for unknown OID $var->[0].$var->[1] (expected port $port)"; } - if ($var->[0] eq 'ifHCInOctets') { + if ($var->[0] eq 'ifInOctets') { $in = $var->[2]; - } elsif ($var->[0] eq 'ifHCOutOctets') { + } elsif ($var->[0] eq 'ifOutOctets') { $out = $var->[2]; } elsif ($var->[0] eq 'ifInErrors') { $ine = $var->[2]; @@ -212,17 +212,21 @@ sub callback { warn $switch->{'sysname'}.":$port: failed reading in"; } $ok = 0; + warn "no in"; } if (!defined($out) || $out !~ /^\d+$/) { if (defined($oute)) { warn $switch->{'sysname'}.":$port: failed reading in"; } $ok = 0; + warn "no out"; } if ($ok) { $qpoll->execute($switch->{'switch'}, $port, $in, $out, $ine, $oute) || die "%s:%s: %s\n", $switch->{'switch'}, $port, $in; $dbh->commit; + } else { + warn $switch->{'sysname'} . " failed to OK."; } if (++$switch->{'num_done'} == $switch->{'num_ports'}) { |