Changeset 852 for trunk/Modules
- Timestamp:
- Oct 25, 2017, 10:55:05 PM (7 years ago)
- Location:
- trunk/Modules
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigLinux/Generators/Latency.php
r842 r852 22 22 exec('fping -e -r '.$RetryLimit.' -t '.$Timeout.' -a '.implode(' ', $Hosts).' 2>/dev/null', $Output); 23 23 24 $this->Database->query('BEGIN'); 25 foreach($Output as $Index => $Line) { 24 $Queries = array(); 25 foreach($Output as $Index => $Line) 26 { 26 27 $IP = substr($Line, 0, strPos($Line, ' ')); 27 28 $Line = substr($Line, strpos($Line, '(') + 1); 28 29 $Value = substr($Line, 0, strpos($Line, ' ')); 29 30 //echo($IP.' '.$Value."\n"); 30 $ this->Database->insert('NetworkInterfaceLatency', array('Interface' => $HostInterface[$IP],31 $Queries[] = $this->Database->GetInsert('NetworkInterfaceLatency', array('Interface' => $HostInterface[$IP], 31 32 'Value' => $Value, 'Time' => TimeToMysqlDateTime($Time))); 32 33 } 33 $this->Database-> query('COMMIT');34 $this->Database->Transaction($Queries); 34 35 } 35 36 -
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r841 r852 42 42 } 43 43 44 $this->Database->query('BEGIN'); 45 44 $Queries = array(); 46 45 foreach($Interfaces as $Index => $Interface) 47 46 { 48 47 // Update last online time if still online 49 48 if($Interface['NewOnline']) 50 $ DbResult = $this->Database->update('NetworkInterface', '`Id` = "'.$Interface['Id'].'"',49 $Queries[] = $this->Database->GetUpdate('NetworkInterface', '`Id` = "'.$Interface['Id'].'"', 51 50 array('LastOnline' => TimeToMysqlDateTime($StartTime))); 52 51 … … 54 53 { 55 54 // Online state changed 56 $ DbResult = $this->Database->query('INSERT INTO `NetworkInterfaceUpDown` (`Interface`,55 $Queries[] = 'INSERT INTO `NetworkInterfaceUpDown` (`Interface`, 57 56 `State`, `Time`, `Duration`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'. 58 TimeToMysqlDateTime($StartTime).'", NULL)' );57 TimeToMysqlDateTime($StartTime).'", NULL)'; 59 58 // Update previous record duration in UpDown table 60 $ this->Database->query('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND, '.59 $Queries[] = 'UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND, '. 61 60 '`TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`) '. 62 61 'AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1)) '. 63 'WHERE (`TM`.`Duration` IS NULL) AND (`TM`.`Interface` ='.$Interface['Id'].')' );64 $ this->Database->update('NetworkInterface', '`Id` = "'.$Interface['Id'].'"',62 'WHERE (`TM`.`Duration` IS NULL) AND (`TM`.`Interface` ='.$Interface['Id'].')'; 63 $Queries[] = $this->Database->GetUpdate('NetworkInterface', '`Id` = "'.$Interface['Id'].'"', 65 64 array('Online' => $Interface['NewOnline'])); 66 65 } 67 66 } 67 $this->Database->Transaction($Queries); 68 68 69 69 // Set offline all interfaces which were not updated as online … … 81 81 } 82 82 83 $Queries = array(); 83 84 // Update device online state 84 85 $DbResult = $this->Database->select('NetworkInterface', '`Device`, SUM(`Online`) AS `SumOnline`', '`Online` = 1 GROUP BY `Device`'); … … 86 87 { 87 88 if($Device['SumOnline'] > 0) 88 $ this->Database->update('NetworkDevice', 'Id='.$Device['Device'], array('LastOnline' => TimeToMysqlDateTime($StartTime), 'Online' => 1));89 $Queries[] = $this->Database->GetUpdate('NetworkDevice', 'Id='.$Device['Device'], array('LastOnline' => TimeToMysqlDateTime($StartTime), 'Online' => 1)); 89 90 } 90 $this->Database->update('NetworkDevice', '`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'"', array('Online' => 0)); 91 92 $this->Database->query('COMMIT'); 91 $Queries[] = $this->Database->GetUpdate('NetworkDevice', '`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'"', array('Online' => 0)); 92 $this->Database->Transaction($Queries); 93 93 } 94 94
Note:
See TracChangeset
for help on using the changeset viewer.