diff options
author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-03-05 11:05:22 +0000 |
---|---|---|
committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-03-05 11:05:22 +0000 |
commit | e5992e34a200830b997e1e157ea09bfc60e28782 (patch) | |
tree | eb4a48c6f859903ecc4ac2e0e866ea5646d4ee1e /frontends | |
parent | 3afdae1c3fc06fe0d465f9c8416dec27ab5c957f (diff) | |
download | zabbix-e5992e34a200830b997e1e157ea09bfc60e28782.tar.gz zabbix-e5992e34a200830b997e1e157ea09bfc60e28782.tar.xz zabbix-e5992e34a200830b997e1e157ea09bfc60e28782.zip |
- [DEV-108] Configuration GUI - Discovery
git-svn-id: svn://svn.zabbix.com/trunk@5439 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends')
-rw-r--r-- | frontends/php/discovery.php | 140 |
1 files changed, 77 insertions, 63 deletions
diff --git a/frontends/php/discovery.php b/frontends/php/discovery.php index 728ff111..c9d5c976 100644 --- a/frontends/php/discovery.php +++ b/frontends/php/discovery.php @@ -43,93 +43,107 @@ include_once "include/page_header.php"; $cmbDRules = new CComboBox('druleid',$druleid,'submit()'); $cmbDRules->AddItem(0,S_ALL_SMALL); - $db_drules = DBselect('select distinct * from drules where '.DBin_node('druleid').' order by name'); - while($drule_data = DBfetch($db_drules)) + $db_drules = DBselect('select distinct druleid,name from drules where '.DBin_node('druleid').' order by name'); + while($drule = DBfetch($db_drules)) $cmbDRules->AddItem( - $drule_data['druleid'], - get_node_name_by_elid($drule_data['druleid']).$drule_data['name'] + $drule['druleid'], + get_node_name_by_elid($drule['druleid']).$drule['name'] ); $r_form->AddItem(array(S_DISCOVERY_RULE.SPACE,$cmbDRules)); show_table_header(S_STATUS_OF_DISCOVERY_BIG, $r_form); - $db_dhosts = DBselect('SELECT d.* '. - ' FROM dhosts d'. - ($druleid > 0 ? ' WHERE d.druleid='.$druleid : ''). - order_by('d.dhostid','d.status,d.ip') - ); - $services = array(); - $discovery_info = array(); - - while($drule_data = DBfetch($db_dhosts)){ - $class = 'enabled'; - $time = 'lastup'; - if(DHOST_STATUS_DISABLED == $drule_data['status']){ - $class = 'disabled'; - $time = 'lastdown'; - } - - $discovery_info[$drule_data['ip']] = array('class' => $class, 'time' => $drule_data[$time], 'druleid' => $drule_data['druleid']); - $db_dservices = DBselect('SELECT * FROM dservices '. - ' WHERE dhostid='.$drule_data['dhostid']. - ' order by status,type,port'); - while($dservice_data = DBfetch($db_dservices)){ - $class = 'active'; - $time = 'lastup'; - - if(DSVC_STATUS_DISABLED == $dservice_data['status']){ - $class = 'inactive'; - $time = 'lastdown'; - } - - $service_name = discovery_check_type2str($dservice_data['type']).':'.$dservice_data['port']; - - $services[$service_name] = 1; - - $discovery_info - [$drule_data['ip']] - ['services'] - [$service_name] = array('class' => $class, 'time' => $dservice_data[$time]); - } + $db_dservices = DBselect('SELECT s.type,s.port FROM dservices s,dhosts h'. + ' WHERE '.DBin_node('s.dserviceid'). + ' AND s.dhostid=h.dhostid'. + ($druleid > 0 ? ' AND h.druleid='.$druleid : '')); + while ($dservice = DBfetch($db_dservices)) { + $service_name = discovery_check_type2str($dservice['type']).':'.$dservice['port']; + $services[$service_name] = 1; } ksort($services); $header = array( - is_show_subnodes() ? new CCol(S_NODE, 'center') : null, - new CCol(make_sorting_link(S_HOST,'d.dhostid'), 'center'), - new CCol(array(S_UPTIME.'/',BR(),S_DOWNTIME),'center') - ); + is_show_subnodes() ? new CCol(S_NODE, 'center') : null, + new CCol(make_sorting_link(S_HOST,'dhostid'), 'center'), + new CCol(array(S_UPTIME.'/',BR(),S_DOWNTIME),'center') + ); - foreach($services as $name => $foo) - { + foreach ($services as $name => $foo) { $header[] = new CImg('vtext.php?text='.$name); } $table = new CTableInfo(); $table->SetHeader($header,'vertical_header'); - foreach($discovery_info as $ip => $h_data) - { - $table_row = array( - get_node_name_by_elid($h_data['druleid']), - new CSpan($ip, $h_data['class']), - new CSpan(convert_units(time() - $h_data['time'], 'uptime'), $h_data['class']) - ); - foreach($services as $name => $foo) - { - $class = null; $time = SPACE; + $db_drules = DBselect('select distinct druleid,name from drules where '.DBin_node('druleid'). + ($druleid > 0 ? ' and druleid='.$druleid : ''). + ' order by name'); + while($drule = DBfetch($db_drules)) { + $discovery_info = array(); + + $db_dhosts = DBselect('SELECT dhostid,druleid,ip,status,lastup,lastdown '. + ' FROM dhosts WHERE '.DBin_node('dhostid'). + ' AND druleid='.$drule['druleid']. + order_by('dhostid','status,ip')); + while($dhost = DBfetch($db_dhosts)){ + $class = 'enabled'; + $time = 'lastup'; + if(DHOST_STATUS_DISABLED == $dhost['status']){ + $class = 'disabled'; + $time = 'lastdown'; + } + + $discovery_info[$dhost['ip']] = array('class' => $class, 'time' => $dhost[$time], 'druleid' => $dhost['druleid']); + + $db_dservices = DBselect('SELECT type,port,status,lastup,lastdown FROM dservices '. + ' WHERE dhostid='.$dhost['dhostid']. + ' order by status,type,port'); + while($dservice = DBfetch($db_dservices)){ + $class = 'active'; + $time = 'lastup'; + + if(DSVC_STATUS_DISABLED == $dservice['status']){ + $class = 'inactive'; + $time = 'lastdown'; + } + + $service_name = discovery_check_type2str($dservice['type']).':'.$dservice['port']; - if(isset($h_data['services'][$name])) + $discovery_info + [$dhost['ip']] + ['services'] + [$service_name] = array('class' => $class, 'time' => $dservice[$time]); + } + } + + if ($druleid == 0 && !empty($discovery_info)) { + $table->AddRow(array(get_node_name_by_elid($drule['druleid']),$drule['name'],'','','')); + } + + foreach($discovery_info as $ip => $h_data) + { + $table_row = array( + get_node_name_by_elid($h_data['druleid']), + new CSpan($ip, $h_data['class']), + new CSpan(convert_units(time() - $h_data['time'], 'uptime'), $h_data['class']) + ); + foreach($services as $name => $foo) { - $class = $h_data['services'][$name]['class']; - $time = $h_data['services'][$name]['time']; + $class = null; $time = SPACE; + + if(isset($h_data['services'][$name])) + { + $class = $h_data['services'][$name]['class']; + $time = $h_data['services'][$name]['time']; + } + $table_row[] = new CCol(SPACE, $class); } - $table_row[] = new CCol(SPACE, $class); + $table->AddRow($table_row); } - $table->AddRow($table_row); } $table->Show(); |