- Timestamp:
- Oct 4, 2019, 9:37:59 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r861 r862 44 44 $Queries = array(); 45 45 $QueriesInsert = array(); 46 $QueriesUpdate = array();47 46 foreach($Interfaces as $Index => $Interface) 48 47 { … … 56 55 // Online state changed 57 56 $QueriesInsert[] = 'INSERT INTO `NetworkInterfaceUpDown` (`Interface`,'. 58 '`State`, `Time`, `Duration`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'. 59 TimeToMysqlDateTime($StartTime).'", NULL)'; 60 // Update previous record duration in UpDown table 61 $QueriesUpdate[] = 'UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND, '. 62 '`TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`) '. 63 'AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1)) '. 64 'WHERE (`TM`.`Duration` IS NULL) AND (`TM`.`Interface` ='.$Interface['Id'].')'; 57 '`State`, `Time`, `Previous`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'. 58 TimeToMysqlDateTime($StartTime).'", (SELECT MAX(T2.Id) FROM NetworkInterfaceUpDown AS T2 WHERE T2.Interface='.$Interface['Id'].'))'; 65 59 $Queries[] = $this->Database->GetUpdate('NetworkInterface', '`Id` = "'.$Interface['Id'].'"', 66 60 array('Online' => $Interface['NewOnline'])); … … 73 67 $this->Database->Transaction($Queries); 74 68 echo("done\n"); 75 echo("transakce\n"); 76 $this->Database->Transaction($QueriesUpdate);77 echo("done\n");69 70 // Update Duration for new items 71 $this->Database->query('UPDATE NetworkInterfaceUpDown AS T1, NetworkInterfaceUpDown AS T2 SET T1.Duration = TIMESTAMPDIFF(SECOND, T1.Time, T2.Time) WHERE (T2.Previous = T1.Id) AND (T2.Interface = T1.Interface) AND (T1.Duration IS NULL)'); 78 72 79 73 // Set offline all interfaces which were not updated as online
Note:
See TracChangeset
for help on using the changeset viewer.