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

bugfix: fix walk snmp v1 interface list

rajven 4 лет назад
Родитель
Сommit
df2b12cc32
3 измененных файлов с 45 добавлено и 9 удалено
  1. 2 1
      html/admin/devices/switchstatus.php
  2. 16 0
      html/admin/iplist/index.php
  3. 27 8
      html/inc/common.php

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

@@ -142,7 +142,8 @@ if ($switch['snmp_version']>0) {
 
         if ($snmp_ok) {
             $vlan = get_port_vlan($row['port'], $row['snmp_index'], $switch['ip'], $switch['community'], $switch['snmp_version'], $switch['fdb_snmp_index']);
-            $ifname = get_snmp_ifname($switch['ip'], $switch['community'], $switch['snmp_version'], $row['snmp_index']);
+            $ifname = get_snmp_ifname1($switch['ip'], $switch['community'], $switch['snmp_version'], $row['snmp_index']);
+            if (empty($ifname)) { $ifname = get_snmp_ifname2($switch['ip'], $switch['community'], $switch['snmp_version'], $row['snmp_index']); }
             $sfp_status = get_sfp_status($switch['vendor_id'], $row['snmp_index'], $switch['ip'], $switch['community'], $switch['snmp_version'], $modules_oids);
             $poe_status = get_port_poe_state($switch['vendor_id'], $row['snmp_index'], $switch['ip'], $switch['community'], $switch['snmp_version']);
             if (isset($poe_status)) {

+ 16 - 0
html/admin/iplist/index.php

@@ -17,6 +17,21 @@ if ($sort_field == 'fio') { $sort_table = 'User_list'; }
 $sort_url = "<a href=index.php?ou=" . $rou; 
 global $default_user_id;
 
+if (isset($_POST["removeauth"])) {
+    $auth_id = $_POST["fid"];
+    foreach ($auth_id as $key => $val) {
+        if ($val) {
+                delete_record($db_link, 'connections', "auth_id=" . $val);
+                delete_record($db_link, 'User_auth_alias', "auth_id=" . $val);
+                $auth["deleted"] = 1;
+                $changes = get_diff_rec($db_link,"User_auth","id='$val'", '', 0);
+                if (!empty($changes)) { LOG_WARNING($db_link,"Удалён адрес доступа: \r\n $changes"); }
+                update_record($db_link, "User_auth", "id=" . $val, $auth);
+                delete_record($db_link, "connections", "auth_id=" . $val);
+                }
+            }
+    header("Location: " . $_SERVER["REQUEST_URI"]);
+    }
 
 if (isset($_POST["ApplyForAll"])) {
     $auth_id = $_POST["fid"];
@@ -106,6 +121,7 @@ print_navigation($page_url,$page,$displayed,$count_records[0],$total);
 <td>Dhcp&nbsp<?php print_qa_select('a_dhcp', 1); ?></td>
 <td>Dhcp-acl&nbsp<?php print_dhcp_acl_select('a_dhcp_acl',''); ?></td>
 <td>&nbsp<input type="submit" name="ApplyForAll" value="Apply"></td>
+<td align=right><input type="submit" name="removeauth" value="Удалить выделенных"></td>
 </tr>
 </table>
 

+ 27 - 8
html/inc/common.php

@@ -30,7 +30,9 @@ $cisco_sfp_sensors = '.1.3.6.1.4.1.9.9.91.1.1.1.1.4';
 $cisco_sfp_precision = '.1.3.6.1.4.1.9.9.91.1.1.1.1.3';
 $cisco_vlan_oid = 'SNMPv2-SMI::enterprises.9.9.46.1.3.1.1.2';
 
-$ifmib_ifindex = '.1.3.6.1.2.1.31.1.1.1.1';
+$ifmib_ifindex  = '.1.3.6.1.2.1.2.2.1.1';
+$ifmib_ifdescr  = '.1.3.6.1.2.1.2.2.1.2';
+$ifmib_ifname   = '.1.3.6.1.2.1.31.1.1.1.1';
 
 $huawei_sfp_vendor = '.1.3.6.1.4.1.2011.5.25.31.1.1.2.1.11';
 $huawei_sfp_speed = '.1.3.6.1.4.1.2011.5.25.31.1.1.2.1.2';
@@ -1902,18 +1904,28 @@ function get_cisco_sensors($ip, $community, $version, $mkey)
     return $result;
 }
 
-function get_snmp_ifname($ip, $community, $version, $port)
+function get_snmp_ifname1($ip, $community, $version, $port)
 {
-    global $ifmib_ifindex;
+    global $ifmib_ifname;
     $port_name = '';
     list ($pattern, $port_name) = explode(':', get_snmp($ip, $community, $version, $ifmib_ifindex . "." . $port));
     return $port_name;
 }
 
+function get_snmp_ifname2($ip, $community, $version, $port)
+{
+    global $ifmib_ifdescr;
+    $port_name = '';
+    list ($pattern, $port_name) = explode(':', get_snmp($ip, $community, $version, $ifmib_ifdescr . "." . $port));
+    return $port_name;
+}
+
 function get_snmp_interfaces($ip, $community, $version)
 {
-    global $ifmib_ifindex;
-    $result = walk_snmp($ip, $community, $version, $ifmib_ifindex);
+    global $ifmib_ifname;
+    global $ifmib_ifdescr;
+    $result = walk_snmp($ip, $community, $version, $ifmib_ifname);
+    if (empty($result)) { $result = walk_snmp($ip, $community, $version, $ifmib_ifdescr); }
     return $result;
 }
 
@@ -1961,7 +1973,8 @@ function get_sfp_status($vendor_id, $port, $ip, $community, $version, $modules_o
     }
     // if (!is_up($ip)) { return; }
 
-    global $ifmib_ifindex;
+    global $ifmib_ifname;
+    global $ifmib_ifdescr;
 
     $status = '';
     // eltex
@@ -2015,7 +2028,10 @@ function get_sfp_status($vendor_id, $port, $ip, $community, $version, $modules_o
         global $cisco_descr;
         global $cisco_modules;
         // get interface names
-        list ($pattern, $port_name) = explode(':', get_snmp($ip, $community, $version, $ifmib_ifindex . "." . $port));
+        list ($pattern, $port_name) = explode(':', get_snmp($ip, $community, $version, $ifmib_ifname . "." . $port));
+        if (empty($port_name)) {
+            list ($pattern, $port_name) = explode(':', get_snmp($ip, $community, $version, $ifmib_ifdescr . "." . $port));
+            }
         // search module indexes
         $port_name = preg_quote(trim($port_name), '/');
         foreach ($modules_oids as $key => $value) {
@@ -2086,7 +2102,10 @@ function get_sfp_status($vendor_id, $port, $ip, $community, $version, $modules_o
         global $huawei_sfp_biascurrent;
         
         // get interface names
-        list ($pattern, $port_name) = explode(':', get_snmp($ip, $community, $version, $ifmib_ifindex . "." . $port));
+        list ($pattern, $port_name) = explode(':', get_snmp($ip, $community, $version, $ifmib_ifname . "." . $port));
+        if (empty($port_name)) {
+            list ($pattern, $port_name) = explode(':', get_snmp($ip, $community, $version, $ifmib_ifdescr . "." . $port));
+    	    }
         // search module indexes
         $port_name = preg_quote(trim($port_name), '/');
         foreach ($modules_oids as $key => $value) {