Ignore:
Timestamp:
Aug 5, 2014, 10:49:06 PM (10 years ago)
Author:
chronos
Message:
  • Upraveno: Funkce RepeatFunction přesunuta do Global.php.
  • Upraveno: Nezaznamenávat chyby potlačené symbolem @.
  • Upraveno: Nezobrazovat HTML chyby při spuštění z konzole.
  • Opraveno: Pokud není navázáno spojení s RouterboardAPI, tak nepokračuj se zasíláním povelů.
  • Upraveno: NetwatchImport přepracován na načítání přes RouterboardAPI.
Location:
trunk/Modules/NetworkConfigRouterOS
Files:
3 edited

Legend:

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

    r667 r682  
    77$System->Run();
    88
    9 $Path = array('tool', 'netwatch');
    10 $Period = 60; // every 60 seconds
     9function NetwatchImport()
     10{
     11  global $System, $Config;
    1112
    12 
    13 while(1)
    14 {
    1513  $StartTime = time();
    1614
     
    2725  {
    2826    echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n");
    29     $Routerboard = new Routerboard();
    30     $Routerboard->UserName = $Config['MainRouter']['UserName'];
    31     $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout'];
    32     $Routerboard->HostName = $Subnet['DHCP'];
    33     $List = $Routerboard->ListGetPrint($Path, array('host', 'status'));
     27    $Routerboard = new RouterosAPI();
     28    $Routerboard->Connect($Subnet['DHCP'], $Config['API']['UserName'], $Config['API']['Password']);
     29    if(!$Routerboard->Connected) continue;
     30    $Routerboard->Write('/tool/netwatch/getall', false);
     31    $Routerboard->Write('=.proplist=host,status');
     32    $Read = $Routerboard->Read(false);
     33    $List = $Routerboard->ParseResponse($Read);
    3434    foreach($List as $Properties)
    3535    {
     
    9696      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"))');
    9797  }
    98 
    99   $EndTime = time();
    100   $Delay = $Period - ($EndTime - $StartTime);
    101   if($Delay < 0) $Delay = 0;
    102 
    103   echo('Waiting '.$Delay.' seconds...'."\n");
    104   sleep($Delay);
    10598}
    10699
     100RepeatFunction(60, 'NetwatchImport');
  • trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php

    r679 r682  
    77$System->Run();
    88
    9 function RepeatFunction($Period, $Function)
    10 {
    11   while(1)
    12   {
    13     $StartTime = time();
    14     $Function();
    15     $EndTime = time();
    16     $Delay = $Period - ($EndTime - $StartTime);
    17     if($Delay < 0) $Delay = 0;
    18 
    19     echo('Waiting '.$Delay.' seconds...'."\n");
    20     sleep($Delay);
    21   }
    22 }
    23 
    249function ReadWirelessRegistration()
    2510{
    2611  global $System, $Config;
    2712
    28   $Path = array('interface', 'wireless', 'registration-table');
    2913  $Time = time();
    3014
     
    4024    //$Routerboard->Port = 8729;
    4125    $Routerboard->Connect($Device['LocalIP'], $Config['API']['UserName'], $Config['API']['Password']);
     26    if(!$Routerboard->Connected) continue;
    4227    $Routerboard->Write('/interface/wireless/registration-table/getall', false);
    4328    $Routerboard->Write('=.proplist=signal-strength,mac-address,rx-rate,tx-rate', false);
  • trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php

    r677 r682  
    5050        $IP = 'ssl://'.$IP;
    5151    }
    52 
    5352    $this->Socket = @fsockopen($IP, $this->Port, $this->ErrorNo, $this->ErrorStr, $this->Timeout);
    5453    if($this->Socket)
     
    146145  function Read($Parse = true)
    147146  {
     147    $Line = '';
    148148    $Response = array();
    149149    while (true) {
Note: See TracChangeset for help on using the changeset viewer.