- Timestamp:
- Apr 15, 2013, 11:08:49 PM (12 years ago)
- Location:
- trunk/Modules/NetworkConfigRouterOS
- Files:
-
- 2 added
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php
r521 r522 2 2 3 3 if(isset($_SERVER['REMOTE_ADDR'])) die(); 4 include ('../../Common/Global.php');5 include ('../routerboard.php');6 include ('common.php');4 include_once(dirname(__FILE__).'/../../../Common/Global.php'); 5 include_once(dirname(__FILE__).'/../Routerboard.php'); 6 include_once('Common.php'); 7 7 $Path = array('tool', 'netwatch'); 8 8 $Period = 60; // every 60 seconds 9 $Database = &$System->Database;10 9 11 10 while(1) … … 13 12 $StartTime = time(); 14 13 15 $DbResult3 = $ Database->query('SELECT DHCP, AddressRange, Mask FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP');14 $DbResult3 = $System->Database->query('SELECT DHCP, AddressRange, Mask FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP'); 16 15 //echo($DbResult3->num_rows); 17 16 while($Subnet = $DbResult3->fetch_assoc()) … … 38 37 } 39 38 40 $DbResult = $ Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values);39 $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values); 41 40 } 42 41 } 43 42 44 43 // Update device online state 45 $DbResult = $ Database->select('NetworkDevice', 'Id', '`Used`=1');44 $DbResult = $System->Database->select('NetworkDevice', 'Id', '`Used`=1'); 46 45 while($Device = $DbResult->fetch_assoc()) 47 46 { 48 $DbResult2 = $ Database->select('NetworkInterface', 'SUM(`Online`) AS `SumOnline`', '`Device`='.$Device['Id']);47 $DbResult2 = $System->Database->select('NetworkInterface', 'SUM(`Online`) AS `SumOnline`', '`Device`='.$Device['Id']); 49 48 $DbRow = $DbResult2->fetch_array(); 50 49 if($DbRow['SumOnline'] > 0) $Online = 1; … … 52 51 $Values = array('Online' => $Online); 53 52 if($Online == 1) $Values['LastOnline'] = 'NOW()'; 54 $ Database->update('NetworkDevice', 'Id='.$Device['Id'], $Values);53 $System->Database->update('NetworkDevice', 'Id='.$Device['Id'], $Values); 55 54 } 56 55 57 56 // Update interface online statistics 58 $DbResult = $ Database->select('NetworkInterface', 'Id', '`Online` = 1');57 $DbResult = $System->Database->select('NetworkInterface', 'Id', '`Online` = 1'); 59 58 while($Interface = $DbResult->fetch_assoc()) 60 59 { 61 $DbResult2 = $ Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');62 if($DbResult2->num_rows == 0) $ Database->query('REPLACE INTO `NetworkInterfaceStat` (`NetworkInterface`, `Time`, `PingCount`) VALUES ("'.$Interface['Id'].'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), 1)');63 else $ Database->query('UPDATE `NetworkInterfaceStat` SET `PingCount` = `PingCount` + 1 WHERE (`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');60 $DbResult2 = $System->Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))'); 61 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)'); 62 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"))'); 64 63 } 65 64
Note:
See TracChangeset
for help on using the changeset viewer.