Changeset 248 for trunk


Ignore:
Timestamp:
Sep 8, 2009, 9:03:14 AM (15 years ago)
Author:
george
Message:
  • Opraveno: Import položek Netwatch z routerboardu do datbáze.
Location:
trunk/system
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/system/generators/dhcp_routerboard.php

    r239 r248  
    99$Routerboard->UserName = $Config['MainRouter']['UserName'];
    1010$Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout'];
     11$Routerboard->Debug = true;
    1112
    1213$DbResult = $Database->query('SELECT * FROM `NetworkSubnet` WHERE `Member` = 0');
  • trunk/system/generators/nat_routerboard.php

    r240 r248  
    99$Routerboard->UserName = $Config['MainRouter']['UserName'];
    1010$Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout'];
     11$Routerboard->Debug = true;
    1112
    1213$InetInterface = $Config['MainRouter']['InetInterface'];
  • trunk/system/generators/netwatch.php

    r239 r248  
    99$Routerboard->UserName = $Config['MainRouter']['UserName'];
    1010$Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout'];
     11$Routerboard->Debug = true;
    1112
    1213$DbResult3 = $Database->query('SELECT DISTINCT (`DHCP`) FROM `NetworkSubnet` WHERE `Member` = 0');
  • trunk/system/generators/netwatch_import.php

    r247 r248  
    1616  $List = $Routerboard->ListGetPrint($Path, array('host', 'status'));
    1717 
    18   //print_r($List);
    1918  foreach($List as $Properties)
    2019  {
    2120    if(IsAddressInSubnet($Properties['host'], $Subnet['AddressRange'], $Subnet['Mask']))
    2221    {
     22      //echo($Properties['host'].', ');
    2323      if($Properties['status'] == 'up')
    2424      {
     
    3636        $DbResult = $Database->select('NetworkInterface', 'Id', 'LocalIP = "'.$Properties['host'].'"');
    3737        $DbRow = $DbResult->fetch_assoc();
    38         $HostId = $DbRow['Id'];
    39         $DbResult2 = $Database->select('stat_hosts', '*', '(host_id="'.$HostId.'") AND (time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
    40         if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO stat_hosts (host_id, time) VALUES ("'.$HostId.'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');         
    41         $Database->query('UPDATE stat_hosts SET count = count + 1 WHERE (host_id="'.$HostId.'") AND (time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
     38        $InterfaceId = $DbRow['Id'];
     39        $DbResult2 = $Database->select('NetworkInterfaceStat', '*', '(NetworkInterface="'.$InterfaceId.'") AND (Time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
     40        if($DbResult2->num_rows == 0) $Database->query('REPLACE INTO NetworkInterfaceStat (NetworkInterface, Time) VALUES ("'.$InterfaceId.'", DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');         
     41        $Database->query('UPDATE NetworkInterfaceStat SET Count = Count + 1 WHERE (NetworkInterface="'.$InterfaceId.'") AND (Time = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
    4242      }
    4343    }
  • trunk/system/generators/traffic_shaping_routerboard.php

    r243 r248  
    1414$Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout'];
    1515$Routerboard->HostName = $Config['MainRouter']['HostName'];
     16$Routerboard->Debug = true;
    1617
    1718$Finance = &$System->Modules['Finance'];
  • trunk/system/routerboard.php

    r242 r248  
    1010  var $PrivateKey = 'id_dsa';
    1111  var $MaxBurstLineCount = 100;
    12  
     12  var $Debug = false;
     13
    1314  function __construct($HostName = 'localhost', $UserName = 'admin', $Password = '')
    1415  {
     
    5253      $Commands = str_replace('$', '\$', $Commands);
    5354      $Command = $this->SSHPath.' -o ConnectTimeout='.$this->Timeout.' -l '.$this->UserName.' -i '.$this->PrivateKey.' '.$this->HostName.' "'.$Commands.'"';
    54       echo($Command);
     55      if($this->Debug) echo($Command);
    5556      exec($Command, $Output);
    5657    } else $Output = '';
    57     print_r($Output);
     58    if($this->Debug) print_r($Output);
    5859    return($Output);
    5960  }
     
    235236      }
    236237    }
    237     print_r($Commands);
     238    if($this->Debug) print_r($Commands);
    238239    return($this->Execute($Commands));   
    239240  }
Note: See TracChangeset for help on using the changeset viewer.