Changeset 192


Ignore:
Timestamp:
Apr 26, 2009, 11:30:31 PM (16 years ago)
Author:
george
Message:
  • Přidáno: Tabulka HostType definující účel zařízení v síti.
  • Opraveno: Zobrazování online stavu počítačů v topologii s adresou IP vyšší než 100.
Location:
trunk
Files:
1 added
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r189 r192  
    104104    $Output2 = '';
    105105
    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');
    107107    $DbRow = $DbResult->fetch_array();
    108108    $TotalComputers = $DbRow[0];
    109109
    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)');
    111111    $DbRow = $DbResult->fetch_array();
    112112    $OnlineComputers = $DbRow[0];
     
    118118    $TotalUser = $DbRow[0];
    119119
    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');
    121121    $DbRow = $DbResult->fetch_array();
    122122    $OnlineUser = $DbRow[0];
     
    173173  function OnlineHostList()
    174174  {
    175     global $Database;
    176 
    177175    $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 BY name');
     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');
    179177    while($Row = $DbResult->fetch_array())
    180178    {
  • trunk/is/topologie-img.php

    r129 r192  
    112112      $count[$level]++;
    113113  // --- 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);
    115115      $childcnt = $DbResult->fetch_array();
    116116      if ($childcnt[0] > 0)
     
    164164$data = gentree(1);
    165165$datawidth = $data['width'];
    166 for($i=0; $i <= $maxindex; $i++)
     166for($i = 0; $i <= $maxindex; $i++)
    167167{
    168168  if(!array_key_exists($i, $vleft)) $vleft[$i] = 0;
     
    175175$halfx = $spacex / 2;
    176176$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');
     181while($HostType = $DbResult->fetch_assoc())
     182  $IconList[$HostType['Id']] = imagecreatefrompng('images/'.$HostType['IconName'].'.png');
     183
    180184// === 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);
    182186$background_color = imagecolorallocate($im, 255, 255, 255);
    183187$black = imagecolorallocate($im, 0, 0, 0);
     
    193197}
    194198
    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');
    196200while($item = $DbResult->fetch_array())
    197201{
     
    207211      imageline($im, xpos($id) + $halfx, ($vtop[$id] + 1) * $spacey - 10, xpos($id) + $halfx, ($vtop[$id] + 1) * $spacey, $black);
    208212    }
    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    {
    221217      $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;
    232225    }
    233226//      $text='IP: '.$ip[0];
    234227//      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);
    236229//    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    {
    238232      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);
    240235  }
    241236}
     
    244239if(!($debug > 1))
    245240{
    246   header("Content-type: image/png");
    247   header("Cache-Control: no-cache");    // Dynamický graf, nekešovat
     241  header('Content-type: image/png');
     242  header('Cache-Control: no-cache');
    248243  imagepng($im);
    249244  imagedestroy($im);
    250   imagedestroy($im_comp);
    251   imagedestroy($im_dev);
    252 }
     245}
     246
    253247?>
  • trunk/is/topologie.php

    r4 r192  
    11<?php
    2 include_once('../style.php');
     2include_once('../global.php');
    33
    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/>
     4class 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/>
    812<p>Vysvětlivky: Obrázek znázorňuje připojení prvků sítě do internetu.<br/>
    913<img src="images/comp.png"> Je počítač zapojený v síti a pod ním je uvedeno jeho jméno.
     
    1620z počítače Centrála, takže při výpadku zařízení nebude možné zjistit stav
    1721zaří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>');
     22zjišťovat je použita <span style="color:gray">šedá barvou</span>.</p>';
     23    return($Output);
     24  }
     25}
    1926
    20 ShowFooter();
     27$System->AddModule(new NetworkTopologyPage());
     28$System->Modules['NetworkTopologyPage']->GetOutput();
     29
    2130?>
  • trunk/network/dostupnost.php

    r167 r192  
    1313    $Output .= '<div align="center">';
    1414
     15    $HostTypeList = array();
     16    $DbResult = $this->Database->select('HostType', '*');
     17    while($DbRow = $DbResult->fetch_assoc())
     18      $HostTypeList[$DbRow['Id']] = $DbRow;
     19   
    1520    // Zařízení
    1621    $Output .= '<br /><table class="WideTable" style="font-size: small;">';
    1722    $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=0 GROUP 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))
    2126    {
    2227      $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.