Changeset 336 for trunk/system


Ignore:
Timestamp:
Dec 30, 2011, 2:22:10 PM (13 years ago)
Author:
chronos
Message:
  • Opraveno: Zobrazování chybových hlášení chyb SQL.
Location:
trunk/system/generators
Files:
2 edited

Legend:

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

    r335 r336  
    1212  $StartTime = time();
    1313
    14 $DbResult3 = $Database->query('SELECT DISTINCT (`DHCP`), * FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL)');
    15 //echo($DbResult3->num_rows);
    16 while($Subnet = $DbResult3->fetch_assoc())
    17 {
    18   echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n");
    19   $Routerboard = new Routerboard();
    20   $Routerboard->UserName = $Config['MainRouter']['UserName'];
    21   $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout'];
    22   $Routerboard->HostName = $Subnet['DHCP'];
    23   $List = $Routerboard->ListGetPrint($Path, array('host', 'status'));
    24   foreach($List as $Properties)
     14  $DbResult3 = $Database->query('SELECT DHCP, AddressRange, Mask FROM `NetworkSubnet` WHERE (`Configure` = 1) AND (`Member` IS NULL) GROUP BY DHCP');
     15  //echo($DbResult3->num_rows);
     16  while($Subnet = $DbResult3->fetch_assoc())
    2517  {
    26     //echo($Properties['host'].', ');
    27     if($Properties['status'] == 'up')
     18    echo($Subnet['AddressRange'].'/'.$Subnet['Mask'].' on router '.$Subnet['DHCP']."\n");
     19    $Routerboard = new Routerboard();
     20    $Routerboard->UserName = $Config['MainRouter']['UserName'];
     21    $Routerboard->Timeout = $Config['MainRouter']['ConnectTimeout'];
     22    $Routerboard->HostName = $Subnet['DHCP'];
     23    $List = $Routerboard->ListGetPrint($Path, array('host', 'status'));
     24    foreach($List as $Properties)
    2825    {
    29       $Online = 1;
    30       $Values = array('Online' => $Online, 'LastOnline' => 'NOW()');
    31       //echo($Properties['host']." up\n");
    32     } else
    33     {
    34       $Online = 0;
    35       $Values = array('Online' => $Online);
    36       //echo($Properties['host']." down\n");
     26      //echo($Properties['host'].', ');
     27      if($Properties['status'] == 'up')
     28      {
     29        $Online = 1;
     30        $Values = array('Online' => $Online, 'LastOnline' => 'NOW()');
     31        //echo($Properties['host']." up\n");
     32      } else
     33      {
     34        $Online = 0;
     35        $Values = array('Online' => $Online);
     36        //echo($Properties['host']." down\n");
     37      }
     38
     39      $DbResult = $Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values);
    3740    }
     41  }
    3842
    39     $DbResult = $Database->update('NetworkInterface', '`LocalIP` = "'.$Properties['host'].'"', $Values);
     43  // Update device online state
     44  $DbResult = $Database->select('NetworkDevice', 'Id', '`Used`=1');
     45  while($Device = $DbResult->fetch_assoc())
     46  {
     47    $DbResult2 = $Database->select('NetworkInterface', 'SUM(`Online`) AS `SumOnline`', '`Device`='.$Device['Id']);
     48    $DbRow = $DbResult2->fetch_array();
     49    if($DbRow['SumOnline'] > 0) $Online = 1;
     50      else $Online = 0; 
     51    $Values = array('Online' => $Online);
     52    if($Online == 1) $Values['LastOnline'] = 'NOW()';
     53    $Database->update('NetworkDevice', 'Id='.$Device['Id'], $Values);
    4054  }
    41 }
    4255
    43 // Update device online state
    44 $DbResult = $Database->select('NetworkDevice', 'Id', '`Used`=1');
    45 while($Device = $DbResult->fetch_assoc())
    46 {
    47   $DbResult2 = $Database->select('NetworkInterface', 'SUM(`Online`) AS `SumOnline`', '`Device`='.$Device['Id']);
    48   $DbRow = $DbResult2->fetch_array();
    49   if($DbRow['SumOnline'] > 0) $Online = 1;
    50     else $Online = 0; 
    51   $Values = array('Online' => $Online);
    52   if($Online == 1) $Values['LastOnline'] = 'NOW()';
    53   $Database->update('NetworkDevice', 'Id='.$Device['Id'], $Values);
    54 }
     56  // Update interface online statistics
     57  $DbResult = $Database->select('NetworkInterface', 'Id', '`Online` = 1');
     58  while($Interface = $DbResult->fetch_assoc())
     59  {
     60    $DbResult2 = $Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
     61    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)');         
     62      else $Database->query('UPDATE `NetworkInterfaceStat` SET `PingCount` = `PingCount` + 1 WHERE (`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
     63  }
    5564
    5665  $EndTime = time();
     
    6271}
    6372
    64 // Update interface online statistics
    65 $DbResult = $Database->select('NetworkInterface', 'Id', '`Online` = 1');
    66 while($Interface = $DbResult->fetch_assoc())
    67 {
    68   $DbResult2 = $Database->select('NetworkInterfaceStat', '*', '(`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
    69   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');         
    70     $Database->query('UPDATE `NetworkInterfaceStat` SET `PingCount` = `PingCount` + 1 WHERE (`NetworkInterface`="'.$Interface['Id'].'") AND (`Time` = DATE_FORMAT(NOW(), "%Y-%m-%d %H:00:00"))');
    71 }
    72 
    7373?>
  • trunk/system/generators/queue.php

    r317 r336  
    3838$InInterface = 'ifb0';
    3939$InetInterface = $Config['MainRouter']['InetInterface'];
    40 $FreeInetSpeed = $Finance->Tariffs[6]['SpeedMax'];
     40$FreeInetSpeed = $Finance->Tariffs[7]['SpeedMax'];
    4141
    4242$ItemsQueue = array();
     
    116116}
    117117
    118 //print_r($ItemsFirewall);
     118//print_r($ItemsQueue);
    119119$Routerboard->ListUpdate($PathQueue, array('name', 'limit-at', 'max-limit', 'parent', 'packet-mark'), $ItemsQueue, array(), true);
    120120
Note: See TracChangeset for help on using the changeset viewer.