Просмотр исходного кода

rollback fdb_snmp_index option

rajven 4 лет назад
Родитель
Сommit
40c1960f78

+ 3 - 2
html/admin/devices/editdevice.php

@@ -54,6 +54,7 @@ if (isset($_POST["editdevice"]) and isset($id)) {
     if (isset($_POST["f_snmp3_user_ro"])) { $new['snmp3_user_ro'] = substr($_POST["f_snmp3_user_ro"], 0, 20); }
     if (isset($_POST["f_snmp3_user_rw_password"])) { $new['snmp3_user_rw_password'] = substr($_POST["f_snmp3_user_rw_password"], 0, 20); }
     if (isset($_POST["f_snmp3_user_ro_password"])) { $new['snmp3_user_ro_password'] = substr($_POST["f_snmp3_user_ro_password"], 0, 20); }
+    if (isset($_POST["f_fdb_snmp"])) { $new['fdb_snmp_index'] = $_POST["f_fdb_snmp"]; }
     if (isset($_POST["f_discovery"])) { $new['discovery'] = $_POST["f_discovery"]; }
     if (isset($_POST["f_dhcp"])) { $new['dhcp'] = $_POST["f_dhcp"] * 1; }
     if (isset($_POST["f_user_acl"])) { $new['user_acl'] = $_POST["f_user_acl"] * 1; }
@@ -139,7 +140,7 @@ if ($device['device_type']==2) {
 ?>
 </tr>
 <td>Snmp Version</td>
-<td></td>
+<td>Mac by snmp</td>
 <td>Discovery</td>
 <td>Nagios</td>
 <td>
@@ -147,7 +148,7 @@ if ($device['device_type']==2) {
 <?php
 print "<tr>\n";
 print "<td class=\"data\">"; print_snmp_select('f_snmp_version', $device['snmp_version']); print "</td>\n";
-print "<td class=\"data\"></td>\n";
+print "<td class=\"data\">"; print_qa_select('f_fdb_snmp', $device['fdb_snmp_index']); print "</td>\n";
 print "<td class=\"data\">"; print_qa_select('f_discovery', $device['discovery']); print "</td>\n";
 print "<td class=\"data\">"; print_qa_select('f_nagios', $device['nagios']); print "</td>\n";
 print "</tr>\n";

+ 5 - 2
html/admin/devices/portmactable.php

@@ -14,15 +14,18 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 <div id="cont">
 <?php
 $port_id = $id;
-$sSQL = "SELECT DP.port, DP.snmp_index, D.device_name, D.ip, D.snmp_version, D.community  FROM `device_ports` AS DP, devices AS D WHERE D.id = DP.device_id AND DP.id=$port_id";
+$sSQL = "SELECT DP.port, DP.snmp_index, D.device_name, D.ip, D.snmp_version, D.community, D.fdb_snmp_index FROM `device_ports` AS DP, devices AS D WHERE D.id = DP.device_id AND DP.id=$port_id";
 $port_info = mysqli_query($db_link, $sSQL);
-list ($f_port, $f_snmp_index, $f_switch, $f_ip, $f_version, $f_community) = mysqli_fetch_array($port_info);
+list ($f_port, $f_snmp_index, $f_switch, $f_ip, $f_version, $f_community, $f_snmp) = mysqli_fetch_array($port_info);
 $display_name = " $f_port свича $f_switch";
 print "<b>$f_switch [$f_port] </b><br>\n";
 
 if ($f_snmp_index > 0) {
     print "<table class=\"data\" cellspacing=\"1\" cellpadding=\"4\">\n";
     print "<tr><td><b>Список маков активных на порту</b></td></tr>\n";
+    if (! $f_snmp) {
+        $f_snmp_index = $f_port;
+    }
     $fdb = get_fdb_port_table($f_ip, $f_snmp_index, $f_community, $f_version);
     foreach ($fdb as $a_mac => $a_port) {
         print "<tr>";

+ 6 - 2
html/admin/devices/switchstatus.php

@@ -98,7 +98,7 @@ if ($switch['snmp_version']>0) {
         print "<tr align=center>\n";
         $cl = "up";
         if (isset($switch['ip']) and ($switch['ip'] != '') and $snmp_ok) {
-            $port_state_detail = get_port_state_detail($d_snmp, $switch['ip'], $switch['community'], $switch['snmp_version']);
+            $port_state_detail = get_port_state_detail($d_snmp, $switch['ip'], $switch['community'], $switch['snmp_version'], $switch['fdb_snmp_index']);
             list ($poper, $padmin, $pspeed, $perrors) = explode(';', $port_state_detail);
             if (preg_match('/up/i', $poper)) {
                 $cl = "up";
@@ -127,7 +127,11 @@ if ($switch['snmp_version']>0) {
         print "</td>\n";
         print "<td class=\"$cl\">" . $d_comment . "</td>\n";
         if ($snmp_ok) {
-            $vlan = get_port_vlan($d_snmp, $switch['ip'], $switch['community'], $switch['snmp_version']);
+            if ($switch['fdb_snmp_index']) {
+                $vlan = get_port_vlan($d_snmp, $switch['ip'], $switch['community'], $switch['snmp_version'], $switch['fdb_snmp_index']);
+            } else {
+                $vlan = get_port_vlan($d_port, $switch['ip'], $switch['community'], $switch['snmp_version'], $switch['fdb_snmp_index']);
+            }
             $ifname = get_snmp_ifname($switch['ip'], $switch['community'], $switch['snmp_version'], $d_snmp);
             $sfp_status = get_sfp_status($switch['vendor_id'], $d_snmp, $switch['ip'], $switch['community'], $switch['snmp_version'], $modules_oids);
             $poe_status = get_port_poe_state($switch['vendor_id'], $d_snmp, $switch['ip'], $switch['community'], $switch['snmp_version']);

+ 16 - 4
scripts/fetch_new_arp.pl

@@ -224,6 +224,8 @@ $fdb_ref{$fdb_table->{id}}{vlans}=$fdb_table->{vlans};
 
 $dbh=init_db();
 
+die;
+
 foreach my $device (@device_list) {
 my %port_snmp_index=();
 my %port_index=();
@@ -244,11 +246,18 @@ foreach my $port_data (@device_ports) {
     my $vlan = $port_data->{vlan};
     if (!$vlan) { $vlan=1; }
 
+    my $fdb_port_index=$port_data->{port};
+
     if (!$port_data->{snmp_index}) { $port_data->{snmp_index} = $port_data->{port}; }
-    my $port_index=$port_data->{snmp_index};
 
-    my $current_vlan = $vlans->{$port_data->{snmp_index}};
+    if ($device->{fdb_snmp_index}) {
+        if (!$snmp_index) { next; }
+        $fdb_port_index=$snmp_index;
+        }
+
+    my $current_vlan = $vlans->{$fdb_port_index};
     if (!$current_vlan) { $current_vlan=1; }
+
     if ($current_vlan != $vlan) {
 	my $dev_ports;
 	$dev_ports->{vlan}=$current_vlan;
@@ -268,9 +277,12 @@ foreach my $mac (keys %$fdb) {
     #port from fdb table
     my $port = $fdb->{$mac};
     next if (!$port);
-    if (!exists $port_snmp_index{$port}) { next; }
+    if ($device->{fdb_snmp_index}) {
+        if (!exists $port_snmp_index{$port}) { next; }
+        $port=$port_snmp_index{$port};
+        }
+    if (!exists $port_index{$port}) { next; }
     #real port number
-    $port=$port_snmp_index{$port};
     $mac_port_count{$port}++;
     $mac_address_table{$mac}=$port;
     }