Ignore:
Timestamp:
Jul 19, 2014, 1:21:24 AM (10 years ago)
Author:
chronos
Message:
  • Upraveno: Příprava pro sledování signálu bezdrátových spojů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php

    r666 r671  
    1212  {
    1313    $StartTime = time();
    14     $Function();   
     14    $Function();
    1515    $EndTime = time();
    1616    $Delay = $Period - ($EndTime - $StartTime);
     
    1919    echo('Waiting '.$Delay.' seconds...'."\n");
    2020    sleep($Delay);
    21   }
     21  }      print_r($Properties);
     22
    2223}
    2324
     
    2526{
    2627  global $System, $Config;
    27  
     28
    2829  $Path = array('interface', 'wireless', 'registration-table');
     30  $Time = time();
    2931
    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())
    3337  {
    34     echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n");
     38    echo($Device['LocalIP']."\n");
    3539    $Routerboard = new Routerboard();
    3640    $Routerboard->UserName = $Config['MainRouter']['UserName'];
    3741    $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');
    4045    foreach($List as $Properties)
    4146    {
     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      /*
    4257      $DbResult = $System->Database->select('Measure', 'Id', '`Name` = "'.$Properties['mac-address'].'"');
    4358      if($DbResult->num_rows > 0)
     
    5267      $Measure->Load($Id);
    5368      $Measure->AddValue($Properties['signal-strength']);
     69      */
    5470    }
    55   } 
     71  }
    5672}
    5773
Note: See TracChangeset for help on using the changeset viewer.