Changeset 855 for trunk/Modules/Network/Network.php
- Timestamp:
- Apr 8, 2018, 7:40:10 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Network/Network.php
r849 r855 142 142 $this->System->RegisterPage(array('network', 'frequency-plan'), 'PageFrequencyPlan'); 143 143 144 $this->System->RegisterCommandLine('config', array($this, 'ImportNetworkLog')); 145 144 146 $this->System->FormManager->RegisterClass('NetworkDomainAlias', array( 145 147 'Title' => 'Alias domény', … … 178 180 'LoginPassword' => array('Type' => 'String', 'Caption' => 'Přihlašovací heslo', 'Default' => '', 'Null' => true, 'NotInList' => true), 179 181 'API' => array('Type' => 'TDeviceAPIType', 'Caption' => 'API', 'Default' => '', 'Null' => true), 182 'Logs' => array('Type' => 'TDeviceLogList', 'Caption' => 'Záznamy', 'Default' => ''), 180 183 ), 181 184 'AfterInsert' => array($this, 'AfterInsertNetworkDevice'), … … 190 193 'ShowOnline' => array('Type' => 'Boolean', 'Caption' => 'Ukázat online', 'Default' => '0'), 191 194 'IconName' => array('Type' => 'String', 'Caption' => 'Jméno ikony', 'Default' => '0'), 195 ), 196 )); 197 $this->System->FormManager->RegisterClass('NetworkDeviceLog', array( 198 'Title' => 'Zprávy zařízení', 199 'Table' => 'NetworkDeviceLog', 200 'DefaultSortColumn' => 'Time', 201 'DefaultSortOrder' => 1, 202 'Items' => array( 203 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''), 204 'Device' => array('Type' => 'TNetworkDevice', 'Caption' => 'Zařízení', 'Default' => ''), 205 'Message' => array('Type' => 'String', 'Caption' => 'Zpáva', 'Default' => ''), 206 'Tags' => array('Type' => 'String', 'Caption' => 'Značky', 'Default' => ''), 192 207 ), 193 208 )); … … 650 665 'Filter' => '1', 651 666 )); 667 $this->System->FormManager->RegisterFormType('TDeviceLogList', array( 668 'Type' => 'ManyToOne', 669 'Table' => 'NetworkDeviceLog', 670 'Id' => 'Id', 671 'Ref' => 'Device', 672 'Filter' => '1', 673 )); 652 674 $this->System->FormManager->RegisterFormType('TNetworkLinkListInterface', array( 653 675 'Type' => 'ManyToOne', … … 725 747 $this->Database->query('DELETE FROM `NetworkInterfaceWireless` WHERE `NetworkInterface`='.$Id); 726 748 $this->Database->query('DELETE FROM `NetworkInterfaceLatency` WHERE `Interface`='.$Id); 749 } 750 751 function ImportNetworkLog($Parameters) 752 { 753 global $Config; 754 755 $DbResult = $this->System->Database->select('NetworkDeviceLog', 'Time', 756 '1 ORDER BY Time DESC LIMIT 1'); 757 if ($DbResult->num_rows > 0) 758 { 759 $DbRow = $DbResult->fetch_assoc(); 760 $WhereTime = ' AND (`Time` > "'.$DbRow['Time'].'")'; 761 } else $WhereTime = ''; 762 763 $RemoteDb = new Database(); 764 $RemoteDb->Connect($Config['NetworkLog']['Host'], $Config['NetworkLog']['User'], 765 $Config['NetworkLog']['Password'], $Config['NetworkLog']['Database']); 766 $DbResult = $RemoteDb->select('SystemEvents', '*', '`ReceivedAt`>"'. TimeToMysqlDate($StartTime).'"'.$WhereTime.' ORDER BY `Time` DESC'); 767 while ($DbRow = $DbResult->fetch_array()) 768 { 769 $DbResult2 = $this->System->Database->select('NetworkInterface', 'Device, CONCAT(CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")), ".") AS `Name` ', '`Name` LIKE "'.$DbRow['FromHost'].'"'); 770 if ($DbResult2->num_rows > 0) 771 { 772 $DbRow2 = $DbResult2->fetch_assoc(); 773 $DeviceID = $DbRow2['Device']; 774 $this->System->Database->insert('NetworkDeviceLog', array('Time' => $DbRow['ReceivedAt'], 775 'Device' => $DeviceId, 'Message' => $DbRow['Message'], 'Tags' => $DbRow['SysLogTag'])); 776 } else echo('Host '.$DbRow['Host'].' not paired with network device.'."\n"); 777 } 727 778 } 728 779
Note:
See TracChangeset
for help on using the changeset viewer.