- Timestamp:
- May 26, 2014, 1:00:20 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r657 r658 14 14 $StartTime = time(); 15 15 16 // Load netwatch status from all DHCP routers 16 // Load netwatch status from all DHCP routers 17 17 $DbResult3 = $System->Database->query('SELECT `DHCP`, `AddressRange`, `Mask` FROM `NetworkSubnet` '. 18 18 'WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP'); … … 29 29 if($Properties['status'] == 'up') $Online = 1; 30 30 else $Online = 0; 31 32 $DbResult = $System->Database->select('NetworkInterface', ' Online', '`LocalIP` = "'.$Properties['host'].'";');31 32 $DbResult = $System->Database->select('NetworkInterface', '`Id`,`Online`', '`LocalIP` = "'.$Properties['host'].'";'); 33 33 while($DbRow = $DbResult->fetch_assoc()) 34 34 { 35 35 $LastOnline = $DbRow['Online']; 36 $Interface = $DbRow[' NetworkInterface'];37 36 $Interface = $DbRow['Id']; 37 38 38 // Record state changes 39 39 if($Online != $LastOnline) 40 { 40 { 41 41 $System->Database->insert('NetworkInterfaceUpDown', array( 42 42 'Interface' => $Interface, 'State' => $Online, 'Time' => TimeToMysqlDateTime($StartTime))); 43 43 } 44 } ;45 44 } 45 46 46 if($Online) 47 47 { 48 $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', 48 $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', 49 49 array('Online' => 1, 'LastOnline' => TimeToMysqlDateTime($StartTime))); 50 } 50 } 51 51 } 52 } 52 } 53 53 $DbResult = $System->Database->update('NetworkInterface', '`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'"', array('Online' => 0)); 54 54 … … 67 67 { 68 68 $DbResult2 = $System->Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 69 if($DbResult2->num_rows == 0) $System->Database->query('REPLACE INTO `NetworkInterfaceStat` (`NetworkInterface`, `Time`, `PingCount`) VALUES ("'.$Interface['Id'].'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), 1)'); 69 if($DbResult2->num_rows == 0) $System->Database->query('REPLACE INTO `NetworkInterfaceStat` (`NetworkInterface`, `Time`, `PingCount`) VALUES ("'.$Interface['Id'].'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), 1)'); 70 70 else $System->Database->query('UPDATE `NetworkInterfaceStat` SET `PingCount` = `PingCount` + 1 WHERE (`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 71 71 }
Note:
See TracChangeset
for help on using the changeset viewer.