예제 #1
0
function make_latest_data()
{
    global $USER_DETAILS;
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
    while ($db_app = DBfetch($db_applications)) {
        $db_items = DBselect('SELECT DISTINCT i.* ' . ' FROM items i,items_applications ia' . ' WHERE ia.applicationid=' . $db_app['applicationid'] . ' AND i.itemid=ia.itemid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . order_by('i.description,i.itemid,i.lastclock'));
        $app_rows = array();
        $item_cnt = 0;
        while ($db_item = DBfetch($db_items)) {
            $description = item_description($db_item);
            if (!zbx_empty($_REQUEST['select']) && !zbx_stristr($description, $_REQUEST['select'])) {
                continue;
            }
            ++$item_cnt;
            if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($show_all_apps)) {
                continue;
            }
            if (isset($db_item['lastclock'])) {
                $lastclock = date(S_DATE_FORMAT_YMDHMS, $db_item['lastclock']);
            } else {
                $lastclock = new CCol('-', 'center');
            }
            $lastvalue = format_lastvalue($db_item);
            if (isset($db_item['lastvalue']) && isset($db_item['prevvalue']) && $db_item['value_type'] == 0 && $db_item['lastvalue'] - $db_item['prevvalue'] != 0) {
                if ($db_item['lastvalue'] - $db_item['prevvalue'] < 0) {
                    $change = convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']);
                } else {
                    $change = '+' . convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']);
                }
                $change = nbsp($change);
            } else {
                $change = new CCol('-', 'center');
            }
            if ($db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $db_item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
                $actions = new CLink(S_GRAPH, 'history.php?action=showgraph&itemid=' . $db_item['itemid'], 'action');
            } else {
                $actions = new CLink(S_HISTORY, 'history.php?action=showvalues&period=3600&itemid=' . $db_item['itemid'], 'action');
            }
            array_push($app_rows, new CRow(array(is_show_all_nodes() ? SPACE : null, $_REQUEST['hostid'] > 0 ? NULL : SPACE, str_repeat(SPACE, 6) . $description, $lastclock, new CCol($lastvalue, $lastvalue == '-' ? 'center' : null), $change, $actions)));
        }
        if ($item_cnt > 0) {
            if (uint_in_array($db_app['applicationid'], $_REQUEST['applications']) || isset($show_all_apps)) {
                $link = new CLink(new CImg('images/general/opened.gif'), '?close=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
            } else {
                $link = new CLink(new CImg('images/general/closed.gif'), '?open=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
            }
            $col = new CCol(array($link, SPACE, bold($db_app['name']), SPACE . '(' . $item_cnt . SPACE . S_ITEMS . ')'));
            $col->setColSpan(5);
            $table->ShowRow(array(get_node_name_by_elid($db_app['hostid']), $_REQUEST['hostid'] > 0 ? NULL : $db_app['host'], $col));
            $any_app_exist = true;
            foreach ($app_rows as $row) {
                $table->ShowRow($row);
            }
        }
    }
}
예제 #2
0
파일: latest.php 프로젝트: rennhak/zabbix
 }
 $db_host =& $db_hosts[$db_item['hostid']];
 if (!isset($tab_rows[$db_host['hostid']])) {
     $tab_rows[$db_host['hostid']] = array();
 }
 $app_rows =& $tab_rows[$db_host['hostid']];
 $db_host['item_cnt']++;
 if (!uint_in_array(0, $_REQUEST['applications']) && !isset($show_all_apps)) {
     continue;
 }
 if (isset($db_item['lastclock'])) {
     $lastclock = zbx_date2str(S_DATE_FORMAT_YMDHMS, $db_item['lastclock']);
 } else {
     $lastclock = new CCol(' - ');
 }
 $lastvalue = format_lastvalue($db_item);
 if (isset($db_item['lastvalue']) && isset($db_item['prevvalue']) && ($db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $db_item['value_type'] == ITEM_VALUE_TYPE_UINT64) && $db_item['lastvalue'] - $db_item['prevvalue'] != 0) {
     if ($db_item['lastvalue'] - $db_item['prevvalue'] < 0) {
         $change = convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']);
         $change = nbsp($change);
     } else {
         $change = '+' . convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']);
         $change = nbsp($change);
     }
 } else {
     $change = new CCol(' - ');
 }
 if ($db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $db_item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
     $actions = new CLink(S_GRAPH, 'history.php?action=showgraph&itemid=' . $db_item['itemid'], 'action');
 } else {
     $actions = new CLink(S_HISTORY, 'history.php?action=showvalues&period=3600&itemid=' . $db_item['itemid'], 'action');
예제 #3
0
$status['style'] = 'enabled';
if (HTTPTEST_STATE_BUSY == $httptest_data['curstate']) {
    $status['msg'] = S_IN_PROGRESS;
    $status['style'] = 'unknown';
} else {
    if (HTTPTEST_STATE_UNKNOWN == $httptest_data['curstate']) {
        $status['msg'] = S_UNKNOWN;
        $status['style'] = 'unknown';
    } else {
        if ($httptest_data['lastfailedstep'] > 0) {
            $status['msg'] = S_FAIL . ' - ' . S_ERROR . ': ' . $httptest_data['error'];
            $status['style'] = 'disabled';
        }
    }
}
$table->AddRow(array(new CCol(S_TOTAL_BIG, 'bold'), new CCol(SPACE, 'bold'), new CCol(format_lastvalue($total_data[HTTPSTEP_ITEM_TYPE_TIME]), 'bold'), new CCol(SPACE, 'bold'), new CCol(new CSpan($status['msg'], $status['style']), 'bold')));
$table->Show();
echo SBR;
if (isset($_REQUEST['period']) && $_REQUEST['period'] != ZBX_MIN_PERIOD) {
    update_profile('web.httptest.period', $_REQUEST['period'], PROFILE_TYPE_INT, $_REQUEST['httptestid']);
}
$_REQUEST['period'] = get_profile('web.httptest.period', ZBX_PERIOD_DEFAULT, PROFILE_TYPE_INT, $_REQUEST['httptestid']);
show_table_header(array(S_HISTORY . ' "', bold($httptest_data['name']), '"'));
$form = new CTableInfo();
$form->AddOption('id', 'graph');
$form->AddRow(array(bold(S_SPEED), new CCol(get_dynamic_chart('graph_1', 'chart3.php?' . url_param('period') . url_param('from') . url_param($httptest_data['name'], false, 'name') . url_param(150, false, 'height') . url_param(get_request('stime', 0), false, 'stime') . url_param($items[HTTPSTEP_ITEM_TYPE_IN], false, 'items') . url_param(GRAPH_TYPE_STACKED, false, 'graphtype'), '-128'), 'center')));
$form->AddRow(array(bold(S_RESPONSE_TIME), new CCol(get_dynamic_chart('graph_2', 'chart3.php?' . url_param('period') . url_param('from') . url_param($httptest_data['name'], false, 'name') . url_param(150, false, 'height') . url_param(get_request('stime', 0), false, 'stime') . url_param($items[HTTPSTEP_ITEM_TYPE_TIME], false, 'items') . url_param(GRAPH_TYPE_STACKED, false, 'graphtype'), '-128'), 'center')));
$form->Show();
$period = get_request('period', 3600);
//SDI(get_min_itemclock_by_itemid($items[HTTPSTEP_ITEM_TYPE_IN][0]['itemid']));
$mstime = min(get_min_itemclock_by_itemid($items[HTTPSTEP_ITEM_TYPE_IN][0]['itemid']), get_min_itemclock_by_itemid($items[HTTPSTEP_ITEM_TYPE_TIME][0]['itemid']));
예제 #4
0
function get_item_data_overview_cells(&$table_row, &$ithosts, $hostname)
{
    $css_class = NULL;
    unset($it_ov_menu);
    $value = '-';
    $ack = null;
    if (isset($ithosts[$hostname])) {
        if ($ithosts[$hostname]['tr_value'] == TRIGGER_VALUE_TRUE) {
            $css_class = get_severity_style($ithosts[$hostname]['severity']);
            $ack = get_last_event_by_triggerid($ithosts[$hostname]['triggerid']);
            if (1 == $ack['acknowledged']) {
                $ack = array(SPACE, new CImg('images/general/tick.png', 'ack'));
            } else {
                $ack = null;
            }
        }
        $value = format_lastvalue($ithosts[$hostname]);
        $it_ov_menu = array(array(S_VALUES, null, null, array('outer' => array('pum_oheader'), 'inner' => array('pum_iheader'))), array(S_500_LATEST_VALUES, 'history.php?action=showlatest&itemid=' . $ithosts[$hostname]['itemid'], array('tw' => '_blank')));
        switch ($ithosts[$hostname]['value_type']) {
            case ITEM_VALUE_TYPE_UINT64:
            case ITEM_VALUE_TYPE_FLOAT:
                $it_ov_menu = array_merge(array(array(S_GRAPHS, null, null, array('outer' => array('pum_oheader'), 'inner' => array('pum_iheader'))), array(S_LAST_HOUR_GRAPH, 'history.php?period=3600&action=showgraph&itemid=' . $ithosts[$hostname]['itemid'], array('tw' => '_blank')), array(S_LAST_WEEK_GRAPH, 'history.php?period=604800&action=showgraph&itemid=' . $ithosts[$hostname]['itemid'], array('tw' => '_blank')), array(S_LAST_MONTH_GRAPH, 'history.php?period=2678400&action=showgraph&itemid=' . $ithosts[$hostname]['itemid'], array('tw' => '_blank'))), $it_ov_menu);
                break;
            default:
                break;
        }
    }
    //		if($value == '-')	$css_class = 'center';
    $value_col = new CCol(array($value, $ack), $css_class);
    if (isset($it_ov_menu)) {
        $it_ov_menu = new CPUMenu($it_ov_menu, 170);
        $value_col->OnClick($it_ov_menu->GetOnActionJS());
        $value_col->AddOption('style', 'cursor: pointer;');
        $value_col->AddAction('onmouseover', 'this.old_border=this.style.border; this.style.border=\'1px dotted #0C0CF0\'');
        $value_col->AddAction('onmouseout', 'this.style.border=this.old_border;');
        unset($it_ov_menu);
    }
    array_push($table_row, $value_col);
    return $table_row;
}
예제 #5
0
$status['style'] = 'enabled';
if (HTTPTEST_STATE_BUSY == $httptest_data['curstate']) {
    $status['msg'] = S_IN_PROGRESS;
    $status['style'] = 'unknown';
} else {
    if (HTTPTEST_STATE_UNKNOWN == $httptest_data['curstate']) {
        $status['msg'] = S_UNKNOWN;
        $status['style'] = 'unknown';
    } else {
        if ($httptest_data['lastfailedstep'] > 0) {
            $status['msg'] = S_FAIL . ' - ' . S_ERROR . ': ' . $httptest_data['error'];
            $status['style'] = 'disabled';
        }
    }
}
$table->addRow(array(new CSpan(S_TOTAL_BIG, 'bold'), SPACE, new CSpan(format_lastvalue($totalTime), 'bold'), SPACE, new CSpan($status['msg'], $status['style'] . ' bold')));
$details_wdgt->addItem($table);
$details_wdgt->show();
echo SBR;
$graphsWidget = new CWidget();
$scroll_div = new CDiv();
$scroll_div->setAttribute('id', 'scrollbar_cntr');
$graphsWidget->addFlicker($scroll_div, CProfile::get('web.httpdetails.filter.state', 0));
$graphsWidget->addItem(SPACE);
$graphTable = new CTableInfo();
$graphTable->setAttribute('id', 'graph');
$graph_cont = new CCol();
$graph_cont->setAttribute('id', 'graph_1');
$graphTable->addRow(array(bold(S_SPEED), $graph_cont));
$graph_cont = new CCol();
$graph_cont->setAttribute('id', 'graph_2');
예제 #6
0
function expand_trigger_description_by_data($row, $flag = ZBX_FLAG_TRIGGER)
{
    if ($row) {
        $description = expand_trigger_description_constants($row['description'], $row);
        for ($i = 0; $i < 10; $i++) {
            $macro = '{HOSTNAME' . ($i ? $i : '') . '}';
            if (zbx_strstr($description, $macro)) {
                $functionid = trigger_get_N_functionid($row['expression'], $i ? $i : 1);
                if (isset($functionid)) {
                    $sql = 'SELECT DISTINCT h.host' . ' FROM functions f,items i,hosts h' . ' WHERE f.itemid=i.itemid' . ' AND i.hostid=h.hostid' . ' AND f.functionid=' . $functionid;
                    $host = DBfetch(DBselect($sql));
                    if (is_null($host['host'])) {
                        $host['host'] = $macro;
                    }
                    $description = str_replace($macro, $host['host'], $description);
                }
            }
        }
        for ($i = 0; $i < 10; $i++) {
            $macro = '{ITEM.LASTVALUE' . ($i ? $i : '') . '}';
            if (zbx_strstr($description, $macro)) {
                $functionid = trigger_get_N_functionid($row['expression'], $i ? $i : 1);
                if (isset($functionid)) {
                    $sql = 'SELECT i.lastvalue, i.value_type, i.itemid, i.valuemapid, i.units ' . ' FROM items i, functions f ' . ' WHERE i.itemid=f.itemid ' . ' AND f.functionid=' . $functionid;
                    $row2 = DBfetch(DBselect($sql));
                    $description = str_replace($macro, format_lastvalue($row2), $description);
                }
            }
        }
        for ($i = 0; $i < 10; $i++) {
            $macro = '{ITEM.VALUE' . ($i ? $i : '') . '}';
            if (zbx_strstr($description, $macro)) {
                $value = $flag == ZBX_FLAG_TRIGGER ? trigger_get_func_value($row['expression'], ZBX_FLAG_TRIGGER, $i ? $i : 1, 1) : trigger_get_func_value($row['expression'], ZBX_FLAG_EVENT, $i ? $i : 1, $row['clock']);
                $description = str_replace($macro, $value, $description);
            }
        }
        if ($res = preg_match_all('/' . ZBX_PREG_EXPRESSION_USER_MACROS . '/', $description, $arr)) {
            $macros = CUserMacro::getMacros($arr[1], array('triggerid' => $row['triggerid']));
            $search = array_keys($macros);
            $values = array_values($macros);
            $description = str_replace($search, $values, $description);
        }
    } else {
        $description = '*ERROR*';
    }
    return $description;
}