Ignore:
Timestamp:
May 26, 2014, 1:00:20 AM (10 years ago)
Author:
chronos
Message:
  • Přidáno: V tabulce změn stavu síťových rozhraní zobrazovat také dobu trvání.
  • Opraveno: Neprováděly se skripty využívající třídu Routerboard.
  • Opraveno: Načítání stavu rozhraní z RouterOS.
File:
1 edited

Legend:

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

    r657 r658  
    1414  $StartTime = time();
    1515
    16   // Load netwatch status from all DHCP routers 
     16  // Load netwatch status from all DHCP routers
    1717  $DbResult3 = $System->Database->query('SELECT `DHCP`, `AddressRange`, `Mask` FROM `NetworkSubnet` '.
    1818                'WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP');
     
    2929      if($Properties['status'] == 'up') $Online = 1;
    3030        else $Online = 0;
    31        
    32       $DbResult = $System->Database->select('NetworkInterface', 'Online', '`LocalIP` = "'.$Properties['host'].'";');
     31
     32      $DbResult = $System->Database->select('NetworkInterface', '`Id`,`Online`', '`LocalIP` = "'.$Properties['host'].'";');
    3333      while($DbRow = $DbResult->fetch_assoc())
    3434      {
    3535        $LastOnline = $DbRow['Online'];
    36         $Interface = $DbRow['NetworkInterface'];
    37        
     36        $Interface = $DbRow['Id'];
     37
    3838        // Record state changes
    3939        if($Online != $LastOnline)
    40         {     
     40        {
    4141          $System->Database->insert('NetworkInterfaceUpDown', array(
    4242                  'Interface' => $Interface, 'State' => $Online, 'Time' => TimeToMysqlDateTime($StartTime)));
    4343        }
    44       };
    45        
     44      }
     45
    4646      if($Online)
    4747      {
    48         $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', 
     48        $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"',
    4949          array('Online' => 1, 'LastOnline' => TimeToMysqlDateTime($StartTime)));
    50       } 
     50      }
    5151    }
    52   } 
     52  }
    5353  $DbResult = $System->Database->update('NetworkInterface', '`LastOnline` < "'.TimeToMysqlDateTime($StartTime).'"', array('Online' => 0));
    5454
     
    6767  {
    6868    $DbResult2 = $System->Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
    69     if($DbResult2->num_rows == 0) $System->Database->query('REPLACE INTO `NetworkInterfaceStat` (`NetworkInterface`, `Time`, `PingCount`) VALUES ("'.$Interface['Id'].'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), 1)');         
     69    if($DbResult2->num_rows == 0) $System->Database->query('REPLACE INTO `NetworkInterfaceStat` (`NetworkInterface`, `Time`, `PingCount`) VALUES ("'.$Interface['Id'].'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), 1)');
    7070      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"))');
    7171  }
Note: See TracChangeset for help on using the changeset viewer.