Changeset 671 for trunk/Modules/NetworkConfigRouterOS
- Timestamp:
- Jul 19, 2014, 1:21:24 AM (10 years ago)
- Location:
- trunk/Modules/NetworkConfigRouterOS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php
r666 r671 12 12 { 13 13 $StartTime = time(); 14 $Function(); 14 $Function(); 15 15 $EndTime = time(); 16 16 $Delay = $Period - ($EndTime - $StartTime); … … 19 19 echo('Waiting '.$Delay.' seconds...'."\n"); 20 20 sleep($Delay); 21 } 21 } print_r($Properties); 22 22 23 } 23 24 … … 25 26 { 26 27 global $System, $Config; 27 28 28 29 $Path = array('interface', 'wireless', 'registration-table'); 30 $Time = time(); 29 31 30 // Load netwatch status from all DHCP routers 31 $DbResult3 = $System->Database->query('SELECT DHCP, AddressRange, Mask FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP'); 32 while($Subnet = $DbResult3->fetch_assoc()) 32 // Load netwatch status from all DHCP routers 33 $DbResult3 = $System->Database->query('SELECT `Id`, '. 34 '(SELECT `LocalIP` FROM `NetworkInterface` WHERE `NetworkInterface`.`Device` = `NetworkDevice`.`Id` LIMIT 1) AS `LocalIP` '. 35 'FROM `NetworkDevice` WHERE (`API` = 1) AND (`Used` = 1)'); 36 while($Device = $DbResult3->fetch_assoc()) 33 37 { 34 echo($ Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n");38 echo($Device['LocalIP']."\n"); 35 39 $Routerboard = new Routerboard(); 36 40 $Routerboard->UserName = $Config['MainRouter']['UserName']; 37 41 $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout']; 38 $Routerboard->HostName = $Subnet['DHCP']; 39 $List = $Routerboard->ListGetPrint($Path, array('mac-address', 'signal-strength')); 42 $Routerboard->HostName = $Device['LocalIP']; 43 $Routerboard->Debug = true; 44 $List = $Routerboard->ListGetPrint($Path, array('mac-address', 'signal-strength'), array(), 'stats'); 40 45 foreach($List as $Properties) 41 46 { 47 print_r($Properties); 48 $DbResult = $System->Database->select('NetworkInterface', 'Id', 'MAC="'.$Properties['mac-address'].'"'); 49 if($DbResult->num_rows > 0) 50 { 51 $DbRow = $DbResult->fetch_assoc(); 52 $Interface = $DbRow['Id']; 53 } else $Interface = null; 54 $System->Database->insert('NetworkSignal', array('MAC' => $Properties['mac-address'], 55 'Value' => $Properties['signal-strength'], 'Time' => $Time, 'Interface' => $Interface)); 56 /* 42 57 $DbResult = $System->Database->select('Measure', 'Id', '`Name` = "'.$Properties['mac-address'].'"'); 43 58 if($DbResult->num_rows > 0) … … 52 67 $Measure->Load($Id); 53 68 $Measure->AddValue($Properties['signal-strength']); 69 */ 54 70 } 55 } 71 } 56 72 } 57 73 -
trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php
r548 r671 11 11 var $Timeout; // Connection attempt timeout and data read timeout 12 12 var $Socket; // Variable for storing socket resource 13 13 14 14 function __construct() 15 15 { … … 43 43 if($this->Connected) $this->Disconnect(); 44 44 $this->Socket = @fsockopen($IP, $this->Port, $this->ErrorNo, $this->ErrorStr, $this->Timeout); 45 if($this->Socket) 45 if($this->Socket) 46 46 { 47 47 socket_set_timeout($this->Socket, $this->Timeout); … … 59 59 } 60 60 } 61 if(!$this->Connected) fclose($this->Socket); 62 } 63 } 64 61 if(!$this->Connected) fclose($this->Socket); 62 } 63 } 64 65 65 function Connect($IP, $Login, $Password) 66 66 { 67 for($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++) 67 for($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++) 68 68 { 69 69 $this->ConnectOnce($IP, $Login, $Password); … … 182 182 $Response[] = $Line; 183 183 } 184 echo($Line."\n"); 184 185 // If we get a !done, make a note of it. 185 186 if ($Line == "!done") $ReceivedDone = true; 187 else $ReceivedDone = false; 186 188 $Status = socket_get_status($this->Socket); 187 if ((!$this->Connected && !$Status['unread_bytes']) || 189 if ((!$this->Connected && !$Status['unread_bytes']) || 188 190 ($this->Connected && !$Status['unread_bytes'] && $ReceivedDone)) 189 191 break; … … 195 197 function Write($Command, $Param2 = true) 196 198 { 197 if($Command) 199 if($Command) 198 200 { 199 201 $Data = explode("\n", $Command); 200 202 foreach ($Data as $Com) { 201 203 $Com = trim($Com); 202 fwrite($this->Socket, $this->EncodeLength(strlen($Com)).$Com); 204 fwrite($this->Socket, $this->EncodeLength(strlen($Com)).$Com); 203 205 } 204 206 if (gettype($Param2) == 'integer') {
Note:
See TracChangeset
for help on using the changeset viewer.