Explorar el Código

- added comment for Customers
- added detect sfp by SNMP for SNR devices

root hace 1 año
padre
commit
f182690791

+ 3 - 2
docs/mysql/mysql.sql

@@ -178,7 +178,7 @@ CREATE TABLE `version` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
-REPLACE INTO `version` (`version`) VALUES ('2.5.1');
+REPLACE INTO `version` (`version`) VALUES ('2.5.3');
 -- --------------------------------------------------------
 
 --
@@ -201,6 +201,7 @@ CREATE TABLE `connections` (
 CREATE TABLE `Customers` (
   `id` int(11) NOT NULL,
   `Login` varchar(20) DEFAULT 'NULL',
+  `comment` VARCHAR(100) DEFAULT 'NULL',
   `password` varchar(255) DEFAULT 'NULL',
   `api_key` varchar(255) DEFAULT NULL,
   `rights` tinyint(1) NOT NULL DEFAULT 3
@@ -210,7 +211,7 @@ CREATE TABLE `Customers` (
 -- Дамп данных таблицы `Customers`
 --
 
-INSERT INTO `Customers` (`id`, `Login`, `password`, `api_key`, `rights`) VALUES(1, 'admin', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31', 1);
+INSERT INTO `Customers` (`id`, `Login`, `comment`, `password`, `api_key`, `rights`) VALUES(1, 'admin', 'Administrator', '$2y$11$wohV8Tuqu0Yai9Shacei5OKfMxG5bnLxB5ACcZcJJ3pYEbIH0qLGG', 'c3284d0f94606de1fd2af172aba15bf31', 1);
 
 -- --------------------------------------------------------
 

+ 16 - 5
html/admin/customers/editcustom.php

@@ -8,6 +8,7 @@ $msg_error = "";
 if (isset($_POST["edituser"])) {
     global $salt;
     $new['Login'] = substr(trim($_POST["login"]), 0, 20);
+    $new['comment'] = substr(trim($_POST["comment"]), 0, 100);
     if (isset($_POST["pass"]) and (strlen(trim($_POST["pass"])) > 0)) {
         $new['password'] = password_hash($_POST["pass"], PASSWORD_BCRYPT);
 	}
@@ -36,17 +37,27 @@ $customer=get_record($db_link,'Customers',"id=".$id);
 		<table class="data">
 			<tr>
 				<td><?php echo WEB_customer_login; ?></td>
-				<td><?php echo WEB_customer_password; ?></td>
-				<td><?php echo WEB_customer_api_key; ?></td>
-				<td><?php echo WEB_customer_mode; ?></td>
+				<td><input type="text" name="login" value="<?php print $customer['Login']; ?>" size=20></td>
 			</tr>
 			<tr>
-				<td><input type="text" name="login" value="<?php print $customer['Login']; ?>" size=20></td>
+				<td><?php echo WEB_cell_comment; ?></td>
+				<td><input type="text" name="comment" value="<?php print $customer['comment']; ?>" size=50></td>
+			</tr>
+			<tr>
+				<td><?php echo WEB_customer_password; ?></td>
 				<td><input type="password" name="pass" value="" size=20></td>
+			</tr>
+			<tr>
+				<td><?php echo WEB_customer_api_key; ?></td>
 				<td><input type="text" name="api_key" value="<?php print $customer['api_key']; ?>" size=50></td>
+			</tr>
+			<tr>
+				<td><?php echo WEB_customer_mode; ?></td>
 				<td><?php print_acl_select($db_link,'f_acl',$customer['rights']); ?></td>
 			</tr>
-			<td colspan=2><input type="submit" name="edituser" value="<?php echo WEB_btn_save; ?>"></td>
+                        <tr>
+        			<td colspan=2><input type="submit" name="edituser" value="<?php echo WEB_btn_save; ?>"></td>
+                        </tr>
 		</table>
 	</form>
 <?php require_once ($_SERVER['DOCUMENT_ROOT']."/inc/footer.php"); ?>

+ 2 - 0
html/admin/customers/index.php

@@ -50,6 +50,7 @@ print_control_submenu($page_url);
 <tr align="center">
 <td width="30"><input type="checkbox" onClick="checkAll(this.checked);"></td>
 <td><b>Login</b></td>
+<td><b><?php echo WEB_cell_comment; ?></b></td>
 <td><b><?php echo WEB_customer_mode;?></b></td>
 </tr>
 <?php
@@ -60,6 +61,7 @@ foreach ($users as $row) {
     print "<tr align=center>\n";
     print "<td class=\"$cl\" style='padding:0'><input type=checkbox name=fid[] value=".$row['id']."></td>\n";
     print "<td class=\"$cl\" align=left width=200><a href=editcustom.php?id=".$row['id'].">" . $row['Login'] . "</a></td>\n";
+    print "<td class=\"$cl\" >". $acl['comment']. "</a></td>\n";
     print "<td class=\"$cl\" >". $acl['name']. "</a></td>\n";
 }
 ?>

+ 1 - 1
html/admin/devices/switchport.php

@@ -139,7 +139,7 @@ foreach ($ports as $row) {
                 }
         print "<td class='".$cl."'>" . $display_vlan . "</td>\n";
         print "<td class='".$cl."'>" . $snmp_url . "</td>\n";
-        print "<td class='".$cl."' ><button name='write' class='j-submit-report' onclick='window.open('portmactable.php?id=" . $row['id'] . "')'>" . $row['last_mac_count'] . "</button></td>\n";
+        print "<td class='".$cl."' ><button onclick=\"". open_window_url('portmactable.php?id='.$row['id'])." return false;\">" . $row['last_mac_count'] . "</button></td>\n";
 print "</tr>";
 }
 print "<tr>\n";

+ 50 - 5
html/inc/common.php

@@ -1417,17 +1417,20 @@ function get_device_by_auth($db, $id)
 
 function print_auth_port($db, $port_id, $new_window = FALSE)
 {
-    $d_sql = "SELECT A.ip,A.ip_int,A.mac,A.id,A.dns_name FROM User_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0 order by A.ip_int";
+    $d_sql = "SELECT A.ip,A.ip_int,A.mac,A.id,A.dns_name,A.comments,A.user_id FROM User_auth as A, connections as C WHERE C.port_id=$port_id and A.id=C.auth_id and A.deleted=0 order by A.ip_int";
     $t_device = mysqli_query($db, $d_sql);
-    while (list($f_ip, $f_int, $f_mac, $f_auth_id, $f_dns) = mysqli_fetch_array($t_device)) {
+    while (list($f_ip, $f_int, $f_mac, $f_auth_id, $f_dns, $f_comment, $f_user_id) = mysqli_fetch_array($t_device)) {
         $name = $f_ip;
         if (isset($f_dns) and $f_dns != '') {
             $name = $f_dns;
         }
+        $title=get_login($db,$f_user_id)." =>".$f_ip."[".$f_mac."]";
+        if (!empty($f_dns)) { $title.=" | ".$f_dns; }
+        if (!empty($f_comment)) { $title.=" | ".$f_comment; }
         if ($new_window) {
-            print "<a href=\"#\" onclick=\"".open_window_url("/admin/users/editauth.php?id=".$f_auth_id)." return false;\">" . $name . " [" . $f_ip . "]</a><br>";
+            print "<a href=\"\" title=\"" . $title . "\" onclick=\"".open_window_url("/admin/users/editauth.php?id=".$f_auth_id)." return false;\">" . $name . " [" . $f_ip . "]</a><br>";
         } else {
-            print "<a href=/admin/users/editauth.php?id=".$f_auth_id.">" . $name . " [" . $f_ip . "]</a><br>";
+            print "<a href=/admin/users/editauth.php?id=".$f_auth_id." title=\"" . $title . "\" >" . $name . " [" . $f_ip . "]</a><br>";
         }
     }
 }
@@ -2651,7 +2654,7 @@ function get_sfp_status($vendor_id, $port, $ip, $community='public', $version='2
     // eltex
     if ($vendor_id == 2) {
         $sfp_vendor = parse_snmp_value(get_snmp($ip, $community, $version, ELTEX_SFP_VENDOR . "." . $port));
-        if (isset($sfp_vendor)) {
+        if (!empty($sfp_vendor)) {
             $sfp_status_temp = ELTEX_SFP_STATUS . "." . $port . ".5";
             $sfp_status_volt = ELTEX_SFP_STATUS . "." . $port . ".6";
             $sfp_status_circut = ELTEX_SFP_STATUS . "." . $port . ".7";
@@ -2689,6 +2692,48 @@ function get_sfp_status($vendor_id, $port, $ip, $community='public', $version='2
         }
         return;
     }
+
+    // snr
+    if ($vendor_id == 6) {
+        $sfp_vendor = parse_snmp_value(get_snmp($ip, $community, $version, SNR_SFP_VendorName . "." . $port));
+        if (!empty($sfp_vendor) and $sfp_vendor != 'NULL') {
+            $oid_sfp_model_name = SNR_SFP_ModelName . "." . $port;
+            $oid_sfp_type_name = SNR_SFP_TypeName . "." . $port;
+            $oid_sfp_bitrate = SNR_SFP_BitRate . "." . $port;
+            $oid_sfp_status_volt = SNR_SFP_VOLT . "." . $port;
+            $oid_sfp_status_circut = SNR_SFP_BIAS . "." . $port;
+            $oid_sfp_status_tx = SNR_SFP_TX . "." . $port;
+            $oid_sfp_status_rx = SNR_SFP_RX . "." . $port;
+            $oid_sfp_length = SNR_SFP_WaveLength . "." . $port;
+
+            $volt = parse_snmp_value(get_snmp($ip, $community, $version, $oid_sfp_status_volt));
+            $circut = parse_snmp_value(get_snmp($ip, $community, $version, $oid_sfp_status_circut));
+            $tx = parse_snmp_value(get_snmp($ip, $community, $version, $oid_sfp_status_tx));
+            $rx = parse_snmp_value(get_snmp($ip, $community, $version, $oid_sfp_status_rx));
+            $sfp_model_name = parse_snmp_value(get_snmp($ip, $community, $version, $oid_sfp_model_name));
+            $sfp_type_name = parse_snmp_value(get_snmp($ip, $community, $version, $oid_sfp_type_name));
+            $sfp_freq = parse_snmp_value(get_snmp($ip, $community, $version, $oid_sfp_bitrate));
+            $sfp_length = parse_snmp_value(get_snmp($ip, $community, $version, $oid_sfp_length));
+
+            $status = 'Vendor: ' . $sfp_vendor . ' '. $sfp_model_name. ' '.$sfp_type_name. ' Speed: ' . $sfp_freq . ' Freq: ' . $sfp_length . '<br>';
+            if (!empty($sfp_status_volt) and $volt > 0.1) {
+                $status .= ' Volt: ' . round($volt / 1000000, 2) . ' V';
+            }
+            if (!empty($sfp_status_circut) and $circut > 0.1) {
+                $status .= ' Circut: ' . round($circut / 1000, 2) . ' mA';
+            }
+            if (!empty($sfp_status_tx) and $tx > 0.1) {
+                $status .= ' Tx: ' . round($tx / 1000, 2) . ' dBm';
+            }
+            if (!empty($sfp_status_rx) and $rx > 0.1) {
+                $status .= ' Rx: ' . round($rx / 1000, 2) . ' dBm';
+            }
+            $status .= '<br>';
+            return $status;
+        }
+        return;
+    }
+
     // cisco
     if ($vendor_id == 16) {
         // get interface names

+ 23 - 0
html/inc/consts.php

@@ -63,12 +63,35 @@ define("HUAWEI_SFP_BIASCURRENT",".1.3.6.1.4.1.2011.5.25.31.1.1.3.1.31");
 define("HUAWEI_SFP_RX",".1.3.6.1.4.1.2011.5.25.31.1.1.3.1.8");
 define("HUAWEI_SFP_TX",".1.3.6.1.4.1.2011.5.25.31.1.1.3.1.9");
 
+//SNR NAGTECH
+define("SNR_SFP_VendorName",".1.3.6.1.4.1.57206.7.100.30.3.1.4");
+define("SNR_SFP_ModelName",".1.3.6.1.4.1.57206.7.100.30.3.1.5");
+define("SNR_SFP_TypeName",".1.3.6.1.4.1.57206.7.100.30.3.1.6");
+define("SNR_SFP_BitRate",".1.3.6.1.4.1.57206.7.100.30.3.1.7");
+define("SNR_SFP_WaveLength",".1.3.6.1.4.1.57206.7.100.30.3.1.8");
+define("SNR_SFP_VOLT",".1.3.6.1.4.1.57206.7.100.30.1.1.7");
+define("SNR_SFP_BIAS",".1.3.6.1.4.1.57206.7.100.30.1.1.12");
+define("SNR_SFP_RX",".1.3.6.1.4.1.57206.7.100.30.1.1.17");
+define("SNR_SFP_TX",".1.3.6.1.4.1.57206.7.100.30.1.1.22");
+
 //POE Default mib
 //POE class
 define("PETH_PSE_PORT_POE_CLASS",".1.3.6.1.2.1.105.1.1.1.10.1");
 //POE enable
 define("PETH_PSE_PORT_ADMIN_ENABLE",".1.3.6.1.2.1.105.1.1.1.3.1");
 
+//SNR NAGTECH
+// Class
+define("SNR_POE_CLASS",".1.3.6.1.4.1.57206.7.100.26.10.1.9");
+// Status
+define("SNR_POE_OID",".1.3.6.1.4.1.57206.7.100.26.10.1.2");
+// VOLTAGE
+define("SNR_POE_VOLT",".1.3.6.1.4.1.57206.7.100.26.10.1.7");
+// CURRENT
+define("SNR_POE_CURRENT",".1.3.6.1.4.1.57206.7.100.26.10.1.6");
+// POWER USAGE
+define("SNR_POE_USAGE",".1.3.6.1.4.1.57206.7.100.26.10.1.5");
+
 //SNR
 // Class
 define("SNR_POE_CLASS",".1.3.6.1.4.1.40418.7.100.26.10.1.9");