Browse Source

cosmetic fixes

Roman Dmitriev 2 years ago
parent
commit
9dd21c7cee

+ 9 - 6
docs/mysql/mysql.sql

@@ -382,19 +382,22 @@ INSERT INTO `device_models` (`id`, `model_name`, `vendor_id`, `nagios_template`)
 
 
 CREATE TABLE `device_ports` (
 CREATE TABLE `device_ports` (
   `id` bigint(20) UNSIGNED NOT NULL,
   `id` bigint(20) UNSIGNED NOT NULL,
-  `device_id` int(11) DEFAULT NULL,
-  `snmp_index` int(11) DEFAULT NULL,
-  `port` int(11) DEFAULT NULL,
+  `device_id` int(11) NOT NULL DEFAULT 0,
+  `snmp_index` int(11) NOT NULL DEFAULT 0,
+  `port` int(11) NOT NULL DEFAULT 0,
   `ifName` varchar(40) DEFAULT NULL,
   `ifName` varchar(40) DEFAULT NULL,
   `port_name` varchar(40) DEFAULT NULL,
   `port_name` varchar(40) DEFAULT NULL,
-  `comment` varchar(50) DEFAULT NULL,
+  `comment` varchar(50) DEFAULT '',
   `target_port_id` int(11) NOT NULL DEFAULT 0,
   `target_port_id` int(11) NOT NULL DEFAULT 0,
   `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
   `auth_id` bigint(20) UNSIGNED DEFAULT NULL,
-  `last_mac_count` int(11) DEFAULT 0,
+  `last_mac_count` int(11) NOT NULL DEFAULT 0,
   `uplink` tinyint(1) NOT NULL DEFAULT 0,
   `uplink` tinyint(1) NOT NULL DEFAULT 0,
   `nagios` tinyint(1) NOT NULL DEFAULT 0,
   `nagios` tinyint(1) NOT NULL DEFAULT 0,
   `skip` tinyint(1) NOT NULL DEFAULT 0,
   `skip` tinyint(1) NOT NULL DEFAULT 0,
-  `vlan` int(11) NOT NULL DEFAULT 1
+  `vlan` int(11) NOT NULL DEFAULT 1,
+  `tagged_vlan` varchar(250) DEFAULT NULL,
+  `untagged_vlan` varchar(250) DEFAULT NULL,
+  `forbidden_vlan` varchar(250) DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 
 -- --------------------------------------------------------
 -- --------------------------------------------------------

+ 6 - 6
html/admin/iplist/index.php

@@ -5,7 +5,7 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/header.php");
 $default_sort='ip_int';
 $default_sort='ip_int';
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/oufilter.php");
-require_once ($_SERVER['DOCUMENT_ROOT']."/inc/subnetfilter.php");
+require_once ($_SERVER['DOCUMENT_ROOT']."/inc/cidrfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/sortfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/gatefilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/enabledfilter.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/enabledfilter.php");
@@ -18,9 +18,9 @@ $sort_url = "<a href=index.php?ou=" . $rou;
 
 
 if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and User_list.ou_id=$rou "; }
 if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and User_list.ou_id=$rou "; }
 
 
-if ($rsubnet == 0) { $subnet_filter = ''; } else {
-    $subnet_range = get_subnet_range($db_link,$rsubnet);
-    if (!empty($subnet_range)) { $subnet_filter = " and User_auth.ip_int>=".$subnet_range['start']." and User_auth.ip_int<=".$subnet_range['stop']; }
+if (empty($rcidr)) { $cidr_filter = ''; } else {
+    $cidr_range = cidrToRange($rcidr);
+    if (!empty($cidr_range)) { $cidr_filter = " and User_auth.ip_int>=".$cidr_range[0]." and User_auth.ip_int<=".$cidr_range[1]; }
     }
     }
 
 
 $enabled_filter='';
 $enabled_filter='';
@@ -40,7 +40,7 @@ if (!empty($f_ip)) {
     if (checkValidMac($f_ip)) { $ip_where = " and mac='" . mac_dotted($f_ip) . "'  "; }
     if (checkValidMac($f_ip)) { $ip_where = " and mac='" . mac_dotted($f_ip) . "'  "; }
     $ip_list_filter = $ip_where;
     $ip_list_filter = $ip_where;
     } else {
     } else {
-    $ip_list_filter = $ou_filter.$subnet_filter.$enabled_filter;
+    $ip_list_filter = $ou_filter.$cidr_filter.$enabled_filter;
     }
     }
 
 
 print_ip_submenu($page_url);
 print_ip_submenu($page_url);
@@ -53,7 +53,7 @@ print_ip_submenu($page_url);
 	<tr>
 	<tr>
         <td>
         <td>
         <b><?php print WEB_cell_ou; ?> - </b><?php print_ou_select($db_link, 'ou', $rou); ?>
         <b><?php print WEB_cell_ou; ?> - </b><?php print_ou_select($db_link, 'ou', $rou); ?>
-        <b><?php print WEB_network_subnet; ?> - </b><?php print_subnet_select_office($db_link, 'subnet', $rsubnet); ?>
+        <b><?php print WEB_network_subnet; ?> - </b><?php print_subnet_select_office_splitted($db_link, 'cidr', $rcidr); ?>
         <b><?php echo WEB_ips_show_by_state; ?> - </b><?php print_enabled_select('enabled', $enabled); ?>
         <b><?php echo WEB_ips_show_by_state; ?> - </b><?php print_enabled_select('enabled', $enabled); ?>
         <?php echo WEB_ips_search_host; ?>:&nbsp<input type="text" name="ip" value="<?php echo $f_ip; ?>" pattern="^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}|([0-9a-fA-F]{4}[\\.-][0-9a-fA-F]{4}[\\.-][0-9a-fA-F]{4})|[0-9A-Fa-f]{12})$"/>
         <?php echo WEB_ips_search_host; ?>:&nbsp<input type="text" name="ip" value="<?php echo $f_ip; ?>" pattern="^((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}|([0-9a-fA-F]{4}[\\.-][0-9a-fA-F]{4}[\\.-][0-9a-fA-F]{4})|[0-9A-Fa-f]{12})$"/>
         <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>
         <?php print WEB_rows_at_page."&nbsp"; print_row_at_pages('rows',$displayed); ?>

+ 11 - 0
html/inc/cidrfilter.php

@@ -0,0 +1,11 @@
+<?php
+if (! defined("CONFIG")) die("Not defined");
+
+if (!isset($default_cidr)) { $default_cidr = ''; }
+if (isset($_GET['cidr'])) { $rcidr = $_GET["cidr"] * 1; }
+if (isset($_POST['cidr'])) { $rcidr = $_POST["cidr"] * 1; }
+if (! isset($rcidr)) {
+    if (isset($_SESSION[$page_url]['cidr'])) { $rcidr=$_SESSION[$page_url]['cidr']; } else { $rcidr = $default_cidr; }
+    }
+$_SESSION[$page_url]['cidr']=$rcidr;
+?>

+ 21 - 4
html/inc/common.php

@@ -480,6 +480,23 @@ function print_subnet_select_office($db, $subnet_name, $subnet_value)
     print "</select>\n";
     print "</select>\n";
 }
 }
 
 
+function print_subnet_select_office_splitted($db, $subnet_name, $subnet_value)
+{
+    print "<select name=\"$subnet_name\" >\n";
+    $t_subnet = mysqli_query($db, "SELECT id,subnet,ip_int_start,ip_int_stop FROM subnets WHERE office=1 ORDER BY ip_int_start");
+    print_select_item(WEB_select_item_all_ips, 0, $subnet_value);
+    while (list($f_subnet_id, $f_subnet_name,$f_start_ip,$f_stop_ip) = mysqli_fetch_array($t_subnet)) {
+        print_select_item($f_subnet_name, $f_subnet_name, $subnet_value);
+        if (!preg_match('/\/24$/',$subnet_value)) {
+            while ($f_start_ip<=$f_stop_ip) {
+                print_select_item("&nbsp&nbsp-&nbsp".$f_start_ip."/24", $f_start_ip."/24", $subnet_value);
+                $f_start_ip+=256;
+                }
+            }
+    }
+    print "</select>\n";
+}
+
 function print_loglevel_select($item_name, $value)
 function print_loglevel_select($item_name, $value)
 {
 {
     print "<select name=\"$item_name\">\n";
     print "<select name=\"$item_name\">\n";
@@ -2530,21 +2547,21 @@ function get_port_vlan($vendor, $port, $port_index, $ip, $community, $version)
     }
     }
 
 
     //default - default port index
     //default - default port index
-    $port_oid = PORT_VLAN_OID . "." . $port_index;
+    $port_oid = dot1qPortVlanEntry . "." . $port_index;
 
 
     //tplink
     //tplink
     if ($vendor == 69) {
     if ($vendor == 69) {
-        $port_oid = TPLINK_VLAN_PVID . "." . $port_index;
+        $port_oid = TPLINK_dot1qPortVlanEntry . "." . $port_index;
     } 
     } 
 
 
     //huawei
     //huawei
     if ($vendor == 3) {
     if ($vendor == 3) {
-        $port_oid = PORT_VLAN_OID . "." . $port;
+        $port_oid = dot1qPortVlanEntry . "." . $port;
     } 
     } 
 
 
     //allied telesys
     //allied telesys
     if ($vendor == 8) {
     if ($vendor == 8) {
-        $port_oid = PORT_VLAN_OID . "." . $port;
+        $port_oid = dot1qPortVlanEntry . "." . $port;
     } 
     } 
 
 
     $port_vlan = get_snmp($ip, $community, $version, $port_oid);
     $port_vlan = get_snmp($ip, $community, $version, $port_oid);

+ 7 - 2
html/inc/consts.php

@@ -8,9 +8,14 @@ define("PORT_SPEED_OID",".1.3.6.1.2.1.2.2.1.5.");
 define("PORT_ERRORS_OID",".1.3.6.1.2.1.2.2.1.14.");
 define("PORT_ERRORS_OID",".1.3.6.1.2.1.2.2.1.14.");
 
 
 //VLANS
 //VLANS
-define("PORT_VLAN_OID",".1.3.6.1.2.1.17.7.1.4.5.1.1");
+define("dot1qVlanStaticName",".1.3.6.1.2.1.17.7.1.4.3.1.1");
+define("dot1qVlanStaticEgressPorts",".1.3.6.1.2.1.17.7.1.4.3.1.2");
+define("dot1qVlanForbiddenEgressPorts",".1.3.6.1.2.1.17.7.1.4.3.1.3");
+define("dot1qVlanStaticUntaggedPorts",".1.3.6.1.2.1.17.7.1.4.3.1.4");
+define("dot1qVlanStaticRowStatus",".1.3.6.1.2.1.17.7.1.4.3.1.5");
+define("dot1qPortVlanEntry",".1.3.6.1.2.1.17.7.1.4.5.1.1");
 //tp-link
 //tp-link
-define("TPLINK_VLAN_PVID",".1.3.6.1.4.1.11863.6.14.1.1.1.1.2");
+define("TPLINK_dot1qPortVlanEntry",".1.3.6.1.4.1.11863.6.14.1.1.1.1.2");
 
 
 define("IFMIB_IFINDEX",".1.3.6.1.2.1.2.2.1.1");
 define("IFMIB_IFINDEX",".1.3.6.1.2.1.2.2.1.1");
 define("IFMIB_IFINDEX_MAP",".1.3.6.1.2.1.17.1.4.1.2");
 define("IFMIB_IFINDEX_MAP",".1.3.6.1.2.1.17.1.4.1.2");

+ 1 - 1
html/inc/footer.small.php

@@ -1,4 +1,4 @@
-<div id="copyright">Copyright &copy; 2008-2023 Eye v2.4 &nbsp<a href="https://github.com/rajven/Eye">rnd@rajven.ru</a></div>
+<div id="copyright">Copyright &copy; 2008-2023 Eye v2.4.12 &nbsp<a href="https://github.com/rajven/Eye">rnd@rajven.ru</a></div>
 <?php
 <?php
 $end_time = microtime();
 $end_time = microtime();
 $end_array = explode(" ",$end_time);
 $end_array = explode(" ",$end_time);

+ 5 - 5
scripts/Rstat/snmp.pm

@@ -43,7 +43,7 @@ $ipNetToMediaPhysAddress
 $fdb_table_oid
 $fdb_table_oid
 $fdb_table_oid2
 $fdb_table_oid2
 $cisco_vlan_oid
 $cisco_vlan_oid
-$port_vlan_oid
+$dot1qPortVlanEntry
 $fdb_table;
 $fdb_table;
 $snmp_timeout
 $snmp_timeout
 );
 );
@@ -67,7 +67,7 @@ our $fdb_table_oid ='.1.3.6.1.2.1.17.4.3.1.2';
 #Q-BRIDGE-MIB::dot1qTpFdbPort
 #Q-BRIDGE-MIB::dot1qTpFdbPort
 our $fdb_table_oid2='.1.3.6.1.2.1.17.7.1.2.2.1.2';
 our $fdb_table_oid2='.1.3.6.1.2.1.17.7.1.2.2.1.2';
 #Q-BRIDGE-MIB::dot1qPortVlanEntry
 #Q-BRIDGE-MIB::dot1qPortVlanEntry
-our $port_vlan_oid ='.1.3.6.1.2.1.17.7.1.4.5.1.1';
+our $dot1qPortVlanEntry ='.1.3.6.1.2.1.17.7.1.4.5.1.1';
 #CISCO-ES-STACK-MIB::
 #CISCO-ES-STACK-MIB::
 our $cisco_vlan_oid='.1.3.6.1.4.1.9.9.46.1.3.1.1.2';
 our $cisco_vlan_oid='.1.3.6.1.4.1.9.9.46.1.3.1.1.2';
 
 
@@ -304,7 +304,7 @@ sub get_vlan_at_port {
     my $port = 161;
     my $port = 161;
     my $timeout = 5;
     my $timeout = 5;
     if (!$version) { $version='2'; }
     if (!$version) { $version='2'; }
-    my $vlan_oid=$port_vlan_oid.".".$port_index;
+    my $vlan_oid=$dot1qPortVlanEntry.".".$port_index;
 #    print "$host,$community,$vlan_oid,$version\n";
 #    print "$host,$community,$vlan_oid,$version\n";
     my $vlan = snmp_get_req($host,$community,$vlan_oid,$version);
     my $vlan = snmp_get_req($host,$community,$vlan_oid,$version);
     return "1" if (!$vlan);
     return "1" if (!$vlan);
@@ -322,8 +322,8 @@ sub get_switch_vlans {
     if (!$version) { $version='2'; }
     if (!$version) { $version='2'; }
     my $result;
     my $result;
     #need for callback
     #need for callback
-    my $vlan_table = snmp_get_oid($host,$community,$port_vlan_oid,$version);
-    if (!$vlan_table) { $vlan_table=snmp_walk_oid($host,$community,$port_vlan_oid,$version); }
+    my $vlan_table = snmp_get_oid($host,$community,$dot1qPortVlanEntry,$version);
+    if (!$vlan_table) { $vlan_table=snmp_walk_oid($host,$community,$dot1qPortVlanEntry,$version); }
     if ($vlan_table) {
     if ($vlan_table) {
         foreach my $vlan_oid (keys %$vlan_table) {
         foreach my $vlan_oid (keys %$vlan_table) {
             if ($vlan_oid=~/\.([0-9]*)$/) { $result->{$1} = $vlan_table->{$vlan_oid}; }
             if ($vlan_oid=~/\.([0-9]*)$/) { $result->{$1} = $vlan_table->{$vlan_oid}; }

+ 1 - 0
updates/2-4-12/mysql-devices-patch.sql

@@ -24,3 +24,4 @@ DELETE FROM `config` WHERE `option_id` = 17;
 DELETE FROM `config` WHERE `option_id` = 19;
 DELETE FROM `config` WHERE `option_id` = 19;
 INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES (68, 'config_mode', 'Режим конфигурирования. Скрипт опроса устройств не выполняется.', 'Configuration mode. The device polling script is not running.', '1', 'bool', '0', '0', '1');
 INSERT INTO `config_options` (`id`, `option_name`, `description.russian`, `description.english`, `uniq`, `type`, `default_value`, `min_value`, `max_value`) VALUES (68, 'config_mode', 'Режим конфигурирования. Скрипт опроса устройств не выполняется.', 'Configuration mode. The device polling script is not running.', '1', 'bool', '0', '0', '1');
 ALTER TABLE `User_auth` ADD `dhcp_changed` INT NULL DEFAULT NULL AFTER `changed`;
 ALTER TABLE `User_auth` ADD `dhcp_changed` INT NULL DEFAULT NULL AFTER `changed`;
+ALTER TABLE `device_ports` ADD `tagged_vlan` VARCHAR(250) NULL DEFAULT NULL AFTER `vlan`, ADD `untagged_vlan` VARCHAR(250) NULL DEFAULT NULL AFTER `tagged_vlan`, ADD `forbidden_vlan` VARCHAR(250) NULL DEFAULT NULL AFTER `untagged_vlan`;