Index: frontends/php/overview.php =================================================================== --- frontends/php/overview.php (revision 28312) +++ frontends/php/overview.php (working copy) @@ -41,6 +41,7 @@ 'view_style' => array(T_ZBX_INT, O_OPT, P_SYS, IN("0,1"), NULL), 'type' => array(T_ZBX_INT, O_OPT, P_SYS, IN("0,1"), NULL), 'fullscreen' => array(T_ZBX_INT, O_OPT, P_SYS, IN("0,1"), NULL), + 'application'=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), ); check_fields($fields); @@ -54,6 +55,8 @@ $_REQUEST['type'] = get_request('type', CProfile::get('web.overview.type', SHOW_TRIGGERS)); CProfile::update('web.overview.type', $_REQUEST['type'], PROFILE_TYPE_INT); +$_REQUEST['application'] = get_request('application',CProfile::get('web.overview.application',null)); +CProfile::update('web.overview.application',$_REQUEST['application'],PROFILE_TYPE_STR); $options = array( 'groups' => array( 'monitored_hosts' => 1, @@ -132,16 +135,45 @@ $cmbStyle->addItem(STYLE_LEFT, _('Left')); $form_l->additem(array(_('Hosts location'), $cmbStyle)); +// add application combo +$sql_from = ''; +$sql_where = ''; +if($_REQUEST['groupid'] > 0){ + $sql_from .= ' JOIN hosts_groups hg on hg.hostid=h.hostid'; + $sql_where.= ' AND hg.groupid='.$_REQUEST['groupid']; +} +$db_app_res = DBselect('SELECT DISTINCT a.name '. + ' FROM applications a'. + ' JOIN hosts h on a.hostid=h.hostid'. + $sql_from . + ' WHERE h.status<>'.HOST_STATUS_TEMPLATE. + $sql_where . + order_by('a.name')); + +$applist=array(); +while($db_app = DBfetch($db_app_res)) { + $applist[$db_app['name']]=$db_app['name']; +} + if (!isset ($applist[$_REQUEST['application']])) { + $_REQUEST['application']=''; +} +$cmbApp = new CComboBox('application', $_REQUEST['application'], 'submit()'); +$cmbApp->addItem('','all'); +foreach ($applist as $app) { + $cmbApp->addItem($app,$app); +} +$form_l->addItem(array(_('Application'), $cmbApp)); + $over_wdgt->addHeader(_('Overview'), $form); $over_wdgt->addHeader($form_l); if ($_REQUEST['type'] == SHOW_DATA) { - $table = get_items_data_overview(array_keys($pageFilter->hosts), $_REQUEST['view_style']); + $table = get_items_data_overview(array_keys($pageFilter->hosts), $_REQUEST['view_style'],$_REQUEST['application']); } elseif ($_REQUEST['type'] == SHOW_TRIGGERS) { - $table = get_triggers_overview(array_keys($pageFilter->hosts), $_REQUEST['view_style']); + $table = get_triggers_overview(array_keys($pageFilter->hosts), $_REQUEST['view_style'],null,$_REQUEST['application']); } $over_wdgt->addItem($table); Index: frontends/php/include/triggers.inc.php =================================================================== --- frontends/php/include/triggers.inc.php (revision 28312) +++ frontends/php/include/triggers.inc.php (working copy) @@ -1392,7 +1392,7 @@ return DBexecute('DELETE FROM functions WHERE '.DBcondition('triggerid', $triggerids)); } -function get_triggers_overview($hostids, $view_style = null, $params = array()) { +function get_triggers_overview($hostids, $view_style = null, $params = array(), $application = null) { if (is_null($view_style)) { $view_style = CProfile::get('web.overview.view.style', STYLE_TOP); } @@ -1404,7 +1404,8 @@ 'skipDependent' => true, 'output' => API_OUTPUT_EXTEND, 'selectHosts' => array('hostid', 'name'), - 'sortfield' => 'description' + 'sortfield' => 'description', + 'applicationname' => $application )); // get hosts Index: frontends/php/include/screens.inc.php =================================================================== --- frontends/php/include/screens.inc.php (revision 28312) +++ frontends/php/include/screens.inc.php (working copy) @@ -1195,7 +1195,7 @@ $hostids[$tmp_host['hostid']] = $tmp_host['hostid']; } - $item = array(get_items_data_overview($hostids, $style)); + $item = array(get_items_data_overview($hostids, $style, $url)); if ($editmode == 1) { array_push($item, new CLink(_('Change'), $action)); } Index: frontends/php/include/items.inc.php =================================================================== --- frontends/php/include/items.inc.php (revision 28312) +++ frontends/php/include/items.inc.php (working copy) @@ -646,9 +646,18 @@ * @param null $view_style * @return CTableInfo */ -function get_items_data_overview($hostids, $view_style) { +function get_items_data_overview($hostids, $view_style,$application=null) { global $USER_DETAILS; + $sql_app_from=''; + $sql_app_where=''; + if(!is_null($application) and strcmp($application,'') != 0 ) { + $sql_app_from= + ' LEFT JOIN items_applications ia on ia.itemid=i.itemid'. + ' LEFT JOIN applications a on a.applicationid=ia.applicationid'; + $sql_app_where=' AND a.name=' . zbx_dbstr($application); + } + $table = new CTableInfo(_('No items defined.')); $db_items = DBselect( @@ -657,10 +666,12 @@ ' FROM hosts h,items i'. ' LEFT JOIN functions f ON f.itemid=i.itemid'. ' LEFT JOIN triggers t ON t.triggerid=f.triggerid AND t.status='.TRIGGER_STATUS_ENABLED. + $sql_app_from . ' WHERE '.DBcondition('h.hostid', $hostids). ' AND h.status='.HOST_STATUS_MONITORED. ' AND h.hostid=i.hostid'. ' AND i.status='.ITEM_STATUS_ACTIVE. + $sql_app_where . ' AND '.DBcondition('i.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)). ' ORDER BY i.name,i.itemid' ); Index: frontends/php/include/views/configuration.screen.constructor.edit.php =================================================================== --- frontends/php/include/views/configuration.screen.constructor.edit.php (revision 28312) +++ frontends/php/include/views/configuration.screen.constructor.edit.php (working copy) @@ -384,6 +384,18 @@ 'formlist' ) )); + + $cmbApp = new CComboBox('url', $url, 'submit()'); + $cmbApp->addItem('','all'); + $db_app_res = DBselect('SELECT DISTINCT a.name '. + ' FROM applications a'. + ' JOIN hosts h on a.hostid=h.hostid'. + ' WHERE h.status<>'.HOST_STATUS_TEMPLATE. + order_by('a.name')); + while($db_app = DBfetch($db_app_res)){ + $cmbApp->addItem($db_app['name'],$db_app['name']); + } + $screenFormList->addRow(_('Application'), $cmbApp); } /* Index: frontends/php/api/classes/CTrigger.php =================================================================== --- frontends/php/api/classes/CTrigger.php (revision 28312) +++ frontends/php/api/classes/CTrigger.php (working copy) @@ -77,6 +77,7 @@ 'triggerids' => null, 'itemids' => null, 'applicationids' => null, + 'applicationname' => null, 'discoveryids' => null, 'functions' => null, 'inherited' => null, @@ -293,7 +294,25 @@ $sqlParts['group']['id'] = 'id.parent_itemid'; } } + // applicationname + // must exist, no "other" for items with no application + if(!is_null($options['applicationname'])){ + if($options['output'] != API_OUTPUT_SHORTEN){ + $sql_parts['select']['applicationame'] = 'a.name'; + } + $sql_parts['from']['functions'] = 'functions f'; + $sql_parts['from']['items'] = 'items i'; + $sql_parts['from']['applications'] = 'applications a'; + $sql_parts['from']['items_applications'] = 'items_applications ia'; + $sql_parts['where']['a'] = 'a.name='. zbx_dbstr($options['applicationname']); + $sql_parts['where']['iia'] = 'ia.itemid=i.itemid'; + $sql_parts['where']['iaa'] = 'ia.applicationid=a.applicationid'; + $sql_parts['where']['ia'] = 'i.hostid=a.hostid'; + $sql_parts['where']['ft'] = 'f.triggerid=t.triggerid'; + $sql_parts['where']['fi'] = 'f.itemid=i.itemid'; + } + // functions if (!is_null($options['functions'])) { zbx_value2array($options['functions']);