Changeset 818
- Timestamp:
- Mar 16, 2016, 10:01:02 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/UpdateTrace.php
r817 r818 1988 1988 $Manager->Execute('UPDATE `NetworkConfiguration` SET `SysName`="RouterosDNS" WHERE `Id`=13'); 1989 1989 $Manager->Execute('ALTER TABLE `NetworkConfiguration` DROP `Execute`;'); 1990 } 1991 1992 function UpdateTo818($Manager) 1993 { 1994 $Manager->Execute('ALTER TABLE `NetworkPort` ADD `Protocol` INT NOT NULL AFTER `Enabled`;'); 1995 $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkPortUpDown` ( 1996 `Id` int(11) NOT NULL AUTO_INCREMENT, 1997 `Time` datetime NOT NULL, 1998 `Port` int(11) NOT NULL, 1999 `State` int(11) NOT NULL, 2000 `Duration` int(11) DEFAULT NULL, 2001 PRIMARY KEY (`Id`), 2002 KEY `Port` (`Port`), 2003 KEY `Time` (`Time`) 2004 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;'); 2005 $Manager->Execute('ALTER TABLE `NetworkPortUpDown` 2006 ADD CONSTRAINT `NetworkPortUpDown_ibfk_1` FOREIGN KEY (`Port`) REFERENCES `NetworkPort` (`Id`);'); 1990 2007 } 1991 2008 … … 2080 2097 808 => array('Revision' => 814, 'Function' => 'UpdateTo814'), 2081 2098 814 => array('Revision' => 817, 'Function' => 'UpdateTo817'), 2099 817 => array('Revision' => 818, 'Function' => 'UpdateTo818'), 2082 2100 )); 2083 2101 } -
trunk/Application/Version.php
r817 r818 1 1 <?php 2 2 3 $Revision = 81 7; // Subversion revision4 $DatabaseRevision = 81 7; // SQL structure revision3 $Revision = 818; // Subversion revision 4 $DatabaseRevision = 818; // SQL structure revision 5 5 $ReleaseTime = strtotime('2016-03-16'); -
trunk/Modules/Network/Network.php
r817 r818 244 244 'Items' => array( 245 245 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 246 'Protocol' => array('Type' => 'TNetworkProtocol', 'Caption' => 'Protokol', 'Default' => '0'), 246 247 'Number' => array('Type' => 'Integer', 'Caption' => 'Číslo', 'Default' => ''), 247 248 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => ''), … … 249 250 'Online' => array('Type' => 'TOnlineState', 'Caption' => 'Běží', 'Default' => '0', 'ReadOnly' => true), 250 251 'LastOnline' => array('Type' => 'DateTime', 'Caption' => 'Naposledy běželo', 'Default' => '', 'ReadOnly' => true), 252 'UpDown' => array('Type' => 'TNetworkPortUpDown', 'Caption' => 'Změny stavu', 'Default' => ''), 251 253 ), 252 254 )); … … 490 492 ), 491 493 )); 494 $this->System->FormManager->RegisterClass('NetworkInterfaceUpDown', array( 495 'Title' => 'Změny stavu rozhraní', 496 'Table' => 'NetworkInterfaceUpDown', 497 'DefaultSortColumn' => 'Time', 498 'DefaultSortOrder' => 1, 499 'Items' => array( 500 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => '', 'ReadOnly' => true), 501 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'ReadOnly' => true), 502 'State' => array('Type' => 'TOnlineState', 'Caption' => 'Stav', 'Default' => '', 'ReadOnly' => true), 503 'Duration' => array('Type' => 'TimeDiff', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true), 504 ), 505 )); 506 $this->System->FormManager->RegisterClass('NetworkPortUpDown', array( 507 'Title' => 'Změny stavu portů', 508 'Table' => 'NetworkPortUpDown', 509 'DefaultSortColumn' => 'Time', 510 'DefaultSortOrder' => 1, 511 'Items' => array( 512 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => '', 'ReadOnly' => true), 513 'Port' => array('Type' => 'TNetworkPort', 'Caption' => 'Port', 'Default' => '', 'ReadOnly' => true), 514 'State' => array('Type' => 'TOnlineState', 'Caption' => 'Stav', 'Default' => '', 'ReadOnly' => true), 515 'Duration' => array('Type' => 'TimeDiff', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true), 516 ), 517 )); 518 $this->System->FormManager->RegisterFormType('TNetworkProtocol', array( 519 'Type' => 'Enumeration', 520 'States' => array('TCP', 'UDP'), 521 )); 492 522 $this->System->FormManager->RegisterFormType('TNetworkDevice', array( 493 523 'Type' => 'Reference', … … 513 543 'Filter' => '1', 514 544 )); 545 $this->System->FormManager->RegisterFormType('TNetworkPort', array( 546 'Type' => 'Reference', 547 'Table' => 'NetworkPort', 548 'View' => '(SELECT `NetworkPort`.*, CONCAT(CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")), ":", `NetworkPort`.`Number`) AS `PortName` FROM `NetworkPort` '. 549 'LEFT JOIN `NetworkInterface` ON `NetworkInterface`.`Id` = `NetworkPort`.`Interface` '. 550 'LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device`) AS `T`', 551 'Id' => 'Id', 552 'Name' => 'PortName', 553 'Filter' => '1', 554 )); 515 555 $this->System->FormManager->RegisterFormType('TNetworkInterfaceType', array( 516 556 'Type' => 'Reference', … … 597 637 'Filter' => '1', 598 638 )); 599 639 $this->System->FormManager->RegisterFormType('TNetworkPortUpDown', array( 640 'Type' => 'ManyToOne', 641 'Table' => 'NetworkPortUpDown', 642 'Id' => 'Id', 643 'Ref' => 'Port', 644 'Filter' => '1', 645 )); 646 600 647 $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Network', 601 648 array('ModuleNetwork', 'ShowDashboardItem')); -
trunk/Modules/NetworkConfigLinux/Generators/CheckPorts.php
r815 r818 3 3 class ConfigCheckPorts extends NetworkConfigItem 4 4 { 5 function CheckPortStatus($IP, $Port )5 function CheckPortStatus($IP, $Port, $Protocol = 'tcp') 6 6 { 7 7 $Timeout = 1; 8 8 $State = 0; 9 if($Socket = @fsockopen($IP, $Port, $ErrorNumber, $ErrorString, $Timeout)) 9 if($Protocol = 'tcp') $Prefix = ''; 10 else if($Protocol = 'udp') $Prefix = 'udp://'; 11 else throw new Exception('Unsupported protocol "'.$Protocol.'"'); 12 if($Socket = @fsockopen($Prefix.$IP, $Port, $ErrorNumber, $ErrorString, $Timeout)) 10 13 { 11 14 fclose($Socket); … … 21 24 // Load all ports to memory 22 25 $Ports = array(); 23 $DbResult = $this->Database->query('SELECT `NetworkPort`.`Id`, `NetworkPort`.`Number`, '.26 $DbResult = $this->Database->query('SELECT `NetworkPort`.`Id`, `NetworkPort`.`Number`, `NetworkPort`.`Protocol`, '. 24 27 '`NetworkPort`.`Online`, 0 AS `NewOnline`, `NetworkInterface`.`LocalIP` AS `LocalIP` '. 25 28 'FROM `NetworkPort` '. … … 31 34 foreach($Ports as $Index => $Port) 32 35 { 33 $Port['NewOnline'] = $this->CheckPortStatus($Port['LocalIP'], $Port['Number']); 36 if($Port['Protocol'] == 0) $Port['Protocol'] = 'tcp'; 37 if($Port['Protocol'] == 1) $Port['Protocol'] = 'udp'; 38 $Port['NewOnline'] = $this->CheckPortStatus($Port['LocalIP'], $Port['Number'], $Port['Protocol']); 34 39 35 40 // Update last online time if still online … … 37 42 { 38 43 $DbResult = $this->Database->update('NetworkPort', '`Id` = "'.$Port['Id'].'"', 39 array('LastOnline' => TimeToMysqlDateTime($StartTime))); 44 array('Online' => 1, 'LastOnline' => TimeToMysqlDateTime($StartTime))); 45 } 46 47 // Update UpDown table 48 if($Port['Online'] != $Port['NewOnline']) 49 { 50 // Online state changed 51 $DbResult = $this->Database->query('INSERT INTO `NetworkPortUpDown` (`Port`, 52 `State`, `Time`, `Duration`) VALUES ('.$Port['Id'].', '.$Port['NewOnline'].', "'. 53 TimeToMysqlDateTime($StartTime).'", NULL)'); 54 // Update previous record duration in UpDown table 55 $this->Database->query('UPDATE `NetworkPortUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND, '. 56 '`TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkPortUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`) '. 57 'AND (`TA`.`Port`=`TM`.`Port`) ORDER BY `TA`.`Time` ASC LIMIT 1)) '. 58 'WHERE (`TM`.`Duration` IS NULL) AND (`TM`.`Interface` ='.$Port['Id'].')'); 40 59 } 41 60 } 42 61 $DbResult = $this->Database->update('NetworkDevice', '`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'"', array('Online' => 0)); 62 43 63 // Set offline all ports which were not updated as online 44 64 $DbResult = $this->Database->select('NetworkPort', '*', '(`Online` = 1) AND '. -
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r793 r818 49 49 array('LastOnline' => TimeToMysqlDateTime($StartTime))); 50 50 51 52 53 54 55 `State`, `Time`, `Duration`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'.56 57 58 59 60 61 62 63 64 51 if($Interface['Online'] != $Interface['NewOnline']) 52 { 53 // Online state changed 54 $DbResult = $this->Database->query('INSERT INTO `NetworkInterfaceUpDown` (`Interface`, 55 `State`, `Time`, `Duration`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'. 56 TimeToMysqlDateTime($StartTime).'", NULL)'); 57 // Update previous record duration in UpDown table 58 $this->Database->query('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND, '. 59 '`TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`) '. 60 'AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1)) '. 61 'WHERE (`TM`.`Duration` IS NULL) AND (`TM`.`Interface` ='.$Interface['Id'].')'); 62 $this->Database->update('NetworkInterface', '`Id` = "'.$Interface['Id'].'"', 63 array('Online' => $Interface['NewOnline'])); 64 } 65 65 } 66 66 -
trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php
r781 r818 40 40 { 41 41 $this->System->Pages['zdarma'] = 'PageFreeAccess'; 42 $this->System->FormManager->RegisterClass('NetworkInterfaceUpDown', array(43 'Title' => 'Změny stavu rozhraní',44 'Table' => 'NetworkInterfaceUpDown',45 'DefaultSortColumn' => 'Time',46 'DefaultSortOrder' => 1,47 'Items' => array(48 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => '', 'ReadOnly' => true),49 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'ReadOnly' => true),50 'State' => array('Type' => 'TOnlineState', 'Caption' => 'Stav', 'Default' => '', 'ReadOnly' => true),51 'Duration' => array('Type' => 'TimeDiff', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true),52 ),53 ));54 55 42 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-dns', 'ConfigRouterOSDNS'); 56 43 $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-dhcp', 'ConfigRouterOSDHCP');
Note:
See TracChangeset
for help on using the changeset viewer.