array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), NULL), 'groupid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), 'hostgroupid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), 'hostid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), 'tpl_triggerid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), 'triggerid'=> array(T_ZBX_INT, O_OPT, P_SYS|P_NZERO, DB_ID, NULL) ); check_fields($fields); $config = get_request('config',get_profile('web.avail_report.config',0)); update_profile('web.avail_report.config',$config); if(0 == $config){ $options = array('allow_all_hosts','always_select_first_host','monitored_hosts','with_items'); } else{ $options = array('allow_all_hosts','always_select_first_host','templated_hosts','with_items'); } if(!$ZBX_WITH_SUBNODES) array_push($options,'only_current_node'); validate_group_with_host(PERM_READ_LIST,$options); ?> AddRow(new CImg('chart4.php?triggerid='.$_REQUEST['triggerid'])); $table->Show(); } else if(isset($_REQUEST['hostid'])){ if(0 == $config){ if($_REQUEST['hostid'] > 0) $sql_cond = ' AND h.hostid='.$_REQUEST['hostid']; else $sql_cond = ''; } else{ $sql_cond = ' AND h.hostid=ht.hostid '; $sql_cond.=(isset($_REQUEST['hostgroupid']) && ($_REQUEST['hostgroupid']>0))?' AND g.groupid ='.$_REQUEST['hostgroupid']:''; if($_REQUEST['hostid'] > 0) $sql_cond.=' AND ht.templateid='.$_REQUEST['hostid']; if(isset($_REQUEST['tpl_triggerid']) && ($_REQUEST['tpl_triggerid'] > 0)) $sql_cond.= ' AND t.templateid='.$_REQUEST['tpl_triggerid']; } if($_REQUEST['hostid'] > 0){ $row = DBfetch(DBselect('SELECT host FROM hosts WHERE hostid='.$_REQUEST['hostid'])); show_table_header($row['host']); } else{ if(isset($_REQUEST['tpl_triggerid']) && ($_REQUEST['tpl_triggerid'] > 0)) show_table_header(expand_trigger_description($_REQUEST['tpl_triggerid'])); else show_table_header(S_ALL_HOSTS_BIG); } $result = DBselect('SELECT DISTINCT h.hostid,h.host,t.triggerid,t.expression,t.description,t.value '. ' FROM triggers t,hosts h,items i,functions f, hosts_templates ht, groups g, hosts_groups hg '. ' WHERE f.itemid=i.itemid '. ' AND hg.hostid=h.hostid'. ' AND g.groupid=hg.groupid '. ' AND h.hostid=i.hostid '. ' AND h.hostid in ('.$available_hosts.')'. ' AND t.status='.TRIGGER_STATUS_ENABLED. ' AND t.triggerid=f.triggerid '. ' AND '.DBin_node('t.triggerid'). ' AND i.status='.ITEM_STATUS_ACTIVE. ' AND h.status='.HOST_STATUS_MONITORED. $sql_cond. ' ORDER BY h.host, t.description'); $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); $table = new CTableInfo(); $table->setHeader(array(is_show_subnodes() ? S_NODE : null,(($_REQUEST['hostid'] == 0) || (1 == $config))?S_HOST:NULL, S_NAME,S_TRUE,S_FALSE,S_UNKNOWN,S_GRAPH)); while($row=DBfetch($result)){ if(!check_right_on_trigger_by_triggerid(null, $row['triggerid'], $accessible_hosts)) continue; $availability = calculate_availability($row['triggerid'],0,0); $true = new CSpan(sprintf("%.4f%%",$availability['true']), 'on'); $false = new CSpan(sprintf("%.4f%%",$availability['false']), 'off'); $unknown= new CSpan(sprintf("%.4f%%",$availability['unknown']), 'unknown'); $actions= new CLink(S_SHOW,'report2.php?hostid='.$_REQUEST['hostid'].'&triggerid='.$row['triggerid'],'action'); $table->addRow(array( get_node_name_by_elid($row['hostid']), (($_REQUEST['hostid'] == 0) || (1 == $config))?$row['host']:NULL, new CLink( expand_trigger_description_by_data($row), 'events.php?triggerid='.$row['triggerid'],'action'), $true, $false, $unknown, $actions )); } $table->show(); } ?>