Example #1
0
    $rep2_wdgt->addHeader(array(new CLink($trigger_data['host'], '?filter_groupid=' . $_REQUEST['groupid'] . '&filter_hostid=' . $trigger_data['hostid']), ' : ', expand_trigger_description_by_data($trigger_data)), SPACE);
    $table = new CTableInfo(null, 'graph');
    $table->addRow(new CImg('chart4.php?triggerid=' . $_REQUEST['triggerid']));
    $rep2_wdgt->addItem($table);
    $rep2_wdgt->show();
} else {
    if (isset($_REQUEST['hostid'])) {
        $r_form = new CForm();
        $r_form->setMethod('get');
        $cmbConf = new CComboBox('config', $config, 'submit()');
        $cmbConf->addItem(0, S_BY_HOST);
        $cmbConf->addItem(1, S_BY_TRIGGER_TEMPLATE);
        $r_form->addItem($cmbConf);
        $rep2_wdgt->addHeader(S_REPORT_BIG, array(S_MODE . SPACE, $r_form));
        // FILTER
        $filterForm = get_report2_filter($config, $PAGE_GROUPS, $PAGE_HOSTS);
        $rep2_wdgt->addFlicker($filterForm, CProfile::get('web.avail_report.filter.state', 0));
        //-------
        $options = array('output' => array('triggerid', 'description', 'expression', 'value'), 'expandDescription' => true, 'expandData' => true, 'monitored' => true, 'filter' => array());
        if (0 == $config) {
            if ($_REQUEST['groupid'] > 0) {
                $options['groupids'] = $_REQUEST['groupid'];
            }
            if ($_REQUEST['hostid'] > 0) {
                $options['hostids'] = $_REQUEST['hostid'];
            }
        } else {
            if ($_REQUEST['hostid'] > 0) {
                $hosts = CHost::get(array('templateids' => $_REQUEST['hostid']));
                $options['hostids'] = zbx_objectValues($hosts, 'hostid');
            }
     }
 } elseif ($availabilityReportMode == AVAILABILITY_REPORT_BY_TEMPLATE) {
     // if a template is selected, fetch all of the hosts, that are linked to those templates
     if ($_REQUEST['hostid'] > 0 || !$config['dropdown_first_entry']) {
         $hosts = API::Host()->get(array('templateids' => $_REQUEST['hostid']));
         $options['hostids'] = zbx_objectValues($hosts, 'hostid');
     }
     if (isset($_REQUEST['tpl_triggerid']) && $_REQUEST['tpl_triggerid'] > 0) {
         $options['filter']['templateid'] = $_REQUEST['tpl_triggerid'];
     }
     if (isset($_REQUEST['hostgroupid']) && $_REQUEST['hostgroupid'] > 0) {
         $options['groupids'] = $_REQUEST['hostgroupid'];
     }
 }
 // filter
 $filter = get_report2_filter($availabilityReportMode, $PAGE_GROUPS, $PAGE_HOSTS, $options);
 $rep2_wdgt->addFlicker($filter['form'], CProfile::get('web.avail_report.filter.state', 0));
 $triggers = API::Trigger()->get($filter['options']);
 CArrayHelper::sort($triggers, array('host', 'description'));
 $table = new CTableInfo(_('No triggers defined.'));
 $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, $_REQUEST['hostid'] == 0 || $availabilityReportMode == AVAILABILITY_REPORT_BY_TEMPLATE ? _('Host') : null, _('Name'), _('Problems'), _('Ok'), _('Unknown'), _('Graph')));
 foreach ($triggers as $trigger) {
     $availability = calculate_availability($trigger['triggerid'], $_REQUEST['filter_timesince'], $_REQUEST['filter_timetill']);
     $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(_('Show'), 'report2.php?filter_groupid=' . $_REQUEST['groupid'] . '&filter_hostid=' . $_REQUEST['hostid'] . '&triggerid=' . $trigger['triggerid']);
     $table->addRow(array(get_node_name_by_elid($trigger['hostid']), $_REQUEST['hostid'] == 0 || $availabilityReportMode == AVAILABILITY_REPORT_BY_TEMPLATE ? $trigger['hosts'][0]['name'] : null, new CLink($trigger['description'], 'events.php?triggerid=' . $trigger['triggerid']), $true, $false, $unknown, $actions));
 }
 $rep2_wdgt->addItem(BR());
 $rep2_wdgt->addItem($table);