- Timestamp:
- Oct 2, 2013, 8:26:20 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r548 r575 12 12 $StartTime = time(); 13 13 14 // Load netwatch status from all DHCP routers 14 15 $DbResult3 = $System->Database->query('SELECT DHCP, AddressRange, Mask FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP'); 15 //echo($DbResult3->num_rows);16 16 while($Subnet = $DbResult3->fetch_assoc()) 17 17 { … … 24 24 foreach($List as $Properties) 25 25 { 26 //echo($Properties['host'].', ');27 26 if($Properties['status'] == 'up') 28 27 { 29 $Online = 1; 30 $Values = array('Online' => $Online, 'LastOnline' => 'NOW()'); 31 //echo($Properties['host']." up\n"); 32 } else 33 { 34 $Online = 0; 35 $Values = array('Online' => $Online); 36 //echo($Properties['host']." down\n"); 37 } 38 39 $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values); 28 $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', 29 array('Online' => $Online, 'LastOnline' => TimeToMysqlDateTime($StartTime))); 30 } 40 31 } 41 } 32 } 33 $DbResult = $System->Database->update('NetworkInterface', '`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'"', array('Online' => 0)); 42 34 43 35 // Update device online state 44 $DbResult = $System->Database->select('Network Device', 'Id', '`Used`=1');36 $DbResult = $System->Database->select('NetworkInterface', '`Device`, SUM(`Online`) AS `SumOnline`', '`Online` = 1 GROUP BY `Device`'); 45 37 while($Device = $DbResult->fetch_assoc()) 46 38 { 47 $DbResult2 = $System->Database->select('NetworkInterface', 'SUM(`Online`) AS `SumOnline`', '`Device`='.$Device['Id']); 48 $DbRow = $DbResult2->fetch_array(); 49 if($DbRow['SumOnline'] > 0) $Online = 1; 50 else $Online = 0; 51 $Values = array('Online' => $Online); 52 if($Online == 1) $Values['LastOnline'] = 'NOW()'; 53 $System->Database->update('NetworkDevice', 'Id='.$Device['Id'], $Values); 39 if($Device['SumOnline'] > 0) 40 $System->Database->update('NetworkDevice', 'Id='.$Device['Device'], array('LastOnline' => TimeToMysqlDateTime($StartTime))); 54 41 } 42 $DbResult = $System->Database->update('NetworkDevice', '`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'"', array('Online' => 0)); 55 43 56 44 // Update interface online statistics
Note:
See TracChangeset
for help on using the changeset viewer.