$count_now = array(); $true = array(); $false = array(); $unknown = array(); $year = date('Y'); $start = mktime(0, 0, 0, 1, 1, $year); $wday = date('w', $start); if ($wday == 0) { $wday = 7; } $start = $start - ($wday - 1) * 24 * 3600; $weeks = (int) (date('z') / 7 + 1); for ($i = 0; $i < $weeks; $i++) { $period_start = $start + 7 * 24 * 3600 * $i; $period_end = $start + 7 * 24 * 3600 * ($i + 1); $stat = calculate_availability($_REQUEST['triggerid'], $period_start, $period_end); $true[$i] = $stat['true']; $false[$i] = $stat['false']; $unknown[$i] = $stat['unknown']; $count_now[$i] = 1; //SDI($false[$i]); } for ($i = 0; $i <= $sizeY; $i += $sizeY / 10) { DashedLine($im, $shiftX, $i + $shiftYup, $sizeX + $shiftX, $i + $shiftYup, $gray); } $j = 0; for ($i = 0; $i <= $sizeX; $i += $sizeX / 52) { DashedLine($im, $i + $shiftX, $shiftYup, $i + $shiftX, $sizeY + $shiftYup, $gray); $period_start = $start + 7 * 24 * 3600 * $j; imagestringup($im, 1, $i + $shiftX - 4, $sizeY + $shiftYup + 32, date('d.M', $period_start), $black); $j++;
$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'); } if (isset($_REQUEST['tpl_triggerid']) && $_REQUEST['tpl_triggerid'] > 0) { $options['filter']['templateid'] = $_REQUEST['tpl_triggerid']; } } $triggers = CTrigger::get($options); morder_result($triggers, array('host', 'description')); $table = new CTableInfo(); $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, $_REQUEST['hostid'] == 0 || 1 == $config ? S_HOST : NULL, S_NAME, S_PROBLEMS, S_OK, S_UNKNOWN, S_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(S_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 || 1 == $config ? $trigger['host'] : NULL, new CLink($trigger['description'], 'events.php?triggerid=' . $trigger['triggerid']), $true, $false, $unknown, $actions)); } $rep2_wdgt->addItem($table); $rep2_wdgt->show(); } } include_once 'include/page_footer.php';