Exemplo n.º 1
0
function make_trigger_details($triggerid, &$trigger_data)
{
    $table = new CTableInfo();
    if (is_show_subnodes()) {
        $table->AddRow(array(S_NODE, get_node_name_by_elid($triggerid)));
    }
    $table->AddRow(array(S_HOST, $trigger_data['host']));
    $table->AddRow(array(S_TRIGGER, $trigger_data['exp_desc']));
    $table->AddRow(array(S_SEVERITY, new CCol(get_severity_description($trigger_data["priority"]), get_severity_style($trigger_data["priority"]))));
    $table->AddRow(array(S_EXPRESSION, $trigger_data['exp_expr']));
    $table->AddRow(array(S_EVENT_GENERATION, S_NORMAL . (TRIGGER_MULT_EVENT_ENABLED == $trigger_data['type'] ? SPACE . '+' . SPACE . S_MULTIPLE_TRUE_EVENTS : '')));
    $table->AddRow(array(S_DISABLED, TRIGGER_STATUS_ENABLED == $trigger_data['status'] ? new CCol(S_NO, 'off') : new CCol(S_YES, 'on')));
    return $table;
}
Exemplo n.º 2
0
                                $sec_600[$row['proxy_hostid']]++;
                            } else {
                                $sec_rest[$row['proxy_hostid']]++;
                            }
                        }
                    }
                }
            }
        }
        $table->setHeader(array(S_PROXY, S_5_SECONDS, S_10_SECONDS, S_30_SECONDS, S_1_MINUTE, S_5_MINUTES, S_MORE_THAN_10_MINUTES));
        $db_proxies = DBselect('select hostid,host from hosts where status=' . HOST_STATUS_PROXY . ' order by host');
        while (null != ($db_proxy = DBfetch($db_proxies))) {
            $elements = array($db_proxy['host'], new CCol($sec_10[$db_proxy['hostid']], $sec_10[$db_proxy['hostid']] ? "unknown_trigger" : "normal"), new CCol($sec_30[$db_proxy['hostid']], $sec_30[$db_proxy['hostid']] ? "information" : "normal"), new CCol($sec_60[$db_proxy['hostid']], $sec_60[$db_proxy['hostid']] ? "warning" : "normal"), new CCol($sec_300[$db_proxy['hostid']], $sec_300[$db_proxy['hostid']] ? "average" : "normal"), new CCol($sec_600[$db_proxy['hostid']], $sec_600[$db_proxy['hostid']] ? "high" : "normal"), new CCol($sec_rest[$db_proxy['hostid']], $sec_rest[$db_proxy['hostid']] ? "disaster" : "normal"));
            $table->addRow($elements);
        }
        $elements = array(new CCol(S_SERVER, 'bold'), new CCol($sec_10[0], $sec_10[0] ? 'unknown_trigger' : 'normal'), new CCol($sec_30[0], $sec_30[0] ? 'information' : 'normal'), new CCol($sec_60[0], $sec_60[0] ? 'warning' : 'normal'), new CCol($sec_300[0], $sec_300[0] ? 'average' : 'normal'), new CCol($sec_600[0], $sec_600[0] ? 'high' : 'normal'), new CCol($sec_rest[0], $sec_rest[0] ? 'disaster' : 'normal'));
        $table->addRow($elements);
    } else {
        if ($_REQUEST["show"] == 2) {
            $table->SetHeader(array(S_NEXT_CHECK, is_show_subnodes() ? S_NODE : null, S_HOST, S_DESCRIPTION));
            while ($row = DBfetch($result)) {
                $table->AddRow(array(date("m.d.Y H:i:s", $row["nextcheck"]), get_node_name_by_elid($row['hostid']), $row['host'], item_description($row)));
            }
        }
    }
}
$table->Show();
if ($_REQUEST["show"] != 0) {
    show_table_header(S_TOTAL . ": " . $table->GetNumRows());
}
include_once "include/page_footer.php";
Exemplo n.º 3
0
function get_actions_hint_by_eventid($eventid, $status = NULL)
{
    $hostids = array();
    $sql = 'SELECT DISTINCT i.hostid ' . ' FROM events e, functions f, items i ' . ' WHERE e.eventid=' . $eventid . ' AND e.objectid=' . EVENT_SOURCE_TRIGGERS . ' AND f.triggerid=' . $_REQUEST['triggerid'] . ' AND i.itemid=f.itemid';
    if ($host = DBfetch(DBselect($sql, 1))) {
        $hostids[$host['hostid']] = $host['hostid'];
    }
    $available_triggers = get_accessible_triggers(PERM_READ_ONLY, $hostids);
    $tab_hint = new CTableInfo(S_NO_ACTIONS_FOUND);
    $tab_hint->addOption('style', 'width: 300px;');
    $tab_hint->SetHeader(array(is_show_subnodes() ? S_NODES : null, S_USER, S_DETAILS, S_STATUS));
    /*			
    	$sql = 'SELECT DISTINCT a.alertid,mt.description,a.sendto,a.status,u.alias,a.retries '.
    			' FROM events e,users u,alerts a'.
    			' left join media_type mt on mt.mediatypeid=a.mediatypeid'.
    			' WHERE a.eventid='.$eventid.
    				(is_null($status)?'':' AND a.status='.$status).
    				' AND e.eventid = a.eventid'.
    				' AND a.alerttype IN ('.ALERT_TYPE_MESSAGE.','.ALERT_TYPE_COMMAND.')'.
    				' AND '.DBcondition('e.objectid',$available_triggers).
    				' AND '.DBin_node('a.alertid').
    				' AND u.userid=a.userid '.
    			' ORDER BY mt.description';
    //*/
    $sql = 'SELECT DISTINCT a.alertid,mt.description,u.alias,a.subject,a.message,a.sendto,a.status,a.retries,a.alerttype ' . ' FROM events e,alerts a ' . ' LEFT JOIN users u ON u.userid=a.userid ' . ' LEFT JOIN media_type mt ON mt.mediatypeid=a.mediatypeid' . ' WHERE a.eventid=' . $eventid . (is_null($status) ? '' : ' AND a.status=' . $status) . ' AND e.eventid = a.eventid' . ' AND a.alerttype IN (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . ' AND ' . DBcondition('e.objectid', $available_triggers) . ' AND ' . DBin_node('a.alertid') . ' ORDER BY a.alertid';
    $result = DBselect($sql, 30);
    while ($row = DBfetch($result)) {
        if ($row["status"] == ALERT_STATUS_SENT) {
            $status = new CSpan(S_SENT, "green");
            $retries = new CSpan(SPACE, "green");
        } else {
            if ($row["status"] == ALERT_STATUS_NOT_SENT) {
                $status = new CSpan(S_IN_PROGRESS, "orange");
                $retries = new CSpan(ALERT_MAX_RETRIES - $row["retries"], "orange");
            } else {
                $status = new CSpan(S_NOT_SENT, "red");
                $retries = new CSpan(0, "red");
            }
        }
        switch ($row['alerttype']) {
            case ALERT_TYPE_MESSAGE:
                $message = empty($row['description']) ? '-' : $row['description'];
                break;
            case ALERT_TYPE_COMMAND:
                $message = array(bold(S_COMMAND . ':'));
                $msg = explode("\n", $row['message']);
                foreach ($msg as $m) {
                    array_push($message, BR(), $m);
                }
                break;
            default:
                $message = '-';
        }
        $tab_hint->addRow(array(get_node_name_by_elid($row['alertid']), empty($row['alias']) ? ' - ' : $row['alias'], $message, $status));
    }
    return $tab_hint;
}
Exemplo n.º 4
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');
    }
    array_push($app_rows, new CRow(array(is_show_subnodes() ? $db_host['item_cnt'] ? SPACE : get_node_name_by_elid($db_item['itemid']) : null, $_REQUEST['hostid'] ? NULL : ($db_host['item_cnt'] ? SPACE : $db_item['host']), str_repeat(SPACE, 6) . $description, $lastclock, new CCol($lastvalue), $change, $actions)));
}
unset($app_rows);
unset($db_host);
foreach ($db_hosts as $hostid => $db_host) {
    if (!isset($tab_rows[$hostid])) {
        continue;
    }
    $app_rows = $tab_rows[$hostid];
    if (uint_in_array(0, $_REQUEST['applications']) || isset($show_all_apps)) {
        $url = '?close=1&applicationid=0' . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select');
        $link = new CLink(new CImg('images/general/opened.gif'), $url);
        //			$link = new CLink(new CImg('images/general/opened.gif'),$url,null,"javascript: return updater.onetime_update('".ZBX_PAGE_MAIN_HAT."','".$url."');");
    } else {
        $url = '?open=1&applicationid=0' . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select');
        $link = new CLink(new CImg('images/general/closed.gif'), $url);
Exemplo n.º 5
0
function get_node_name_by_elid($id_val, $forse_with_subnodes = null)
{
    global $ZBX_NODES;
    if (!is_show_subnodes($forse_with_subnodes)) {
        return null;
    }
    $nodeid = id2nodeid($id_val);
    if (!isset($ZBX_NODES[$nodeid])) {
        return null;
    }
    return '[' . $ZBX_NODES[$nodeid]['name'] . '] ';
}
Exemplo n.º 6
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 ('' != $_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_subnodes() ? 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);
            }
        }
    }
}
Exemplo n.º 7
0
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = array('period' => array(T_ZBX_STR, O_OPT, P_SYS | P_NZERO, IN('"day","week","month","year"'), NULL));
check_fields($fields);
$_REQUEST['period'] = get_request('period', 'day');
$admin_links = $USER_DETAILS['type'] == USER_TYPE_ZABBIX_ADMIN || $USER_DETAILS['type'] == USER_TYPE_SUPER_ADMIN;
$form = new CForm();
$form->SetMethod('get');
$cmbPeriod = new CComboBox('period', $_REQUEST['period'], 'submit()');
$cmbPeriod->AddItem('day', S_DAY);
$cmbPeriod->AddItem('week', S_WEEK);
$cmbPeriod->AddItem('month', S_MONTH);
$cmbPeriod->AddItem('year', S_YEAR);
$form->AddItem($cmbPeriod);
show_table_header(S_TRIGGERS_TOP_100_BIG, $form);
$table = new CTableInfo();
$table->setHeader(array(is_show_subnodes() ? S_NODE : null, S_HOST, S_TRIGGER, S_SEVERITY, S_NUMBER_OF_STATUS_CHANGES));
switch ($_REQUEST['period']) {
    case 'week':
        $time_dif = 7 * 24 * 3600;
        break;
    case 'month':
        $time_dif = 10 * 24 * 3600;
        break;
    case 'year':
        $time_dif = 365 * 24 * 3600;
        break;
    case 'day':
    default:
        $time_dif = 24 * 3600;
        break;
}
Exemplo n.º 8
0
            if ($next_event = get_next_event($row, $show_unknown)) {
                $duration = zbx_date2age($row['clock'], $next_event['clock']);
            }
            // Actions
            $actions = get_event_actions_status($row['eventid']);
            //--------
            if ($config['event_ack_enable']) {
                if ($row['acknowledged'] == 1) {
                    $ack = new CLink(S_YES, 'acknow.php?eventid=' . $row['eventid'], 'action');
                } else {
                    $ack = new CLink(S_NO, 'acknow.php?eventid=' . $row['eventid'], 'on');
                }
            }
            $tr_desc = new CSpan(expand_trigger_description_by_data($row, ZBX_FLAG_EVENT), 'pointer');
            $tr_desc->addAction('onclick', "create_mon_trigger_menu(event, " . " new Array({'triggerid': '" . $row['triggerid'] . "', 'lastchange': '" . $row['clock'] . "'})," . zbx_jsvalue($row['items']) . ");");
            $table->AddRow(array(new CLink(date('Y.M.d H:i:s', $row['clock']), 'tr_events.php?triggerid=' . $row['triggerid'] . '&eventid=' . $row['eventid'], 'action'), is_show_subnodes() ? get_node_name_by_elid($row['triggerid']) : null, $_REQUEST['hostid'] == 0 ? $row['host'] : null, $tr_desc, $value, new CCol(get_severity_description($row['priority']), get_severity_style($row['priority'], $row['value'])), $duration, $config['event_ack_enable'] ? $ack : NULL, $actions));
            $col++;
        }
    }
}
/************************* FILTER **************************/
/***********************************************************/
// Navigation
$nav_time = get_request('nav_time', time());
$navForm = new CForm('events.php');
if (isset($_REQUEST['groupid'])) {
    $navForm->AddVar('groupid', $_REQUEST['groupid']);
}
if (isset($_REQUEST['hostid'])) {
    $navForm->AddVar('hostid', $_REQUEST['hostid']);
}
Exemplo n.º 9
0
    }
} else {
    $table = new CTableInfo();
    if ($prof_type) {
        $table->setHeader(array(is_show_subnodes() ? make_sorting_link(S_NODE, 'h.hostid') : null, make_sorting_link(S_HOST, 'h.host'), $_REQUEST['groupid'] > 0 ? null : make_sorting_link(S_GROUP, 'g.name'), make_sorting_link(S_DEVICE_OS_SHORT, 'hpe.device_os_short'), make_sorting_link(S_DEVICE_HW_ARCH, 'hpe.device_hw_arch'), make_sorting_link(S_DEVICE_TYPE, 'hpe.device_type'), make_sorting_link(S_DEVICE_STATUS, 'hpe.device_status')));
        $sql_where = '';
        if ($_REQUEST['groupid'] > 0) {
            $sql_where = ' AND hg.groupid=' . $_REQUEST['groupid'];
        }
        $sql = 'SELECT DISTINCT g.name, h.hostid,h.host,hpe.device_os_short,hpe.device_hw_arch,hpe.device_type,hpe.device_status' . ' FROM hosts h,hosts_profiles_ext hpe,hosts_groups hg,groups g ' . ' WHERE h.hostid=hpe.hostid ' . ' AND h.hostid=hg.hostid ' . ' AND g.groupid=hg.groupid ' . ' AND ' . DBcondition('h.hostid', $PAGE_HOSTS['hostids']) . $sql_where . order_by('h.host,h.hostid,g.name,hpe.device_os_short,hpe.device_hw_arch,hpe.device_type,hpe.device_status');
        $result = DBselect($sql);
        while ($row = DBfetch($result)) {
            $table->AddRow(array(get_node_name_by_elid($row['hostid']), new CLink($row["host"], "?hostid=" . $row["hostid"] . url_param("groupid") . '&prof_type=' . $prof_type, "action"), $_REQUEST["groupid"] > 0 ? null : $row["name"], $row["device_os_short"], $row["device_hw_arch"], $row["device_type"], $row["device_status"]));
        }
    } else {
        $table->setHeader(array(is_show_subnodes() ? make_sorting_link(S_NODE, 'h.hostid') : null, make_sorting_link(S_HOST, 'h.host'), make_sorting_link(S_NAME, 'p.name'), make_sorting_link(S_OS, 'p.os'), make_sorting_link(S_SERIALNO, 'p.serialno'), make_sorting_link(S_TAG, 'p.tag'), make_sorting_link(S_MACADDRESS, 'p.macaddress')));
        $sql_from = '';
        $sql_where = '';
        if ($_REQUEST['groupid'] > 0) {
            $sql_from = ', hosts_groups hg ';
            $sql_where = ' and h.hostid=hg.hostid AND hg.groupid=' . $_REQUEST['groupid'];
        }
        $sql = 'SELECT h.hostid,h.host,p.name,p.os,p.serialno,p.tag,p.macaddress' . ' FROM hosts h,hosts_profiles p ' . $sql_from . ' WHERE h.hostid=p.hostid' . ' and ' . DBcondition('h.hostid', $PAGE_HOSTS['hostids']) . $sql_where . order_by('h.host,h.hostid,p.name,p.os,p.serialno,p.tag,p.macaddress');
        $result = DBselect($sql);
        while ($row = DBfetch($result)) {
            $table->AddRow(array(get_node_name_by_elid($row['hostid']), new CLink($row["host"], '?hostid=' . $row['hostid'] . url_param('groupid') . '&prof_type=' . $prof_type, "action"), $row["name"], $row["os"], $row["serialno"], $row["tag"], $row["macaddress"]));
        }
    }
    $table->show();
}
include_once "include/page_footer.php";
Exemplo n.º 10
0
 foreach ($db_httptests as $httptestid => $httptest_data) {
     $db_app =& $db_apps[$httptest_data['applicationid']];
     if (!isset($tab_rows[$db_app['applicationid']])) {
         $tab_rows[$db_app['applicationid']] = array();
     }
     $app_rows =& $tab_rows[$db_app['applicationid']];
     if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($show_all_apps)) {
         continue;
     }
     $name = array();
     array_push($name, new CLink($httptest_data['name'], '?form=update' . '&httptestid=' . $httptest_data['httptestid'] . '&hostid=' . $db_app['hostid'] . url_param('groupid'), NULL));
     $status = new CCol(new CLink(httptest_status2str($httptest_data['status']), '?group_httptestid[]=' . $httptest_data['httptestid'] . '&hostid=' . $db_app['hostid'] . '&group_task=' . ($httptest_data['status'] ? 'Activate+selected' : 'Disable+selected'), httptest_status2style($httptest_data['status'])));
     $chkBox = new CCheckBox('group_httptestid[' . $httptest_data['httptestid'] . ']', null, null, $httptest_data['httptestid']);
     $step_cout = DBfetch(DBselect('select count(*) as cnt from httpstep where httptestid=' . $httptest_data['httptestid']));
     $step_cout = $step_cout['cnt'];
     array_push($app_rows, new CRow(array(is_show_subnodes() ? SPACE : NULL, $_REQUEST['hostid'] > 0 ? NULL : SPACE, array(str_repeat(SPACE, 4), $chkBox, $name), $step_cout, $httptest_data['delay'], $status)));
 }
 unset($app_rows);
 unset($db_app);
 foreach ($tab_rows as $appid => $app_rows) {
     $db_app =& $db_apps[$appid];
     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 . '(' . $db_app['scenarios_cnt'] . SPACE . S_SCENARIOS . ')'));
     $col->SetColSpan(6);
     $table->addRow(array(get_node_name_by_elid($db_app['applicationid']), $_REQUEST['hostid'] > 0 ? NULL : $db_app['host'], $col));
     $any_app_exist = true;
     foreach ($app_rows as $row) {
Exemplo n.º 11
0
            }
            if ($_REQUEST['hostid'] > 0) {
                $sql_where .= ' AND h.hostid=' . $_REQUEST['hostid'];
            }
        } else {
            if ($_REQUEST['hostid'] > 0) {
                $sql_from .= ',hosts_templates ht ';
                $sql_where .= ' AND ht.hostid=h.hostid AND ht.templateid=' . $_REQUEST['hostid'];
            }
            if (isset($_REQUEST['tpl_triggerid']) && $_REQUEST['tpl_triggerid'] > 0) {
                $sql_where .= ' AND t.templateid=' . $_REQUEST['tpl_triggerid'];
            }
        }
        $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 ' . $sql_from . ' WHERE h.status=' . HOST_STATUS_MONITORED . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND i.hostid=h.hostid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND f.itemid=i.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . $sql_where . ' ORDER BY h.host, t.description');
        $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'])) {
                continue;
            }
            $availability = calculate_availability($row['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?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();
    }
}
include_once 'include/page_footer.php';
Exemplo n.º 12
0
// Header
$text = array(SPACE);
$url = '?fullscreen=' . ($_REQUEST['fullscreen'] ? '0' : '1') . '&amp;druleid=' . $druleid;
$fs_icon = new CDiv(SPACE, 'fullscreen');
$fs_icon->AddOption('title', $_REQUEST['fullscreen'] ? S_NORMAL . ' ' . S_VIEW : S_FULLSCREEN);
$fs_icon->AddAction('onclick', new CScript("javascript: document.location = '" . $url . "';"));
$p_elements[] = get_table_header($text, $r_form);
//-------------
$services = array();
$db_dservices = DBselect('SELECT s.type,s.port,s.key_ FROM dservices s,dhosts h' . ' WHERE ' . DBin_node('s.dserviceid') . ' AND s.dhostid=h.dhostid' . ($druleid > 0 ? ' AND h.druleid=' . $druleid : ''));
while ($dservice = DBfetch($db_dservices)) {
    $service_name = discovery_check_type2str($dservice['type']) . discovery_port2str($dservice['type'], $dservice['port']) . (empty($dservice['key_']) ? '' : ':' . $dservice['key_']);
    $services[$service_name] = 1;
}
ksort($services);
$header = array(is_show_subnodes() ? new CCol(S_NODE, 'center') : null, new CCol(make_sorting_link(S_HOST, 'ip'), 'center'), new CCol(array(S_UPTIME . '/', S_DOWNTIME), 'center'));
foreach ($services as $name => $foo) {
    $header[] = new CImg('vtext.php?text=' . $name);
}
$table = new CTableInfo();
$table->SetHeader($header, 'vertical_header');
$db_drules = DBselect('select distinct druleid,name from drules where ' . DBin_node('druleid') . ($druleid > 0 ? ' and druleid=' . $druleid : '') . ' order by name');
while ($drule = DBfetch($db_drules)) {
    $discovery_info = array();
    $db_dhosts = DBselect('SELECT dhostid,druleid,ip,status,lastup,lastdown ' . ' FROM dhosts WHERE ' . DBin_node('dhostid') . ' AND druleid=' . $drule['druleid'] . order_by('ip', 'dhostid,status'));
    while ($dhost = DBfetch($db_dhosts)) {
        $class = 'enabled';
        $time = 'lastup';
        if (DHOST_STATUS_DISABLED == $dhost['status']) {
            $class = 'disabled';
            $time = 'lastdown';
Exemplo n.º 13
0
function get_history_of_triggers_events($start, $num, $groupid = 0, $hostid = 0)
{
    global $USER_DETAILS;
    $config = select_config();
    $show_unknown = get_profile('web.events.filter.show_unknown', 0);
    $sql_from = $sql_cond = '';
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_LIST);
    $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_DATA_ARRAY, get_current_nodeid());
    if ($hostid > 0) {
        $sql_cond = ' AND h.hostid=' . $hostid;
    } else {
        if ($groupid > 0) {
            $sql_from = ', hosts_groups hg ';
            $sql_cond = ' AND h.hostid=hg.hostid AND hg.groupid=' . $groupid;
        } else {
            $sql_from = ', hosts_groups hg ';
            $sql_cond = ' AND ' . DBcondition('h.hostid', $available_hosts);
        }
    }
    //---
    $triggers = array();
    $trigger_list = array();
    $sql = 'SELECT DISTINCT t.triggerid,t.priority,t.description,t.expression,h.host,t.type ' . ' FROM triggers t, functions f, items i, hosts h ' . $sql_from . ' WHERE ' . DBcondition('t.triggerid', $available_triggers) . ' AND t.triggerid=f.triggerid ' . ' AND f.itemid=i.itemid ' . ' AND i.hostid=h.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . $sql_cond;
    $rez = DBselect($sql);
    while ($rowz = DBfetch($rez)) {
        $triggers[$rowz['triggerid']] = $rowz;
        array_push($trigger_list, $rowz['triggerid']);
    }
    $sql_cond = $show_unknown == 0 ? ' AND e.value<>' . TRIGGER_VALUE_UNKNOWN . ' ' : '';
    $table = new CTableInfo(S_NO_EVENTS_FOUND);
    $table->SetHeader(array(S_TIME, is_show_subnodes() ? S_NODE : null, $hostid == 0 ? S_HOST : null, S_DESCRIPTION, S_VALUE, S_SEVERITY));
    if (!empty($triggers)) {
        $sql = 'SELECT e.eventid, e.objectid as triggerid, e.clock, e.value, e.acknowledged ' . ' FROM events e ' . ' WHERE e.object=' . EVENT_OBJECT_TRIGGER . ' AND ' . DBcondition('e.objectid', $trigger_list) . $sql_cond . ' ORDER BY e.eventid DESC';
        $result = DBselect($sql, 10 * ($start + $num));
    }
    $col = 0;
    $skip = $start;
    while (!empty($triggers) && $col < $num && ($row = DBfetch($result))) {
        if ($skip > 0) {
            if ($show_unknown == 0 && $row['value'] == TRIGGER_VALUE_UNKNOWN) {
                continue;
            }
            $skip--;
            continue;
        }
        $value = new CCol(trigger_value2str($row['value']), get_trigger_value_style($row['value']));
        $row = array_merge($triggers[$row['triggerid']], $row);
        if (0 == $show_unknown && !event_initial_time($row, $show_unknown)) {
            continue;
        }
        $table->AddRow(array(date("Y.M.d H:i:s", $row["clock"]), get_node_name_by_elid($row['triggerid']), $hostid == 0 ? $row['host'] : null, new CLink(expand_trigger_description_by_data($row, ZBX_FLAG_EVENT), 'tr_events.php?triggerid=' . $row['triggerid'] . '&eventid=' . $row['eventid'], 'action'), $value, new CCol(get_severity_description($row["priority"]), get_severity_style($row["priority"]))));
        $col++;
    }
    return $table;
}
Exemplo n.º 14
0
            $state = S_IDLE_TILL . ' ' . date(S_DATE_FORMAT_YMDHMS, $httptest_data['nextcheck']);
            if ($httptest_data['lastfailedstep'] > 0) {
                $step_data = get_httpstep_by_no($httptest_data['httptestid'], $httptest_data['lastfailedstep']);
                $status['msg'] = S_FAILED_ON . ' "' . $step_data['name'] . '" ' . '[' . $httptest_data['lastfailedstep'] . ' ' . S_OF_SMALL . ' ' . $httptest_data['step_cout'] . '] ' . SPACE . S_ERROR . ': ' . $httptest_data['error'];
                $status['style'] = 'disabled';
            } else {
                $status['msg'] = S_OK_BIG;
                $status['style'] = 'enabled';
            }
        } else {
            $state = S_IDLE_TILL . ' ' . date(S_DATE_FORMAT_YMDHMS, $httptest_data['nextcheck']);
            $status['msg'] = S_UNKNOWN;
            $status['style'] = 'unknown';
        }
    }
    array_push($app_rows, new CRow(array(is_show_subnodes() ? SPACE : NULL, $_REQUEST['hostid'] > 0 ? NULL : SPACE, array(str_repeat(SPACE, 6), $name), $httptest_data['step_cout'], $state, $lastcheck, new CSpan($status['msg'], $status['style']))));
}
unset($app_rows);
unset($db_app);
foreach ($tab_rows as $appid => $app_rows) {
    $db_app =& $db_apps[$appid];
    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 . '(' . $db_app['scenarios_cnt'] . SPACE . S_SCENARIOS . ')'));
    $col->SetColSpan(6);
    $table->addRow(array(get_node_name_by_elid($db_app['applicationid']), $_REQUEST['hostid'] > 0 ? NULL : $db_app['host'], $col));
    $any_app_exist = true;
    foreach ($app_rows as $row) {
Exemplo n.º 15
0
    $triggerInfo->HideHeader();
    $triggerInfo->Show();
}
if ($_REQUEST['fullscreen']) {
    $fullscreen = '&fullscreen=1';
} else {
    $fullscreen = '';
}
$m_form = new CForm('acknow.php');
$m_form->SetName('tr_status');
$admin_links = $USER_DETAILS['type'] == USER_TYPE_ZABBIX_ADMIN || $USER_DETAILS['type'] == USER_TYPE_SUPER_ADMIN;
$table = new CTableInfo();
$table->ShowStart();
$header = array();
$show_event_col = $config['event_ack_enable'] && $show_events != EVENTS_OPTION_NOEVENT;
$table->SetHeader(array($show_event_col ? new CCheckBox('all_events', false, "CheckAll('" . $m_form->GetName() . "','all_events','events');") : NULL, make_sorting_link(S_SEVERITY, 't.priority'), S_STATUS, make_sorting_link(S_LAST_CHANGE, 't.lastchange'), is_show_subnodes() ? make_sorting_link(S_NODE, 'h.hostid') : null, $_REQUEST['hostid'] > 0 ? null : make_sorting_link(S_HOST, 'h.host'), make_sorting_link(S_NAME, 't.description'), $_REQUEST['show_actions'] ? S_ACTIONS : NULL, $show_event_col ? S_ACKNOWLEDGED : NULL, S_COMMENTS));
$cond = $_REQUEST['hostid'] > 0 ? ' AND h.hostid=' . $_REQUEST['hostid'] . ' ' : '';
switch ($show_triggers) {
    case TRIGGERS_OPTION_ALL:
        $cond .= '';
        break;
    case TRIGGERS_OPTION_NOFALSEFORB:
        $cond .= '';
        break;
    case TRIGGERS_OPTION_ONLYTRUE:
    default:
        $cond .= ' AND ((t.value=' . TRIGGER_VALUE_TRUE . ') OR ((t.value=' . TRIGGER_VALUE_FALSE . ') AND ((' . time() . '-t.lastchange)<' . TRIGGER_FALSE_PERIOD . ')))';
        break;
}
if ($show_severity > -1) {
    $cond .= ' AND t.priority>=' . $show_severity;