Changeset 192
- Timestamp:
- Apr 26, 2009, 11:30:31 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/index.php
r189 r192 104 104 $Output2 = ''; 105 105 106 $DbResult = $this->Database-> select('hosts', 'COUNT(*)', 'show_online=1');106 $DbResult = $this->Database->query('SELECT COUNT(*) FROM hosts LEFT JOIN HostType ON HostType.Id = hosts.type WHERE HostType.ShowOnline = 1'); 107 107 $DbRow = $DbResult->fetch_array(); 108 108 $TotalComputers = $DbRow[0]; 109 109 110 $DbResult = $this->Database-> select('hosts', 'COUNT(*)', 'show_online=1 AND online=1');110 $DbResult = $this->Database->query('SELECT COUNT(*) FROM hosts LEFT JOIN HostType ON HostType.Id = hosts.type WHERE (HostType.ShowOnline = 1) AND (hosts.online = 1)'); 111 111 $DbRow = $DbResult->fetch_array(); 112 112 $OnlineComputers = $DbRow[0]; … … 118 118 $TotalUser = $DbRow[0]; 119 119 120 $DbResult = $this->Database-> select('hosts', 'COUNT(DISTINCT(user))', 'show_online=1 AND online=1');120 $DbResult = $this->Database->query('SELECT COUNT(DISTINCT(user)) FROM hosts LEFT JOIN HostType ON HostType.Id = hosts.type WHERE HostType.ShowOnline = 1 AND hosts.online = 1'); 121 121 $DbRow = $DbResult->fetch_array(); 122 122 $OnlineUser = $DbRow[0]; … … 173 173 function OnlineHostList() 174 174 { 175 global $Database;176 177 175 $Output = '<div class="PanelTitle">Online počítače</div><span style="font-size: smaller;">'; 178 $DbResult = $ Database->select('hosts', '*', 'online=1 AND show_online=1 ORDER BYname');176 $DbResult = $this->Database->query('SELECT hosts.name FROM hosts LEFT JOIN HostType ON HostType.Id = hosts.type WHERE (HostType.ShowOnline = 1) AND (hosts.online = 1) ORDER BY hosts.name'); 179 177 while($Row = $DbResult->fetch_array()) 180 178 { -
trunk/is/topologie-img.php
r129 r192 112 112 $count[$level]++; 113 113 // --- Zjisti existenci potomků ---------------------------------------------- 114 $DbResult = $Database->query( "SELECT COUNT(*) FROM hosts WHERE used=1 AND parent = ".$curr);114 $DbResult = $Database->query('SELECT COUNT(*) FROM hosts WHERE used=1 AND parent = '.$curr); 115 115 $childcnt = $DbResult->fetch_array(); 116 116 if ($childcnt[0] > 0) … … 164 164 $data = gentree(1); 165 165 $datawidth = $data['width']; 166 for($i =0; $i <= $maxindex; $i++)166 for($i = 0; $i <= $maxindex; $i++) 167 167 { 168 168 if(!array_key_exists($i, $vleft)) $vleft[$i] = 0; … … 175 175 $halfx = $spacex / 2; 176 176 $halfy = $spacey / 2; 177 // === Načtení pomocných obrázků =============================================== 178 $im_comp = imagecreatefrompng('images/comp.png'); 179 $im_dev = imagecreatefrompng('images/device.png'); 177 178 // Preload icon images 179 $IconList = array(); 180 $DbResult = $Database->query('SELECT * FROM HostType'); 181 while($HostType = $DbResult->fetch_assoc()) 182 $IconList[$HostType['Id']] = imagecreatefrompng('images/'.$HostType['IconName'].'.png'); 183 180 184 // === Generování obrázku ====================================================== 181 $im = imagecreate(($datawidth +$width+3.2) * $halfx, ($height + 1) * $spacey);185 $im = imagecreate(($datawidth + $width + 3.2) * $halfx, ($height + 1) * $spacey); 182 186 $background_color = imagecolorallocate($im, 255, 255, 255); 183 187 $black = imagecolorallocate($im, 0, 0, 0); … … 193 197 } 194 198 195 $DbResult = $Database->query( "SELECT * FROM hosts WHERE used=1");199 $DbResult = $Database->query('SELECT * FROM hosts JOIN HostType ON HostType.Id = hosts.type WHERE hosts.used=1'); 196 200 while($item = $DbResult->fetch_array()) 197 201 { … … 207 211 imageline($im, xpos($id) + $halfx, ($vtop[$id] + 1) * $spacey - 10, xpos($id) + $halfx, ($vtop[$id] + 1) * $spacey, $black); 208 212 } 209 $ip = explode('.',$item['IP']); 210 if(!array_key_exists(3, $ip)) $ip[3] = ''; 211 if($ip[3] < 100) 212 { 213 $image = $im_comp; 214 } else $image = $im_dev; 215 if(($ip[0] != 192) and ($ip[0] != 168)) 216 { 217 $image = $im_dev; 218 } 219 if($item['IP'] == '') 220 { 213 214 $image = $IconList[$item['type']]; 215 if($item['IP'] == '') 216 { 221 217 $color = $gray; 222 $image = $im_dev; 223 } else 224 { 225 if((($ip[0] != 192) and ($ip[0] != 168)) or ($ip[3] >= 100) or ($ip[3] == 1)) 226 { 227 if($item['online'] == 1) { $color = $green; } else $color = $red; 228 } else 229 { 230 if($item['online'] == 1) { $color = $green; } else $color = $black; 231 } 218 } else 219 if($item['ShowOnline'] == 1) 220 { 221 if($item['online'] == 1) $color = $green; else $color = $black; 222 } else 223 { 224 if($item['online'] == 1) $color = $green; else $color = $red; 232 225 } 233 226 // $text='IP: '.$ip[0]; 234 227 // imagestring($im,2,xpos($id)+($spacex-strlen($text)*imagefontwidth(2))/2,$vtop[$id]*$spacey+24+imagefontheight(2),$text,$black); 235 imagecopy($im, $image, xpos($id) +$halfx-15,$vtop[$id]*$spacey+12, 0, 0, 30, 30);228 imagecopy($im, $image, xpos($id) + $halfx - 15, $vtop[$id] * $spacey + 12, 0, 0, 30, 30); 236 229 // imagerectangle($im,xpos($id)+$halfx-6,$vtop[$id]*$spacey+16,xpos($id)+$halfx+6,$vtop[$id]*$spacey+28,$color); 237 if ($debug) { 230 if($debug) 231 { 238 232 imagestring($im, 2, xpos($id) + ($spacex - strlen($item['id']) * imagefontwidth(2)) / 2, $vtop[$id] * $spacey + 31 + imagefontheight(2), $item['id'], $color); 239 } else imagestring($im, 2, xpos($id) + ($spacex - strlen($item['name']) * imagefontwidth(2)) / 2, $vtop[$id] * $spacey + 31 + imagefontheight(2), strtoupper($item['name']), $color); 233 } else 234 imagestring($im, 2, xpos($id) + ($spacex - strlen($item['name']) * imagefontwidth(2)) / 2, $vtop[$id] * $spacey + 31 + imagefontheight(2), strtoupper($item['name']), $color); 240 235 } 241 236 } … … 244 239 if(!($debug > 1)) 245 240 { 246 header( "Content-type: image/png");247 header( "Cache-Control: no-cache"); // Dynamický graf, nekešovat241 header('Content-type: image/png'); 242 header('Cache-Control: no-cache'); 248 243 imagepng($im); 249 244 imagedestroy($im); 250 imagedestroy($im_comp); 251 imagedestroy($im_dev); 252 } 245 } 246 253 247 ?> -
trunk/is/topologie.php
r4 r192 1 1 <?php 2 include_once('../ style.php');2 include_once('../global.php'); 3 3 4 ShowHeader('Grafické zobrazení topologie sítě','Topologie sítě'); 5 6 // Seznam segmentů a zařízení 7 echo('<img src="topologie-img.php"><br/> 4 class NetworkTopologyPage extends Page 5 { 6 var $FullTitle = 'Grafické zobrazení topologie sítě'; 7 var $ShortTitle = 'Topologie sítě'; 8 9 function Show() 10 { 11 $Output = '<img src="topologie-img.php"><br/> 8 12 <p>Vysvětlivky: Obrázek znázorňuje připojení prvků sítě do internetu.<br/> 9 13 <img src="images/comp.png"> Je počítač zapojený v síti a pod ním je uvedeno jeho jméno. … … 16 20 z počítače Centrála, takže při výpadku zařízení nebude možné zjistit stav 17 21 zařízení, které jsou přes něj připojeny. U zařízení, kde není stav možné 18 zjišťovat je použita <span style="color:gray">šedá barvou</span>.</p>'); 22 zjišťovat je použita <span style="color:gray">šedá barvou</span>.</p>'; 23 return($Output); 24 } 25 } 19 26 20 ShowFooter(); 27 $System->AddModule(new NetworkTopologyPage()); 28 $System->Modules['NetworkTopologyPage']->GetOutput(); 29 21 30 ?> -
trunk/network/dostupnost.php
r167 r192 13 13 $Output .= '<div align="center">'; 14 14 15 $HostTypeList = array(); 16 $DbResult = $this->Database->select('HostType', '*'); 17 while($DbRow = $DbResult->fetch_assoc()) 18 $HostTypeList[$DbRow['Id']] = $DbRow; 19 15 20 // Zařízení 16 21 $Output .= '<br /><table class="WideTable" style="font-size: small;">'; 17 22 $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>'; 18 $DbResult = $this->Database->query('SELECT hosts. name, PeriodHour.Percent as Hour, PeriodDay.Percent as Day, PeriodWeek.Percent as Week, PeriodMonth.Percent as Month, PeriodYear.Percent as Year FROM hosts 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=hosts.id 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=hosts.id 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=hosts.id 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=hosts.id 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=hosts.id WHERE hosts.used=1 AND hosts.show_online=0GROUP BY hosts.IP ORDER BY name');19 echo($this->Database->error);20 while($Row = $DbResult->fetch_array())23 $DbResult = $this->Database->query('SELECT hosts.type, hosts.name, PeriodHour.Percent as Hour, PeriodDay.Percent as Day, PeriodWeek.Percent as Week, PeriodMonth.Percent as Month, PeriodYear.Percent as Year FROM hosts 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=hosts.id 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=hosts.id 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=hosts.id 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=hosts.id 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=hosts.id WHERE hosts.used=1 GROUP BY hosts.IP ORDER BY name'); 24 while($Row = $DbResult->fetch_assoc()) 25 if(($Row['type'] == 1) or ($Row['type'] == 4)) 21 26 { 22 27 $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>';
Note:
See TracChangeset
for help on using the changeset viewer.