Ignore:
Timestamp:
Jan 13, 2020, 12:26:00 AM (5 years ago)
Author:
chronos
Message:
  • Added: NotifLog table to collect notify changes in table to be able to preset them through RSS channel.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Network/Network.php

    r865 r867  
    132132    $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkPort',
    133133      array($this, 'PortCheck'));
    134 
    135134
    136135    $this->System->RegisterPage('network', 'PageNetwork');
     
    816815    $OnlineText = array('<span style="color:red;">Nedostupný</span>', '<span style="color:green;">Dostupný</span>');
    817816    $Output = '';
    818     $Condition = 'WHERE (`NetworkInterface`.`Online` = '.$OnlineNow.') AND (`NetworkInterface`.`OnlineNotify` = '.$OnlinePrevious.') '.
    819       'AND (`NetworkInterface`.`LastOnline` <= "'.TimeToMysqlDateTime($Time - $MinDuration).'")';
     817    $Condition = 'WHERE (`NetworkInterface`.`LastOnline` <= "'.TimeToMysqlDateTime($Time - $MinDuration).'")';
     818    if ($OnlineNow != null) $Condition .= ' AND (`NetworkInterface`.`Online` = '.$OnlineNow.')';
     819    if ($OnlinePrevious != null) $Condition .= ' AND (`NetworkInterface`.`OnlineNotify` = '.$OnlinePrevious.')';
    820820    $DbResult3 = $this->Database->query('SELECT CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")) AS `Name`, '.
    821821      '`NetworkInterface`.`Online`, `NetworkInterface`.`LastOnline` FROM `NetworkInterface` '.
     
    845845    $this->Database->query('UPDATE `NetworkInterface` SET `OnlineNotify` = `Online` '.
    846846      $Condition);
    847     return $Output;
     847    return array('Report' => $Output, 'Count' => $DbResult3->num_rows);
    848848  }
    849849
    850850  function ReachabilityCheck()
    851851  {
    852     $Output = '';
    853     $Output = $this->OnlineList('Nově online', 1, 0, 0);
    854     $Output .= $this->OnlineList('Nově offline', 0, 1, $this->MinNotifyTime);
    855     if($Output != '') $Output .= $this->OnlineList('Stále offline', 0, 0, 0);
    856     return($Output);
     852    $NewOnline = $this->OnlineList('Nově online', 1, 0, 0);
     853    $Output = $NewOnline['Report'];
     854    $NewOffline = $this->OnlineList('Nově offline', 0, 1, $this->MinNotifyTime);
     855    $Output .= $NewOffline['Report'];
     856    if ($Output != '')
     857    {
     858      $StillOffline = $this->OnlineList('Stále offline', 0, 0, 0);
     859      $Output .= $StillOffline['Report'];
     860    }
     861    $Offline = $this->OnlineList('Offline', 0, null, 0);
     862    return(array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Odezva'));
    857863  }
    858864
     
    862868    $OnlineText = array('<span style="color:red;">Nedostupný</span>', '<span style="color:green;">Dostupný</span>');
    863869    $Output = '';
    864     $Condition = 'WHERE (`NetworkPort`.`Online` = '.$OnlineNow.') AND (`NetworkPort`.`OnlineNotify` = '.$OnlinePrevious.') '.
    865       'AND (`NetworkPort`.`LastOnline` <= "'.TimeToMysqlDateTime($Time - $MinDuration).'")';
     870    $Condition = 'WHERE (`NetworkPort`.`LastOnline` <= "'.TimeToMysqlDateTime($Time - $MinDuration).'")';
     871    if ($OnlineNow != null) $Condition .= ' AND (`NetworkPort`.`Online` = '.$OnlineNow.')';
     872    if ($OnlinePrevious != null) $Condition .= ' AND (`NetworkPort`.`OnlineNotify` = '.$OnlinePrevious.')';
    866873    $DbResult3 = $this->Database->query('SELECT CONCAT(CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")), ":", `NetworkPort`.`Number`, "(", `NetworkPort`.`Name`, ")") AS `Name`, '.
    867874      '`NetworkPort`.`Online`, `NetworkPort`.`LastOnline` FROM `NetworkPort` '.
     
    871878      '(`NetworkInterface`.`LocalIP` != "") AND (`NetworkPort`.`Enabled` = 1)'.
    872879      'ORDER BY `Name` ASC');
    873     if($DbResult3->num_rows > 0)
     880    if ($DbResult3->num_rows > 0)
    874881    {
    875882      $Output .= $Title.'<br/>';
     
    892899    $this->Database->query('UPDATE `NetworkPort` SET `OnlineNotify` = `Online` '.
    893900      $Condition);
    894     return $Output;
     901    return array('Report' => $Output, 'Count' => $DbResult3->num_rows);
    895902  }
    896903
     
    898905  {
    899906    $Output = '';
    900     $Output = $this->PortCheckList('Nově online', 1, 0, 0);
    901     $Output .= $this->PortCheckList('Nově offline', 0, 1, $this->MinNotifyTime);
    902     if($Output != '') $Output .= $this->PortCheckList('Stále offline', 0, 0, 0);
    903     return($Output);
     907    $NewOnline = $this->PortCheckList('Nově online', 1, 0, 0);
     908    $Output .= $NewOnline['Report'];
     909    $NewOffline = $this->PortCheckList('Nově offline', 0, 1, $this->MinNotifyTime);
     910    $Output .= $NewOffline['Report'];
     911    if ($Output != '')
     912    {
     913      $StillOffline = $this->PortCheckList('Stále offline', 0, 0, 0);
     914      $Output .= $StillOffline['Report'];
     915    }
     916    $Offline = $this->PortCheckList('Offline', 0, null, 0);
     917    return(array('Report' => $Output, 'Count' => $Offline['Count'], 'ShortTitle' => 'Port'));
    904918  }
    905919}
Note: See TracChangeset for help on using the changeset viewer.