- Timestamp:
- Jan 6, 2010, 1:43:24 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/network/dostupnost.php
r261 r268 1 1 <?php 2 3 die();4 2 5 3 include_once('../global.php'); … … 9 7 var $FullTitle = 'Dostupnost aktivních prvků sítě'; 10 8 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 ); 11 17 12 18 function Show() … … 23 29 // Zařízení 24 30 $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) 28 39 { 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 NetworkInterface30 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.Id31 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.Id32 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.Id33 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.id34 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.Id35 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 .= '<t r><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>'; 42 53 } 43 54 $Output .= '</table></div>';
Note:
See TracChangeset
for help on using the changeset viewer.