Ignore:
Timestamp:
Mar 16, 2016, 10:01:02 PM (9 years ago)
Author:
chronos
Message:
  • Added: UpDown history for network ports.
Location:
trunk/Modules/NetworkConfigRouterOS
Files:
2 edited

Legend:

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

    r793 r818  
    4949              array('LastOnline' => TimeToMysqlDateTime($StartTime)));
    5050
    51           if($Interface['Online'] != $Interface['NewOnline'])
    52           {
    53             // Online state changed
    54             $DbResult = $this->Database->query('INSERT INTO `NetworkInterfaceUpDown` (`Interface`,
    55         `State`, `Time`, `Duration`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'.
    56                 TimeToMysqlDateTime($StartTime).'", NULL)');
    57             // Update previous record duration in UpDown table
    58             $this->Database->query('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND, '.
    59                 '`TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`) '.
    60                 'AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1)) '.
    61                 'WHERE (`TM`.`Duration` IS NULL) AND (`TM`.`Interface` ='.$Interface['Id'].')');
    62             $this->Database->update('NetworkInterface', '`Id` = "'.$Interface['Id'].'"',
    63                 array('Online' => $Interface['NewOnline']));
    64           }
     51        if($Interface['Online'] != $Interface['NewOnline'])
     52        {
     53          // Online state changed
     54          $DbResult = $this->Database->query('INSERT INTO `NetworkInterfaceUpDown` (`Interface`,
     55           `State`, `Time`, `Duration`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'.
     56            TimeToMysqlDateTime($StartTime).'", NULL)');
     57          // Update previous record duration in UpDown table
     58          $this->Database->query('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND, '.
     59            '`TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`) '.
     60            'AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1)) '.
     61            'WHERE (`TM`.`Duration` IS NULL) AND (`TM`.`Interface` ='.$Interface['Id'].')');
     62          $this->Database->update('NetworkInterface', '`Id` = "'.$Interface['Id'].'"',
     63            array('Online' => $Interface['NewOnline']));
     64        }
    6565      }
    6666
  • trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php

    r781 r818  
    4040  {
    4141    $this->System->Pages['zdarma'] = 'PageFreeAccess';
    42     $this->System->FormManager->RegisterClass('NetworkInterfaceUpDown', array(
    43       'Title' => 'Změny stavu rozhraní',
    44       'Table' => 'NetworkInterfaceUpDown',
    45       'DefaultSortColumn' => 'Time',
    46       'DefaultSortOrder' => 1,
    47       'Items' => array(
    48         'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => '', 'ReadOnly' => true),
    49         'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'ReadOnly' => true),
    50         'State' => array('Type' => 'TOnlineState', 'Caption' => 'Stav', 'Default' => '', 'ReadOnly' => true),
    51         'Duration' => array('Type' => 'TimeDiff', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true),
    52       ),
    53     ));
    54 
    5542    $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-dns', 'ConfigRouterOSDNS');
    5643    $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-dhcp', 'ConfigRouterOSDHCP');
Note: See TracChangeset for help on using the changeset viewer.