Ignore:
Timestamp:
Sep 2, 2009, 8:51:05 AM (15 years ago)
Author:
george
Message:
  • Opraveno: Dostupnost sítě zobrazovat pro rozhraní a ne společně pro zařízení. Důsledkem bylo zobrazení dostupnosti více než 100%.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/network/dostupnost.php

    r217 r246  
    11<?php
     2
    23include_once('../global.php');
    34
     
    2122    $Output .= '<br /><table class="WideTable" style="font-size: small;">';
    2223    $Output .= '<tr><th>Jméno</th><th>Hodina [%]</th><th>Den [%]</th><th>Týden [%]</th><th>Měsíc [%]</th><th>Rok [%]</th></tr>';
    23     $DbResult = $this->Database->query('SELECT NetworkDevice.Type, NetworkDevice.Name, PeriodHour.Percent AS Hour, PeriodDay.Percent AS Day, PeriodWeek.Percent AS Week, PeriodMonth.Percent AS Month, PeriodYear.Percent AS Year FROM NetworkDevice
    24     LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 1 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 1 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodHour ON PeriodHour.host_id = NetworkDevice.Id
    25     LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodDay ON PeriodDay.host_id = NetworkDevice.Id
    26     LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 7 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 7 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodWeek ON PeriodWeek.host_id = NetworkDevice.Id
    27     LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 30 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 30 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodMonth ON PeriodMonth.host_id = NetworkDevice.id
    28     LEFT JOIN (SELECT stat_hosts.host_id, (SUM(stat_hosts.count) / 24 / 365 / 60 * 100) as Percent FROM stat_hosts WHERE (time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 365 HOUR)) AND (time< DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY host_id) as PeriodYear ON PeriodYear.host_id = NetworkDevice.Id
    29     WHERE NetworkDevice.Used = 1 AND NetworkDevice.Type IN (1, 4, 5) ORDER BY Name');
    30     while($Row = $DbResult->fetch_assoc())
     24    $DbResult = $this->Database->query('SELECT NetworkDevice.Id, NetworkDevice.Type, NetworkDevice.Name FROM NetworkDevice WHERE NetworkDevice.Used = 1 AND NetworkDevice.Type IN (1, 4, 5) ORDER BY Name');
     25    while($Device = $DbResult->fetch_assoc())
    3126    {
    32       $Output .= '<tr><td>'.$Row['Name'].'</td><td style="text-align: right;">'.sprintf('%01.2f', $Row['Hour']).'</td><td style="text-align: right;">'.sprintf('%01.2f', $Row['Day']).'</td><td style="text-align: right;">'.sprintf('%01.2f', $Row['Week']).'</td><td style="text-align: right;">'.sprintf('%01.2f', $Row['Month']).'</td><td style="text-align: right;">'.sprintf('%01.2f', $Row['Year']).'</td></tr>';
     27       $DbResult2 = $this->Database->query('SELECT NetworkInterface.Name, PeriodHour.Percent AS Hour, PeriodDay.Percent AS Day, PeriodWeek.Percent AS Week, PeriodMonth.Percent AS Month, PeriodYear.Percent AS Year FROM NetworkInterface
     28    LEFT JOIN (SELECT NetworkInterfaceStat.NetworkInterface, (SUM(NetworkInterfaceStat. PingCount) / 1 / 60 * 100) AS Percent FROM NetworkInterfaceStat WHERE (Time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 1 HOUR)) AND (Time < DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY NetworkInterface) as PeriodHour ON PeriodHour.NetworkInterface = NetworkInterface.Id
     29    LEFT JOIN (SELECT NetworkInterfaceStat.NetworkInterface, (SUM(NetworkInterfaceStat.PingCount) / 24 / 60 * 100) AS Percent FROM NetworkInterfaceStat WHERE (Time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 HOUR)) AND (Time < DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY NetworkInterface) AS PeriodDay ON PeriodDay.NetworkInterface = NetworkInterface.Id
     30    LEFT JOIN (SELECT NetworkInterfaceStat.NetworkInterface, (SUM(NetworkInterfaceStat.PingCount) / 24 / 7 / 60 * 100) AS Percent FROM NetworkInterfaceStat WHERE (Time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 7 HOUR)) AND (Time < DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY NetworkInterface) AS PeriodWeek ON PeriodWeek.NetworkInterface = NetworkInterface.Id
     31    LEFT JOIN (SELECT NetworkInterfaceStat.NetworkInterface, (SUM(NetworkInterfaceStat.PingCount) / 24 / 30 / 60 * 100) AS Percent FROM NetworkInterfaceStat WHERE (Time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 30 HOUR)) AND (Time < DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY NetworkInterface) AS PeriodMonth ON PeriodMonth.NetworkInterface = NetworkInterface.id
     32    LEFT JOIN (SELECT NetworkInterfaceStat.NetworkInterface, (SUM(NetworkInterfaceStat.PingCount) / 24 / 365 / 60 * 100) AS Percent FROM NetworkInterfaceStat WHERE (Time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL 24 * 365 HOUR)) AND (Time < DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY NetworkInterface) AS PeriodYear ON PeriodYear.NetworkInterface = NetworkInterface.Id
     33   WHERE NetworkInterface.Device = '.$Device['Id']);
     34      while($Interface = $DbResult2->fetch_assoc())
     35      {
     36        $Name = $Device['Name'];
     37        if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     38        $Output .= '<tr><td>'.$Name.'</td><td style="text-align: right;">'.sprintf('%01.2f', $Interface['Hour']).'</td><td style="text-align: right;">'.sprintf('%01.2f', $Interface['Day']).'</td><td style="text-align: right;">'.sprintf('%01.2f', $Interface['Week']).'</td><td style="text-align: right;">'.sprintf('%01.2f', $Interface['Month']).'</td><td style="text-align: right;">'.sprintf('%01.2f', $Interface['Year']).'</td></tr>';
     39      }
    3340    }
    3441    $Output .= '</table></div>';
Note: See TracChangeset for help on using the changeset viewer.