Ignore:
Timestamp:
Apr 15, 2013, 11:08:49 PM (11 years ago)
Author:
chronos
Message:
  • Upraveno: Skritpy generátorů nastavení routerů přetvořeny na aplikační moduly NetworkConfig.
Location:
trunk/Modules/NetworkConfigRouterOS
Files:
2 added
1 copied

Legend:

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

    r521 r522  
    22
    33if(isset($_SERVER['REMOTE_ADDR'])) die();
    4 include('../../Common/Global.php');
    5 include('../routerboard.php');
    6 include('common.php');
     4include_once(dirname(__FILE__).'/../../../Common/Global.php');
     5include_once(dirname(__FILE__).'/../Routerboard.php');
     6include_once('Common.php');
    77$Path = array('tool', 'netwatch');
    88$Period = 60; // every 60 seconds
    9 $Database = &$System->Database;
    109
    1110while(1)
     
    1312  $StartTime = time();
    1413
    15   $DbResult3 = $Database->query('SELECT DHCP, AddressRange, Mask FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP');
     14  $DbResult3 = $System->Database->query('SELECT DHCP, AddressRange, Mask FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP');
    1615  //echo($DbResult3->num_rows);
    1716  while($Subnet = $DbResult3->fetch_assoc())
     
    3837      }
    3938
    40       $DbResult = $Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values);
     39      $DbResult = $System->Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values);
    4140    }
    4241  }
    4342
    4443  // Update device online state
    45   $DbResult = $Database->select('NetworkDevice', 'Id', '`Used`=1');
     44  $DbResult = $System->Database->select('NetworkDevice', 'Id', '`Used`=1');
    4645  while($Device = $DbResult->fetch_assoc())
    4746  {
    48     $DbResult2 = $Database->select('NetworkInterface', 'SUM(`Online`) AS `SumOnline`', '`Device`='.$Device['Id']);
     47    $DbResult2 = $System->Database->select('NetworkInterface', 'SUM(`Online`) AS `SumOnline`', '`Device`='.$Device['Id']);
    4948    $DbRow = $DbResult2->fetch_array();
    5049    if($DbRow['SumOnline'] > 0) $Online = 1;
     
    5251    $Values = array('Online' => $Online);
    5352    if($Online == 1) $Values['LastOnline'] = 'NOW()';
    54     $Database->update('NetworkDevice', 'Id='.$Device['Id'], $Values);
     53    $System->Database->update('NetworkDevice', 'Id='.$Device['Id'], $Values);
    5554  }
    5655
    5756  // Update interface online statistics
    58   $DbResult = $Database->select('NetworkInterface', 'Id', '`Online` = 1');
     57  $DbResult = $System->Database->select('NetworkInterface', 'Id', '`Online` = 1');
    5958  while($Interface = $DbResult->fetch_assoc())
    6059  {
    61     $DbResult2 = $Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
    62     if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO `NetworkInterfaceStat` (`NetworkInterface`, `Time`, `PingCount`) VALUES ("'.$Interface['Id'].'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"), 1)');         
    63       else $Database->query('UPDATE `NetworkInterfaceStat` SET `PingCount` = `PingCount` + 1 WHERE (`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
     60    $DbResult2 = $System->Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
     61    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)');         
     62      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"))');
    6463  }
    6564
Note: See TracChangeset for help on using the changeset viewer.