Ignore:
Timestamp:
Mar 16, 2016, 10:01:02 PM (9 years ago)
Author:
chronos
Message:
  • Added: UpDown history for network ports.
File:
1 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
Note: See TracChangeset for help on using the changeset viewer.