From 0ad6c333401520caccb37749f6f1ba22a789e83e Mon Sep 17 00:00:00 2001 From: root Date: Thu, 5 Apr 2007 18:25:43 +0200 Subject: [PATCH] Optomalize a bit more. --- clients/ciscong.pl | 13 +++++++++---- web/showswitch.pl | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/clients/ciscong.pl b/clients/ciscong.pl index 76ec475..068ff30 100644 --- a/clients/ciscong.pl +++ b/clients/ciscong.pl @@ -75,7 +75,7 @@ sub do_distro { # Prompt => '/[^\s\(]+(\([^\(]\)){0,1}[#>]/'); if (!defined($ios)) { print "Could not connect to $dip"; - return; + return 0; } $ios->login($nms::config::ios_user, $nms::config::ios_pass); $ios->enable; @@ -94,7 +94,7 @@ sub do_distro { if (ios_getroute($ios, "192.168.1.0") == 1) { print "Already routed up 192.168.1.0/24\n" ; - return; + return 0; } my $zyxeloldip = "192.168.1.1"; @@ -111,7 +111,7 @@ sub do_distro { print "Waiting for zyxel on $dip:$vlan timed out, wanted to set ip: $newip\n"; print LOG "Could not connect to $switchname\n"; stop_vlan($ios, $vlan); - return; + return 0; } last if $p->ping($zyxeloldip); print "pinging...\n"; @@ -130,6 +130,7 @@ sub do_distro { $ios->close(); + return 1; } ## Collect switch ips @@ -204,7 +205,11 @@ sub verify_run { while (1) { if ($counter > 4) { print "No answer from $dip:$vlan $ip, trying to route it up\n"; - do_distro($dip, $ip, $vlan, $switch); + my $ret = do_distro($dip, $ip, $vlan, $switch); + if ($ret == 0) { + # No answer from zyxel + last; + } my $pid = fork(); if ($pid == 0) { sleep 100; diff --git a/web/showswitch.pl b/web/showswitch.pl index 3be8769..72b1846 100755 --- a/web/showswitch.pl +++ b/web/showswitch.pl @@ -35,7 +35,7 @@ print <<"EOF";

Switch $switch ($ref->{'sysname'})

EOF -my $q = $dbh->prepare('select port,coalesce(description, \'Port \' || port) as description,extract(epoch from time) as time,bytes_in,bytes_out from polls natural join switches natural left join portnames where time between now() - \'1 day\'::interval and now() and switch=? order by switch,port,time;'); +my $q = $dbh->prepare('select port,coalesce(description, \'Port \' || port) as description,extract(epoch from time) as time,bytes_in,bytes_out from switches natural left join portnames natural join polls where time between now() - \'1 day\'::interval and now() and switch=? order by switch,port,time;'); $q->execute($switch); my (@totx, @toty1, @toty2) = (); -- 2.39.2