Changeset 829
- Timestamp:
- Apr 29, 2016, 11:54:31 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/UpdateTrace.php
r824 r829 2020 2020 ADD CONSTRAINT `NetworkInterfaceLatency_ibfk_1` FOREIGN KEY (`Interface`) REFERENCES `NetworkInterface` (`Id`);'); 2021 2021 } 2022 2023 /* 2024 function UpdateTo829($Manager) 2025 { 2026 $Manager->Execute('ALTER TABLE `NetworkLinkType` '. 2027 'ADD `MaxLinkSpeed` INT NOT NULL AFTER `Name`, '. 2028 'ADD `MaxRealSpeed` INT NOT NULL AFTER `MaxLinkSpeed`, '. 2029 'ADD `FullDuplex` INT NOT NULL AFTER `MaxRealSpeed`, '. 2030 'ADD `Color` VARCHAR(6) NOT NULL AFTER `FullDuplex`'); 2031 } 2032 */ 2022 2033 2023 2034 class Updates … … 2113 2124 817 => array('Revision' => 818, 'Function' => 'UpdateTo818'), 2114 2125 818 => array('Revision' => 824, 'Function' => 'UpdateTo824'), 2126 //824 => array('Revision' => 829, 'Function' => 'UpdateTo829'), 2115 2127 )); 2116 2128 } -
trunk/Modules/Network/Network.php
r825 r829 100 100 { 101 101 var $MinNotifyTime; 102 102 103 103 function __construct($System) 104 104 { … … 110 110 $this->Description = 'Networking related tools'; 111 111 $this->Dependencies = array('Notify'); 112 112 113 113 // TODO: Make notify time configurable 114 $this->MinNotify time = 2 * 60;114 $this->MinNotifyTime = 2 * 60; 115 115 } 116 116 … … 125 125 function DoStart() 126 126 { 127 $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkReachability', 127 $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkReachability', 128 128 array($this, 'ReachabilityCheck')); 129 $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkPort', 129 $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkPort', 130 130 array($this, 'PortCheck')); 131 132 131 132 133 133 $this->System->RegisterPage('network', 'PageNetwork'); 134 134 $this->System->RegisterPage(array('network', 'administration'), 'PageNetworkAdministration'); … … 297 297 'Items' => array( 298 298 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''), 299 'MaxLinkSpeed' => array('Type' => 'Integer', 'Caption' => 'Maximální spojová rychlost', 'Default' => '0', 'Suffix' => 'bits/s'), 300 'MaxRealSpeed' => array('Type' => 'Integer', 'Caption' => 'Maximální reálná rychlost', 'Default' => '0', 'Suffix' => 'bits/s'), 301 'FullDuplex' => array('Type' => 'Boolean', 'Caption' => 'Plně duplexní', 'Default' => '0'), 302 'Color' => array('Type' => 'Color', 'Caption' => 'Barva', 'Default' => '0'), 299 303 ), 300 304 )); … … 669 673 'Filter' => '1', 670 674 )); 671 675 672 676 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Network', 673 677 array('ModuleNetwork', 'ShowDashboardItem')); … … 680 684 )); 681 685 } 682 686 683 687 function AfterInsertNetworkDevice($Form) 684 688 { … … 690 694 $this->System->Models['NetworkDevice']->DoOnChange(); 691 695 } 692 696 693 697 function AfterInsertNetworkInterface($Form) 694 698 { … … 700 704 $this->System->Models['NetworkInterface']->DoOnChange(); 701 705 } 702 706 703 707 function BeforeDeleteNetworkInterface($Form, $Id) 704 708 { … … 734 738 { 735 739 } 736 740 737 741 function OnlineList($Title, $OnlineNow, $OnlinePrevious, $MinDuration) 738 742 { … … 748 752 '(`NetworkInterface`.`LocalIP` != "") AND (`NetworkInterface`.`Enabled`=1)'. 749 753 'ORDER BY `Name` ASC'); 750 if($DbResult3->num_rows > 0) 754 if($DbResult3->num_rows > 0) 751 755 { 752 756 $Output .= $Title.'<br/>'; … … 780 784 return($Output); 781 785 } 782 786 783 787 function PortCheckList($Title, $OnlineNow, $OnlinePrevious, $MinDuration) 784 788 { … … 808 812 $Days = floor($Duration / (60 * 60 * 24)); 809 813 if($Days > 0) $DurationText = $Days.' dnů '.$DurationText; 810 814 811 815 $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']]. 812 816 '</td><td>'.$Item['LastOnline'].'</td><td>'.$DurationText.'</td></tr>'."\n"; … … 818 822 return $Output; 819 823 } 820 824 821 825 function PortCheck() 822 826 { -
trunk/Modules/NetworkConfigRouterOS/Generators/Netwatch.php
r790 r829 31 31 if($Interface['Name'] != '') $Name .= '-'.$Interface['Name']; 32 32 echo($Name.', '); 33 $Items[] = array('host' => $Interface['LocalIP'], 'interval' => '00:0 1:00', 'comment' => $Name);33 $Items[] = array('host' => $Interface['LocalIP'], 'interval' => '00:00:30', 'comment' => $Name); 34 34 } 35 35 } -
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r818 r829 91 91 function Run() 92 92 { 93 RepeatFunction( 60, array($this, 'NetwatchImport'));93 RepeatFunction(30, array($this, 'NetwatchImport')); 94 94 } 95 95 } -
trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php
r781 r829 13 13 function Run() 14 14 { 15 //print_r($this->BuildTree($this->System->Config['MainRouter']['DeviceId'], 140 * 1000 * 1000)); 16 //die(); 17 15 18 $PathQueue = array('queue', 'tree'); 16 19 … … 74 77 echo('Zákazník '.$Member['Name']."\n"); 75 78 $DbResult4 = $this->Database->query('SELECT `Service`.*, `ServiceCustomerRel`.`Id` AS `RelId` FROM `ServiceCustomerRel` '. 76 77 78 79 'JOIN `Service` ON `Service`.`Id` = `ServiceCustomerRel`.`Service` '. 80 'WHERE (`ServiceCustomerRel`.`Customer` = '.$Member['Id'].') AND (`ServiceCustomerRel`.`ChangeAction` IS NULL) '. 81 'AND (`Service`.`InternetSpeedMax` > 0) AND (`Service`.`InternetSpeedMin` > 0)'); 79 82 while($Service = $DbResult4->fetch_assoc()) 80 83 { … … 147 150 $Routerboard->ListUpdate($PathQueue, array('name', 'limit-at', 'max-limit', 'parent', 'packet-mark'), $ItemsQueue, array(), true); 148 151 } 152 153 // Calculate maximum real speed available for each network device Start with main router and continue with adjecement nodes. 154 function BuildTree($RootDeviceId, $BaseSpeed) 155 { 156 // Load network devices 157 $Devices = array(); 158 $DbResult = $this->Database->query('SELECT `Name`,`Id` FROM `NetworkDevice`'); 159 while($Device = $DbResult->fetch_assoc()) 160 { 161 $Device['Interfaces'] = array(); 162 $Device['Calculated'] = false; 163 $Device['MaxSpeed'] = 0; 164 $Devices[$Device['Id']] = $Device; 165 } 166 167 // Load network interfaces and assign them to device 168 $Interfaces = array(); 169 $DbResult = $this->Database->query('SELECT `Device`,`Name`,`Id` FROM `NetworkInterface`'); 170 while($Interface = $DbResult->fetch_assoc()) 171 { 172 $Interface['Links'] = array(); 173 $Interfaces[$Interface['Id']] = $Interface; 174 $Devices[$Interface['Device']]['Interfaces'][] = $Interface['Id']; 175 } 176 177 // Load network links and assign them to interfaces 178 $Links = array(); 179 $DbResult = $this->Database->query('SELECT `NetworkLink`.`Id`,`NetworkLink`.`Interface1`,'. 180 '`NetworkLink`.`Interface2`,`NetworkLinkType`.`MaxRealSpeed` FROM `NetworkLink` '. 181 'LEFT JOIN `NetworkLinkType` ON `NetworkLinkType`.`Id`=`NetworkLink`.`Type`'); 182 while($Link = $DbResult->fetch_assoc()) 183 { 184 $Links[$Link['Id']] = $Link; 185 $Interfaces[$Link['Interface1']]['Links'][] = $Link['Id']; 186 $Interfaces[$Link['Interface2']]['Links'][] = $Link['Id']; 187 } 188 189 $DevicesToCheck = array($RootDeviceId); 190 $Devices[$RootDeviceId]['MaxSpeed'] = $BaseSpeed; 191 $Devices[$RootDeviceId]['Calculated'] = true; 192 193 while(count($DevicesToCheck) > 0) 194 { 195 echo('Pass'."\n"); 196 $NewDevicesToCheck = array(); 197 foreach($DevicesToCheck as $DeviceId) 198 { 199 echo($Devices[$DeviceId]['Name'].': '); 200 foreach($Devices[$DeviceId]['Interfaces'] as $InterfaceId) 201 { 202 foreach($Interfaces[$InterfaceId]['Links'] as $LinkId) 203 { 204 $Link = $Links[$LinkId]; 205 $Interface2Id = $Link['Interface1']; 206 if($Interface2Id == $InterfaceId) $Interface2Id = $Links[$LinkId]['Interface2']; 207 208 $Device2Id = $Interfaces[$Interface2Id]['Device']; 209 if($Devices[$Device2Id]['Calculated'] == false) 210 { 211 $Devices[$Device2Id]['Calculated'] = true; 212 $NewMaxSpeed = $Devices[$DeviceId]['MaxSpeed']; 213 if($NewMaxSpeed > $Link['MaxRealSpeed']) 214 $NewMaxSpeed = $Link['MaxRealSpeed']; 215 echo($Devices[$Device2Id]['Name'].' '.$Device2Id.', '); 216 $Devices[$Device2Id]['MaxSpeed'] = $NewMaxSpeed; 217 echo($NewMaxSpeed.", ".count($NewDevicesToCheck).' '); 218 $NewDevicesToCheck[] = $Device2Id; 219 } 220 } 221 } 222 echo("\n"); 223 } 224 $DevicesToCheck = $NewDevicesToCheck; 225 } 226 //print_r($Devices); 227 228 echo('Not linked network devices: '); 229 foreach($Devices as $Device) 230 { 231 if($Device['MaxSpeed'] == 0) echo($Device['Name'].', '); 232 } 233 echo("\n"); 234 235 $Tree = array(); 236 return($Tree); 237 } 149 238 }
Note:
See TracChangeset
for help on using the changeset viewer.