]> git.sesse.net Git - nms/commitdiff
Optomalize a bit more.
authorroot <root@space>
Thu, 5 Apr 2007 16:25:43 +0000 (18:25 +0200)
committerroot <root@space>
Thu, 5 Apr 2007 16:25:43 +0000 (18:25 +0200)
clients/ciscong.pl
web/showswitch.pl

index 76ec4759102a2d9556f1352ec28bc68ec8230d46..068ff308e9c5ad7f3730f8c8595b8a5abd30a4e4 100644 (file)
@@ -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;
index 3be8769c34dafdd0127203a52756049fe20bf343..72b18462b10e3e07098e19c7224be381b5f94fa2 100755 (executable)
@@ -35,7 +35,7 @@ print <<"EOF";
     <h1>Switch $switch ($ref->{'sysname'})</h1>
 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) = ();