1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/SSHClient.php');
|
---|
4 |
|
---|
5 | class ConfigAirOSSignal extends NetworkConfigItem
|
---|
6 | {
|
---|
7 | function ReadWirelessRegistration(): void
|
---|
8 | {
|
---|
9 | $Time = time();
|
---|
10 | $NetworkMac = new NetworkMac($this->System);
|
---|
11 |
|
---|
12 | // Load netwatch status from all DHCP routers
|
---|
13 | $DbResult3 = $this->Database->query('SELECT `Id`, `LoginName`, `LoginPassword`, '.
|
---|
14 | '(SELECT `LocalIP` FROM `NetworkInterface` WHERE `NetworkInterface`.`Device` = `NetworkDevice`.`Id` LIMIT 1) AS `LocalIP` '.
|
---|
15 | 'FROM `NetworkDevice` WHERE (`API` = 2) AND (`Used` = 1)');
|
---|
16 | while ($Device = $DbResult3->fetch_assoc())
|
---|
17 | {
|
---|
18 | echo($Device['LocalIP']."");
|
---|
19 | $SSHClient = new SSHClient($Device['LocalIP'], $Device['LoginName'], $Device['LoginPassword']);
|
---|
20 | //$SSHClient->Debug = true;
|
---|
21 | $Result = $SSHClient->Execute('wstalist');
|
---|
22 | if (count($Result) > 0)
|
---|
23 | {
|
---|
24 | $Array = json_decode(implode("\n", $Result), true);
|
---|
25 | echo('-');
|
---|
26 | foreach ($Array as $Properties)
|
---|
27 | {
|
---|
28 | $DbResult = $this->Database->select('NetworkInterface', 'Id', '`MAC`="'.$Properties['mac'].'"');
|
---|
29 | if ($DbResult->num_rows > 0)
|
---|
30 | {
|
---|
31 | $DbRow = $DbResult->fetch_assoc();
|
---|
32 | $Interface = $DbRow['Id'];
|
---|
33 | } else $Interface = null;
|
---|
34 |
|
---|
35 | $Strength = $Properties['signal'];
|
---|
36 | $RemoteSignal = $Properties['remote']['signal'];
|
---|
37 | $RateRx = $Properties['rx'];
|
---|
38 | $RateTx = $Properties['tx'];
|
---|
39 | $MacRef = $NetworkMac->GetIndex($Properties['mac']);
|
---|
40 | $this->Database->insert('NetworkSignal', array('MAC' => $MacRef,
|
---|
41 | 'Value' => $Strength, 'Remote' => $RemoteSignal, 'RateRx' => $RateRx, 'RateTx' => $RateTx,
|
---|
42 | 'Time' => TimeToMysqlDateTime($Time), 'Interface' => $Interface, 'Device' => $Device['Id']));
|
---|
43 | echo('.');
|
---|
44 | }
|
---|
45 | echo("\n");
|
---|
46 | } else echo("Empty response\n");
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | function Run(): void
|
---|
51 | {
|
---|
52 | RepeatFunction(60 * 60, array($this, 'ReadWirelessRegistration'));
|
---|
53 | }
|
---|
54 | }
|
---|