jablonka.czprosek.czf

switches

Subversion Repositories:
[/] [switches.cgi] - Diff between revs 27 and 30

Show entire file Ignore whitespace

Rev 27 Rev 30
Line 183... Line 183...
my $popis = ""; my $popis = "";
my $macinfo = ""; my $macinfo = "";
my $macip = ""; my $macip = "";
my $hip = ""; my $hip = "";
my @row = (); my @row = ();
my $dhcp2 = $dhcp;  
   
print "<b>$desc</b> <a href=http:\/\/$myip>$myip</a>"; print "<b>$desc</b> <a href=http:\/\/$myip>$myip</a>";
   
my $speedall = `$snmpwalk -Os -c $com -v $ver $myip .1.3.6.1.2.1.2.2.1.5`; # my $speedall = `$snmpwalk -Os -c $com -v $ver $myip .1.3.6.1.2.1.2.2.1.5`;
  my $speedall = `$snmpwalk -On -c $com -v $ver $myip .1.3.6.1.2.1.31.1.1.1.15`;
my $adminstatusall = `$snmpwalk -Os -c $com -v $ver $myip .1.3.6.1.2.1.2.2.1.7`; my $adminstatusall = `$snmpwalk -Os -c $com -v $ver $myip .1.3.6.1.2.1.2.2.1.7`;
my $operstatusall = `$snmpwalk -Os -c $com -v $ver $myip .1.3.6.1.2.1.2.2.1.8`; my $operstatusall = `$snmpwalk -Os -c $com -v $ver $myip .1.3.6.1.2.1.2.2.1.8`;
# my $mactable = `$snmpwalk -Os -c $com -v $ver $myip atPhysAddress`; my $mactable = `$snmpwalk -Os -c $com -v $ver $myip atPhysAddress`;
# my $mactableport = `$snmpwalk -Os -c $com -v $ver $myip ipNetToMediaIfIndex`; my $mactableport = `$snmpwalk -Os -c $com -v $ver $myip ipNetToMediaIfIndex`;
my $mactable = `$snmpwalk -Os -Cc -c $com -v $ver $myip mib-2.17.4.3.1.1`; my $dhcpdconf = `wget -t 1 -T 1 http://$dhcp/cgi-bin/dhcp.cgi -q -O -`;
my $mactableport = `$snmpwalk -Os -Cc -c $com -v $ver $myip mib-2.17.4.3.1.2`; # $arpn = `wget -t 1 -T 1 http://$dhcp/cgi-bin/arpn.cgi -q -O -`;
my $dhcpdconf = `wget -t 1 -T 1 http://$dhcp2/cgi-bin/dhcp.cgi -q -O -`;  
my $arpn = `wget -t 1 -T 1 http://$dhcp2/cgi-bin/arpn.cgi -q -O -`;  
   
foreach (split("\n",$operstatusall)) { foreach (split("\n",$operstatusall)) {
s/^ifOperStatus\.([0-9]+) = INTEGER: (.*)$/$1 $2/; s/^ifOperStatus\.([0-9]+) = INTEGER: (.*)$/$1 $2/;
@row = split ; @row = split ;
$pole_operstatus[$row[0]] = $row[1]; $pole_operstatus[$row[0]] = $row[1];
} }
Line 208... Line 206...
s/^ifAdminStatus\.([0-9]+) = INTEGER: (.*)$/$1 $2/; s/^ifAdminStatus\.([0-9]+) = INTEGER: (.*)$/$1 $2/;
@row = split ; @row = split ;
$pole_adminstatus[$row[0]] = $row[1]; $pole_adminstatus[$row[0]] = $row[1];
} }
foreach (split("\n",$speedall)) { foreach (split("\n",$speedall)) {
s/^ifSpeed\.([0-9]+) = Gauge32: (.*)$/$1 $2/; s/^.1.3.6.1.2.1.31.1.1.1.15\.([0-9]+) = Gauge32: (.*)$/$1 $2/;
@row = split ; @row = split ;
$row[1] =~ s/10000000$/10M/; $row[1] =~ s/10$/10M/;
$row[1] =~ s/100000000$/100M/; $row[1] =~ s/100$/100M/;
$row[1] =~ s/1000000000$/1G/; $row[1] =~ s/1000$/1G/;
$row[1] =~ s/4294967295$/10G/; $row[1] =~ s/10000$/10G/;
  $row[1] =~ s/40000$/40G/;
  $row[1] =~ s/25000$/25G/;
  $row[1] =~ s/100000$/100G/;
$pole_speed[$row[0]] = $row[1]; $pole_speed[$row[0]] = $row[1];
} }
foreach (split("\n",$mactable)) { foreach (split("\n",$mactable)) {
s/ = Hex-STRING://; s/ = Hex-STRING://;
($macind, my $tmpmac) = split(" ", $_, 2); ($macind, my $tmpmac) = split(" ", $_, 2);
Line 267... Line 268...
if (defined($pole_speed[$port])) { $stat = $pole_speed[$port]; } else { $stat = ""; } if (defined($pole_speed[$port])) { $stat = $pole_speed[$port]; } else { $stat = ""; }
if (defined($pole_operstatus[$port])) { $link = $pole_operstatus[$port]; } else { $link = ""; } if (defined($pole_operstatus[$port])) { $link = $pole_operstatus[$port]; } else { $link = ""; }
$flow = ""; $flow = "";
if ($enab eq "up(1)") { $bg = "\"#FFFFFF\""; } else { $bg = "\"#FF0000\""; } if ($enab eq "up(1)") { $bg = "\"#FFFFFF\""; } else { $bg = "\"#FF0000\""; }
if ($link eq "up(1)") { if ($link eq "up(1)") {
if ($stat eq "1G" || $stat eq "10G") { $bg = "\"#00FF00\""; } else { $bg = "\"#FFFF00\""; } if ($stat eq "1G") { $bg = "\"#00FF00\""; } else { $bg = "\"#FFFF00\""; }
  if ($stat eq "10G" ) { $bg = "\"#AAFF00\""; }
  if ($stat eq "40G" ) { $bg = "\"#00FFA5\""; }
  if ($stat eq "100G") { $bg = "\"#00d9FF\""; }
} }
} }
print "bgcolor=$bg>"; print "bgcolor=$bg>";
if ($port) { if ($port) {
if ($enab =~ /^up/) {$e = "E";} else {$e = "D";} if ($enab =~ /^up/) {$e = "E";} else {$e = "D";}
if (defined($sw_d->{$myip}[$port])) {$label = $sw_d->{$myip}[$port];} if (defined($sw_d->{$myip}[$port])) {$label = $sw_d->{$myip}[$port];}
else { $label = ""; } else { $label = ""; }
$hip = $myip; $hip = $myip;
$hip =~ s/\./_/g; $hip =~ s/\./_/g;
print_port_graph("$dhcp","${hip}_port${port}.html","${hip}_port${port}-day.png","$myip port $port $label","$port $label"); print_port_graph("$dhcp","${hip}_Ethernet${port}.html","${hip}_Ethernet${port}-day.png","$myip port $port $label","$port $label");
print "<br />$e $stat<br />\n"; print "<br />$e $stat<br />\n";
foreach $mac (@{ $mactab{$port} }) { foreach $mac (@{ $mactab{$port} }) {
if (exists $pole_dhcpdhosts{$mac}) { if (exists $pole_dhcpdhosts{$mac}) {
$barva = "black"; $barva = "black";
$title = "$mac " . $pole_dhcpdhosts{$mac}; $title = "$mac " . $pole_dhcpdhosts{$mac};
$popis = $pole_dhcpdhosts{$mac}; $popis = $pole_dhcpdhosts{$mac};
} else { } else {
$barva = "red"; $barva = "red";
$popis = $mac; $popis = $mac;
$macinfo = `wget -t 1 -T 1 http://$dhcp2/cgi-bin/macinfo.cgi?$mac -q -O -`; $macinfo = `wget -t 1 -T 1 http://$dhcp/cgi-bin/macinfo.cgi?$mac -q -O -`;
if ($macinfo) { ($macip) = split(" ", $macinfo, 1) } else { $macip = "none" }; if ($macinfo) { ($macip) = split(" ", $macinfo, 1) } else { $macip = "none" };
$title = "$mac je neznama MAC adresa! Nalezena IP : $macip"; $title = "$mac je neznama MAC adresa! Nalezena IP : $macip";
} }
print "<font color=$barva title=\"$title\">$popis</font><br>" print "<font color=$barva title=\"$title\">$popis</font><br>"
}; };

Powered by WebSVN 2.2.1