# 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;
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";
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";
$ios->close();
+ return 1;
}
## Collect switch ips
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;
<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) = ();