Ignore:
Timestamp:
Jul 21, 2014, 11:09:35 PM (10 years ago)
Author:
chronos
Message:
  • Přidáno: Zprovozněno měření signálu přes RouterOS API.
File:
1 edited

Legend:

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

    r671 r674  
    1919    echo('Waiting '.$Delay.' seconds...'."\n");
    2020    sleep($Delay);
    21   }      print_r($Properties);
    22 
     21  }
    2322}
    2423
     
    3736  {
    3837    echo($Device['LocalIP']."\n");
    39     $Routerboard = new Routerboard();
    40     $Routerboard->UserName = $Config['MainRouter']['UserName'];
    41     $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout'];
    42     $Routerboard->HostName = $Device['LocalIP'];
    43     $Routerboard->Debug = true;
    44     $List = $Routerboard->ListGetPrint($Path, array('mac-address', 'signal-strength'), array(), 'stats');
    45     foreach($List as $Properties)
     38    $Routerboard = new RouterosAPI();
     39    $Routerboard->Connect($Device['LocalIP'], $Config['API']['UserName'], $Config['API']['Password']);
     40    $Routerboard->Write('/interface/wireless/registration-table/getall', false);
     41    $Routerboard->Write('=.proplist=signal-strength,mac-address,rx-rate,tx-rate', false);
     42    $Routerboard->Write('=stats=');
     43    $Read = $Routerboard->Read(false);
     44    $Array = $Routerboard->ParseResponse($Read);
     45    foreach($Array as $Properties)
    4646    {
    47       print_r($Properties);
    4847      $DbResult = $System->Database->select('NetworkInterface', 'Id', 'MAC="'.$Properties['mac-address'].'"');
    4948      if($DbResult->num_rows > 0)
     
    5251        $Interface = $DbRow['Id'];
    5352      } else $Interface = null;
     53
     54      $Parts = explode('@', $Properties['signal-strength']);
     55      $Strength = substr($Parts[0], 0, -3); // without dBm
     56      $RateRx = substr($Properties['rx-rate'], 0, -3); // without MHz
     57      $RateTx = substr($Properties['tx-rate'], 0, -3); // without MHz
    5458      $System->Database->insert('NetworkSignal', array('MAC' => $Properties['mac-address'],
    55         'Value' => $Properties['signal-strength'], 'Time' => $Time, 'Interface' => $Interface));
     59        'Value' => $Strength, 'RateRx' => $RateRx, 'RateTx' => $RateTx,
     60        'Time' => TimeToMysqlDateTime($Time), 'Interface' => $Interface));
    5661      /*
    5762      $DbResult = $System->Database->select('Measure', 'Id', '`Name` = "'.$Properties['mac-address'].'"');
     
    7277}
    7378
    74 RepeatFunction(60, 'ReadWirelessRegistration');
     79RepeatFunction(60 * 60, 'ReadWirelessRegistration');
Note: See TracChangeset for help on using the changeset viewer.