Пример #1
0
include_once "include/page_header.php";
define('PAGE_SIZE', 100);
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = array('triggerid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, PAGE_TYPE_HTML . '==' . $page['type']), 'eventid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, PAGE_TYPE_HTML . '==' . $page['type']), 'fullscreen' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), NULL), "save" => array(T_ZBX_STR, O_OPT, P_ACT | P_SYS, null, null), "cancel" => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'favobj' => array(T_ZBX_STR, O_OPT, P_ACT, IN("'filter','hat'"), NULL), 'favid' => array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'), 'state' => array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'));
check_fields($fields);
/* AJAX */
if (isset($_REQUEST['favobj'])) {
    if ('hat' == $_REQUEST['favobj']) {
        update_profile('web.tr_events.hats.' . $_REQUEST['favid'] . '.state', $_REQUEST['state'], PROFILE_TYPE_INT);
    }
}
if (PAGE_TYPE_JS == $page['type'] || PAGE_TYPE_HTML_BLOCK == $page['type']) {
    exit;
}
//--------
if (!check_right_on_trigger_by_triggerid(PERM_READ_ONLY, $_REQUEST["triggerid"])) {
    access_deny();
}
$trigger_data = DBfetch(DBselect('SELECT h.host, t.* ' . ' FROM hosts h, items i, functions f, triggers t ' . ' WHERE i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid ' . ' AND t.triggerid=' . $_REQUEST["triggerid"] . ' AND h.hostid=i.hostid ' . ' AND ' . DBin_node('t.triggerid')));
$p_elements = array();
//Header
$trigger_data['exp_expr'] = explode_exp($trigger_data["expression"], 1);
$trigger_data['exp_desc'] = expand_trigger_description_by_data($trigger_data);
$text = array(S_EVENTS_BIG . ': "' . $trigger_data['exp_desc'] . '"');
$url = '?fullscreen=' . ($_REQUEST['fullscreen'] ? '0' : '1') . url_param('triggerid') . url_param('eventid');
$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 . "';"));
//-------
$left_tab = new CTable();
$left_tab->setCellPadding(3);
Пример #2
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';
Пример #3
0
function validate_condition($conditiontype, $value)
{
    global $USER_DETAILS;
    switch ($conditiontype) {
        case CONDITION_TYPE_HOST_GROUP:
            $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY, null, get_current_nodeid(true));
            if (!isset($available_groups[$value])) {
                error(S_INCORRECT_GROUP);
                return false;
            }
            break;
        case CONDITION_TYPE_HOST_TEMPLATE:
            $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, null, get_current_nodeid(true));
            if (!isset($available_hosts[$value])) {
                error(S_INCORRECT_HOST);
                return false;
            }
            break;
        case CONDITION_TYPE_TRIGGER:
            if (!DBfetch(DBselect('select triggerid from triggers where triggerid=' . $value)) || !check_right_on_trigger_by_triggerid(PERM_READ_ONLY, $value)) {
                error(S_INCORRECT_TRIGGER);
                return false;
            }
            break;
        case CONDITION_TYPE_HOST:
            $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, null, get_current_nodeid(true));
            if (!isset($available_hosts[$value])) {
                error(S_INCORRECT_HOST);
                return false;
            }
            break;
        case CONDITION_TYPE_TIME_PERIOD:
            if (!validate_period($value)) {
                error(S_INCORRECT_PERIOD . ' [' . $value . ']');
                return false;
            }
            break;
        case CONDITION_TYPE_DHOST_IP:
            if (!validate_ip_range($value)) {
                error(S_INCORRECT_IP . ' [' . $value . ']');
                return false;
            }
            break;
        case CONDITION_TYPE_DSERVICE_TYPE:
            if (S_UNKNOWN == discovery_check_type2str($value)) {
                error(S_INCORRECT_DISCOVERY_CHECK);
                return false;
            }
            break;
        case CONDITION_TYPE_DSERVICE_PORT:
            if (!validate_port_list($value)) {
                error(S_INCORRECT_PORT . ' [' . $value . ']');
                return false;
            }
            break;
        case CONDITION_TYPE_DSTATUS:
            if (S_UNKNOWN == discovery_object_status2str($value)) {
                error(S_INCORRECT_DISCOVERY_STATUS);
                return false;
            }
            break;
        case CONDITION_TYPE_EVENT_ACKNOWLEDGED:
            if (S_UNKNOWN == condition_value2str($conditiontype, $value)) {
                error(S_INCORRECT_DISCOVERY_STATUS);
                return false;
            }
            break;
        case CONDITION_TYPE_TRIGGER_NAME:
        case CONDITION_TYPE_TRIGGER_VALUE:
        case CONDITION_TYPE_TRIGGER_SEVERITY:
        case CONDITION_TYPE_MAINTENANCE:
        case CONDITION_TYPE_DUPTIME:
        case CONDITION_TYPE_DVALUE:
        case CONDITION_TYPE_APPLICATION:
            break;
        default:
            error(S_INCORRECT_CONDITION_TYPE);
            return false;
            break;
    }
    return true;
}
Пример #4
0
**/
require_once 'include/config.inc.php';
require_once 'include/hosts.inc.php';
require_once 'include/triggers.inc.php';
require_once 'include/forms.inc.php';
$page['title'] = "S_CONFIGURATION_OF_TRIGGERS";
$page["file"] = "triggers.php";
$page['hist_arg'] = array('hostid', 'groupid');
include_once 'include/page_header.php';
//		VAR			TYPE	OPTIONAL FLAGS	VALIDATION	EXCEPTION
$fields = array('groupid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), 'hostid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({save})'), 'triggerid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, '(isset({form})&&({form}=="update"))'), 'copy_type' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), 'isset({copy})'), 'copy_mode' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0'), NULL), 'type' => array(T_ZBX_INT, O_OPT, NULL, IN('0,1'), 'isset({save})'), 'description' => array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'), 'expression' => array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'), 'priority' => array(T_ZBX_INT, O_OPT, NULL, IN('0,1,2,3,4,5'), 'isset({save})'), 'comments' => array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({save})'), 'url' => array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({save})'), 'status' => array(T_ZBX_STR, O_OPT, NULL, NULL, NULL), 'dependencies' => array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL), 'new_dependence' => array(T_ZBX_INT, O_OPT, NULL, DB_ID . '{}>0', 'isset({add_dependence})'), 'rem_dependence' => array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL), 'g_triggerid' => array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL), 'copy_targetid' => array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL), 'filter_groupid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({copy})&&(isset({copy_type})&&({copy_type}==0))'), 'showdisabled' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), NULL), 'massupdate' => array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), 'visible' => array(T_ZBX_STR, O_OPT, null, null, null), 'add_dependence' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, NULL, NULL), 'del_dependence' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, NULL, NULL), 'group_enable' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, NULL, NULL), 'group_disable' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, NULL, NULL), 'group_delete' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, NULL, NULL), 'copy' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, NULL, NULL), 'clone' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, NULL, NULL), 'save' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, NULL, NULL), 'mass_save' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, NULL, NULL), 'delete' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, NULL, NULL), 'cancel' => array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), 'form_copy_to' => array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), 'form_refresh' => array(T_ZBX_INT, O_OPT, NULL, NULL, NULL));
$_REQUEST['showdisabled'] = get_request('showdisabled', get_profile('web.triggers.showdisabled', 0));
check_fields($fields);
validate_sort_and_sortorder('t.description', ZBX_SORT_UP);
if (isset($_REQUEST['triggerid'])) {
    if (!check_right_on_trigger_by_triggerid(PERM_READ_WRITE, $_REQUEST['triggerid'])) {
        access_deny();
    }
}
$showdisabled = get_request('showdisabled', 0);
update_profile('web.triggers.showdisabled', $showdisabled, PROFILE_TYPE_INT);
$available_triggers = get_accessible_triggers(PERM_READ_WRITE, array());
// OPTIMIZE!!!
/* FORM ACTIONS */
if (isset($_REQUEST['clone']) && isset($_REQUEST['triggerid'])) {
    unset($_REQUEST['triggerid']);
    $_REQUEST['form'] = 'clone';
} else {
    if (isset($_REQUEST['mass_save']) && isset($_REQUEST['g_triggerid'])) {
        show_messages();
        $result = false;