diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-03-21 13:17:24 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-03-21 13:17:24 +0000 |
| commit | 8ef6917ea5eaae24bc2a15a06a99b3b1f24d1f35 (patch) | |
| tree | 86b9957c4a9a6c4da386064fb497a69cad9fad03 /frontends/php | |
| parent | 2547403188f63f0042a15aff4d17e04e2e80d715 (diff) | |
| download | zabbix-8ef6917ea5eaae24bc2a15a06a99b3b1f24d1f35.tar.gz zabbix-8ef6917ea5eaae24bc2a15a06a99b3b1f24d1f35.tar.xz zabbix-8ef6917ea5eaae24bc2a15a06a99b3b1f24d1f35.zip | |
- added quick help for overview (Eugene)
- developed Dicovery system (Alexei/Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3904 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
| -rw-r--r-- | frontends/php/css.css | 25 | ||||
| -rw-r--r-- | frontends/php/discovery.php | 138 | ||||
| -rw-r--r-- | frontends/php/include/classes/chelp.inc.php | 15 | ||||
| -rw-r--r-- | frontends/php/include/classes/ctag.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/classes/ctriggerinfo.mod.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/config.inc.php | 12 | ||||
| -rw-r--r-- | frontends/php/include/defines.inc.php | 5 | ||||
| -rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 6 | ||||
| -rw-r--r-- | frontends/php/include/page_header.php | 73 | ||||
| -rw-r--r-- | frontends/php/overview.php | 31 |
10 files changed, 280 insertions, 31 deletions
diff --git a/frontends/php/css.css b/frontends/php/css.css index e72cfa61..89c56ea6 100644 --- a/frontends/php/css.css +++ b/frontends/php/css.css @@ -358,7 +358,13 @@ table.tableinfo tr td.unknown_trigger { background-color: #BCBCBC; border: 1px table.tableinfo tr:hover td.unknown_trigger { background-color: #BCB7BC; border: 1px #BCB7BC solid; } table.tableinfo tr td.normal { background-color: #AADDAA; border: 1px #AADDAA solid; } +table.tableinfo tr:hover td.normal { background-color: #AAD9AA; border: 1px #AAD9AA solid; } +table.tableinfo tr td.active { background-color: #AADDAA; border: 1px #AADDAA solid; } +table.tableinfo tr:hover td.active { background-color: #AAD9AA; border: 1px #AAD9AA solid; } + +table.tableinfo tr td.disabled { background-color: #FF8888; border: 1px #FF8888 solid; } +table.tableinfo tr:hover td.disabled { background-color: #FA8388; border: 1px #FA8388 solid; } /****** HEADER *********/ table.header @@ -1082,6 +1088,25 @@ ul /************ END OF COLOR PICKER ***********/ +/************** DISCOVERY STATUS ************/ +.dhosts_active { + padding: 5px; + text-align: center; + color: #0FA00F; +} +.dhosts_disabled { + padding: 5px; + text-align: center; + color: #A00F0F; +} +.dservice_active { + background: #0FA00F; +} +.dservice_disabled { + background: #A00F0F; +} +/********** END OF DISCOVERY STATUS *********/ + .center { width: 100%; diff --git a/frontends/php/discovery.php b/frontends/php/discovery.php new file mode 100644 index 00000000..ce056123 --- /dev/null +++ b/frontends/php/discovery.php @@ -0,0 +1,138 @@ +<?php +/* +** ZABBIX +** Copyright (C) 2000-2005 SIA Zabbix +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +**/ +?> +<?php + require_once "include/config.inc.php"; + require_once "include/discovery.inc.php"; + + $page["file"] = "discovery.php"; + $page["title"] = "S_STATUS_OF_DISCOVERY"; + +include_once "include/page_header.php"; + +?> +<?php +// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION + $fields=array( + "druleid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), + ); + + check_fields($fields); + +?> +<?php + $r_form = new CForm(); + + $druleid = get_request('druleid', 0); + + $cmbDRules = new CComboBox('druleid',$druleid,'submit()'); + $cmbDRules->AddItem(0,S_ALL_SMALL); + $db_drules = DBselect('select distinct * from drules where '.DBid2nodeid('druleid').'='.$ZBX_CURNODEID." order by name"); + while($drule_data = DBfetch($db_drules)) + $cmbDRules->AddItem($drule_data['druleid'],$drule_data['name']); + $r_form->AddItem(array(S_DISCOVERY_RULE.SPACE,$cmbDRules)); + + show_table_header(S_STATUS_OF_DISCOVERY_BIG, $r_form); +?> +<?php + $db_dhosts = DBselect('select * from dhosts'. + ($druleid > 0 ? ' where druleid='.$druleid : ''). + ' order by status,ip' + ); + + $services = 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]); + + $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 = 'disabled'; + $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]); + } + } + + ksort($services); + + $header = array( + new CCol(S_HOST, 'center'), + new CCol(S_UPTIME.'/'.BR.S_DOWNTIME,'center') + ); + + 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( + 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; + + 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->AddRow($table_row); + } + + $table->Show(); +?> +<?php + +include_once "include/page_footer.php"; + +?> diff --git a/frontends/php/include/classes/chelp.inc.php b/frontends/php/include/classes/chelp.inc.php index 310c3286..0f11ab19 100644 --- a/frontends/php/include/classes/chelp.inc.php +++ b/frontends/php/include/classes/chelp.inc.php @@ -22,10 +22,21 @@ class CHelp extends CLink { /* public */ - function CHelp($url="index.php") + function CHelp($url="index.php",$side=null) { + if(is_null($side)) $side = 'right'; + if($side == 'right') + { + $pside = 'left'; + } + else + { + $side = 'left'; + $pside = 'right'; + } + parent::CLink(new CImg('images/general/help.gif','?'), 'http://www.zabbix.com/manual/v1.1/'.$url); - $this->options['style'] = 'float:right'; + $this->options['style'] = 'padding-'.$pside.': 5px; float:'.$side; $this->options['target'] = '_blank'; } } diff --git a/frontends/php/include/classes/ctag.inc.php b/frontends/php/include/classes/ctag.inc.php index df7d91ae..70decbfc 100644 --- a/frontends/php/include/classes/ctag.inc.php +++ b/frontends/php/include/classes/ctag.inc.php @@ -218,7 +218,7 @@ { insert_showhint_javascript(); - $text = addslashes(htmlspecialchars($text)); + $text = addslashes(htmlspecialchars(unpack_object($text))); if($width != '' || $class!= '') { $code = "show_hint_ext(this,event,'".$text."','".$width."','".$class."');"; @@ -229,7 +229,7 @@ } $this->AddAction('onMouseOver', $code); - $this->AddAction('onMouseMove', $code); + $this->AddAction('onMouseMove', 'update_hint(this,event);'); } function OnClick($handle_code) diff --git a/frontends/php/include/classes/ctriggerinfo.mod.php b/frontends/php/include/classes/ctriggerinfo.mod.php index 89481990..0f9c4b20 100644 --- a/frontends/php/include/classes/ctriggerinfo.mod.php +++ b/frontends/php/include/classes/ctriggerinfo.mod.php @@ -70,7 +70,7 @@ " and i.status=".ITEM_STATUS_ACTIVE. ' and h.hostid in ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, null, null, $this->nodeid).') '. - " group by priority"); + " group by priority,t.value"); while($row=DBfetch($db_priority)) { switch($row["value"]) diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index ed817d42..012a0566 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -1531,6 +1531,18 @@ function show_hint_ext(obj, e, hint_text, width, class_name) obj.onmouseout = hide_hint; } +function update_hint(obj, e) +{ + if(!hint_box) return; + + var cursor = get_cursor_position(e); + + var pos = GetPos(obj); + + hint_box.style.left = cursor.x + 10 + "px"; + hint_box.style.top = hint_box.y + obj.offsetHeight + "px"; +} + function create_hint_box() { if(hint_box) return; diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index 8583fcf0..c7dd3d2c 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -327,6 +327,9 @@ define('DRULE_STATUS_ACTIVE', 0); define('DRULE_STATUS_DISABLED', 1); + define('DSVC_STATUS_ACTIVE', 0); + define('DSVC_STATUS_DISABLED', 1); + define('SVC_SSH', 0); define('SVC_LDAP', 1); define('SVC_SMTP', 2); @@ -337,6 +340,8 @@ define('SVC_IMAP', 7); define('SVC_TCP', 8); + define('DHOST_STATUS_ACTIVE', 0); + define('DHOST_STATUS_DISABLED', 1); define("BR", "<br/>\n"); define("SPACE", " "); diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index b700e228..30bc8013 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -74,6 +74,8 @@ 'S_CANNOT_UPDATE_DISCOVERY_RULE'=> 'Cannot update discovery rule', 'S_DISCOVERY_RULE_ADDED'=> 'Discovery rule added', 'S_CANNOT_ADD_DISCOVERY_RULE'=> 'Cannot add discovery rule', + 'S_STATUS_OF_DISCOVERY_BIG'=> 'STATUS OF DISCOVERY', + 'S_STATUS_OF_DISCOVERY'=> 'Status of discovery', // httpdetails.php "S_DETAILS_OF_SCENARIO"=> "Details of scenario", @@ -843,6 +845,8 @@ "S_SHOW_GRAPH_OF_ITEM"=> "Show graph of item", "S_SHOW_VALUES_OF_ITEM"=> "Show values of item", "S_VALUES"=> "Values", + "S_5_MIN"=> "5 min", + "S_15_MIN"=> "15 min", // queue.php "S_QUEUE_BIG"=> "QUEUE", @@ -1054,12 +1058,14 @@ // srv_status.php "S_IT_SERVICES_BIG"=> "IT SERVICES", "S_SERVICE"=> "Service", + "S_SERVICES"=> "Services", "S_REASON"=> "Reason", "S_SLA_LAST_7_DAYS"=> "SLA (last 7 days)", "S_PLANNED_CURRENT_SLA"=> "Planned/current SLA", "S_TRIGGER_BIG"=> "TRIGGER", // triggers.php + "S_NO_TRIGGER"=> "No trigger", "S_NO_TRIGGERS_DEFINED"=> "No triggers defined", "S_CONFIGURATION_OF_TRIGGERS"=> "Configuration of triggers", "S_CONFIGURATION_OF_TRIGGERS_BIG"=> "CONFIGURATION OF TRIGGERS", diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php index 7b6d8d93..3d5d568b 100644 --- a/frontends/php/include/page_header.php +++ b/frontends/php/include/page_header.php @@ -110,6 +110,7 @@ COpt::profiling_start("page"); $ZBX_MENU = array( "view"=>array( "label" => S_MONITORING, + "node_perm" => PERM_READ_LIST, "default_page_id" => 0, "pages"=>array( array("url"=>"overview.php" ,"label"=>S_OVERVIEW ), @@ -133,6 +134,7 @@ COpt::profiling_start("page"); "sub_pages"=>array("chart2.php") ), array("url"=>"screens.php" ,"label"=>S_SCREENS ), + array("url"=>"discovery.php" ,"label"=>S_DISCOVERY , "user_type"=>USER_TYPE_ZABBIX_ADMIN), array("url"=>"srv_status.php" ,"label"=>S_IT_SERVICES , "sub_pages"=>array("report3.php","chart_sla.php","chart5.php") ), @@ -142,6 +144,7 @@ COpt::profiling_start("page"); ), "cm"=>array( "label" => S_INVENTORY, + "node_perm" => PERM_READ_LIST, "default_page_id" => 0, "pages"=>array( array("url"=>"hostprofiles.php" ,"label"=>S_HOSTS ) @@ -149,6 +152,7 @@ COpt::profiling_start("page"); ), "reports"=>array( "label" => S_REPORTS, + "node_perm" => PERM_READ_LIST, "default_page_id" => 0, "pages"=>array( array("url"=>"report1.php", "label"=>S_STATUS_OF_ZABBIX ), @@ -158,6 +162,8 @@ COpt::profiling_start("page"); ), "config"=>array( "label" => S_CONFIGURATION, + "user_type" => USER_TYPE_ZABBIX_ADMIN, + "node_perm" => PERM_READ_LIST, "default_page_id" => 0, "pages"=>array( array("url"=>"config.php" ,"label"=>S_GENERAL , @@ -189,6 +195,8 @@ COpt::profiling_start("page"); ), "admin"=>array( "label" => S_ADMINISTRATION, + "user_type" => USER_TYPE_SUPER_ADMIN, + "node_perm" => PERM_READ_WRITE, "default_page_id" => 1, "pages"=>array( ZBX_DISTRIBUTED ? array("url"=>"nodes.php" ,"label"=>S_NODES) : null , @@ -219,42 +227,59 @@ COpt::profiling_start("page"); foreach($ZBX_MENU as $label=>$sub) { -// Check permissions +// Check permissions for main menu unset($deny); if(!defined('ZBX_PAGE_NO_AUTHERIZATION')) { - if($label!='login' && !isset($USER_DETAILS['type'])) + if(isset($sub['user_type'])) { - $deny = true; + if($USER_DETAILS['type'] < $sub['user_type']) + $deny = true; } - elseif($label=='admin' && (!in_array($USER_DETAILS['type'], array(USER_TYPE_SUPER_ADMIN)) || - !in_array($ZBX_CURNODEID, get_accessible_nodes_by_user( - $USER_DETAILS,PERM_READ_WRITE,null, - PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))) - { - $deny = true; - } - elseif($label=='config' && ( - !in_array($USER_DETAILS['type'], array(USER_TYPE_SUPER_ADMIN, USER_TYPE_ZABBIX_ADMIN)) || - !in_array($ZBX_CURNODEID, get_accessible_nodes_by_user( - $USER_DETAILS,PERM_READ_LIST,null, - PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))) + + if(isset($sub['node_perm'])) { - $deny = true; - } - elseif($label!='login' && !in_array($ZBX_CURNODEID, get_accessible_nodes_by_user( - $USER_DETAILS,PERM_READ_LIST,null, + if(!in_array($ZBX_CURNODEID,get_accessible_nodes_by_user( + $USER_DETAILS,$sub['node_perm'],null, PERM_RES_IDS_ARRAY,$ZBX_CURNODEID))) + $deny = true; + } + + if($label=='login') { - $deny = true; + unset($deny); } } -// End of check permissions +// End of main menu permissions checking unset($menu_url); foreach($sub['pages'] as $id => $sub_pages) { + if(!defined('ZBX_PAGE_NO_AUTHERIZATION')) + { + if(isset($sub_pages['user_type'])) + { + if($USER_DETAILS['type'] < $sub_pages['user_type']) + { + unset($sub['pages'][$id]); + continue; + } + } + + if(isset($sub_pages['node_perm'])) + { + if(!in_array($ZBX_CURNODEID,get_accessible_nodes_by_user( + $USER_DETAILS,$sub_pages['node_perm'],null, + PERM_RES_IDS_ARRAY,$ZBX_CURNODEID))) + { + unset($sub['pages'][$id]); + continue; + } + } + } + + if(isset($page_exist)) continue; if($page['file'] == $sub_pages['url']) { @@ -263,7 +288,7 @@ COpt::profiling_start("page"); $menu_url = $sub_pages['url']; } $page_exist = true; - break; + $sub['pages'][$id]['active'] = true; /* mark as active */ } else if(isset($sub_pages['sub_pages'])) { @@ -274,15 +299,13 @@ COpt::profiling_start("page"); $menu_url = $sub_pages['url']; } $page_exist = true; - break; + $sub['pages'][$id]['active'] = true; /* mark as active */ } } } if(isset($menu_url)) /* active menu */ { - $sub['pages'][$id]['active'] = true; /* mark as active */ - $class = "active"; update_profile('web.menu.'.$label.'.last', $menu_url); diff --git a/frontends/php/overview.php b/frontends/php/overview.php index 71008ca8..afd92191 100644 --- a/frontends/php/overview.php +++ b/frontends/php/overview.php @@ -93,7 +93,36 @@ include_once "include/page_header.php"; $cmbType->AddItem(SHOW_DATA, S_DATA); $form->AddItem(array(S_TYPE.SPACE,$cmbType)); - show_table_header(S_OVERVIEW_BIG, $form); + $help = new CHelp('web.view.php','left'); + $help_table = new CTableInfo(); + $help_table->AddOption('style', 'width: 200px'); + if($_REQUEST["type"]==SHOW_TRIGGERS) + { + $help_table->AddRow(array(new CCol(SPACE, 'normal'), S_DISABLED)); + } + foreach(array(1,2,3,4,5) as $tr_severity) + $help_table->AddRow(array(new CCol(get_severity_description($tr_severity),get_severity_style($tr_severity)),S_ENABLED)); + $help_table->AddRow(array(new CCol(SPACE, 'unknown_trigger'), S_UNKNOWN)); + if($_REQUEST["type"]==SHOW_TRIGGERS) + { + $col = new CCol(SPACE, 'unknown_trigger'); + $col->AddOption('style','background-image: url(images/gradients/blink1.gif); '. + 'background-position: top left; background-repeat: repeate;'); + $help_table->AddRow(array($col, S_5_MIN)); + $col = new CCol(SPACE, 'unknown_trigger'); + $col->AddOption('style','background-image: url(images/gradients/blink2.gif); '. + 'background-position: top left; background-repeat: repeate;'); + $help_table->AddRow(array($col, S_15_MIN)); + $help_table->AddRow(array(new CCol(SPACE), S_NO_TRIGGER)); + } + else + { + $help_table->AddRow(array(new CCol(SPACE), S_DISABLED.' '.S_OR.' '.S_NO_TRIGGER)); + } + + $help->SetHint($help_table); + show_table_header(array($help, S_OVERVIEW_BIG), $form); + unset($help, $help_table, $form, $col); ?> <?php |
