Changeset 268 for trunk


Ignore:
Timestamp:
Jan 6, 2010, 1:43:24 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Vypisování dostupnosti počítačů v časových periodách.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/network/dostupnost.php

    r261 r268  
    11<?php
    2 
    3 die();
    42
    53include_once('../global.php');
     
    97  var $FullTitle = 'Dostupnost aktivních prvků sítě';
    108  var $ShortTitle = 'Dostupnost sítě';
     9  var $Period = array(
     10    array('Column' => 'Hour', 'Title' => 'Hodina', 'Period' => 1),
     11    array('Column' => 'Day', 'Title' => 'Den', 'Period' => 24),
     12    array('Column' => 'Week', 'Title' => 'Týden', 'Period' => 168), // 24 * 7 
     13    array('Column' => 'Month', 'Title' => 'Měsíc', 'Period' => 720), // 24 * 30
     14    array('Column' => 'Year', 'Title' => 'Rok', 'Period' => 8760), // 365 * 24
     15    array('Column' => 'TenYear', 'Title' => 'Desetiletí', 'Period' => 87600), // 365 * 24 * 10
     16  );
    1117
    1218  function Show()
     
    2329    // Zařízení
    2430    $Output .= '<br /><table class="WideTable" style="font-size: small;">';
    25     $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>';
    26     $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');
    27     while($Device = $DbResult->fetch_assoc())
     31    $Output .= '<tr><th>Jméno</th>';
     32    foreach($this->Period as $Period)
     33      $Output .= '<th>'.$Period['Title'].' [%]</th>';
     34    $Output .= '</tr>';
     35   
     36    $Join = '';
     37    $Columns = '';
     38    foreach($this->Period as $Period)
    2839    {
    29        $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
    30     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
    31     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
    32     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
    33     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
    34     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
    35    WHERE NetworkInterface.Device = '.$Device['Id']);
    36       while($Interface = $DbResult2->fetch_assoc())
    37       {
    38         $Name = $Device['Name'];
    39         if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
    40         $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>';
    41       }
     40      $Join .= ' LEFT JOIN (SELECT NetworkInterfaceStat.NetworkInterface, (SUM(NetworkInterfaceStat. PingCount) / '.$Period['Period'].' / 60 * 100) AS Percent FROM NetworkInterfaceStat WHERE (Time > DATE_SUB(DATE_SUB(NOW(), INTERVAL 1 HOUR), INTERVAL '.$Period['Period'].' HOUR)) AND (Time < DATE_SUB(NOW(), INTERVAL 1 HOUR)) GROUP BY NetworkInterface) AS Period'.$Period['Column'].' ON Period'.$Period['Column'].'.NetworkInterface = NetworkInterface.Id';
     41      $Columns .= ', Period'.$Period['Column'].'.Percent AS '.$Period['Column'];
     42    }
     43     
     44    $DbResult2 = $this->Database->query('SELECT NetworkInterface.Name'.$Columns.', NetworkDevice.Name AS DeviceName FROM NetworkInterface '.$Join.' JOIN NetworkDevice ON NetworkInterface.Device = NetworkDevice.Id WHERE NetworkDevice.Used = 1 AND NetworkDevice.Type IN (1, 4, 5) ORDER BY Name');
     45    while($Interface = $DbResult2->fetch_assoc())
     46    {
     47      $Name = $Interface['DeviceName'];
     48      if($Interface['Name'] != '') $Name .= '-'.$Interface['Name'];
     49      $Output .= '<tr><td>'.$Name.'</td>';
     50      foreach($this->Period as $Period)
     51        $Output .= '<td style="text-align: right;">'.sprintf('%01.2f', $Interface[$Period['Column']]).'</td>';
     52      $Output .= '</tr>';
    4253    }
    4354    $Output .= '</table></div>';
Note: See TracChangeset for help on using the changeset viewer.