Exemple #1
0
require_once 'include/hosts.inc.php';
require_once 'include/acknow.inc.php';
require_once 'include/triggers.inc.php';
require_once 'include/events.inc.php';
require_once 'include/scripts.inc.php';
$page['file'] = 'tr_status.php';
$page['title'] = "S_STATUS_OF_TRIGGERS";
$page['scripts'] = array('menu_scripts.js', 'scriptaculous.js?load=effects');
$page['hist_arg'] = array('groupid', 'hostid');
$page['type'] = detect_page_type(PAGE_TYPE_HTML);
if ($page['type'] == PAGE_TYPE_HTML) {
    $tr_hash = calc_trigger_hash();
    $triggers_hash = get_cookie('zbx_triggers_hash', '0,0');
    $new = explode(',', $tr_hash);
    $old = explode(',', $triggers_hash);
    zbx_set_post_cookie('zbx_triggers_hash', $tr_hash, time() + 1800);
    $triggers_hash = get_cookie('zbx_triggers_hash', '0,0');
    $new = explode(',', $tr_hash);
    $old = explode(',', $triggers_hash);
    if ($old[1] != $new[1]) {
        if ($new[0] < $old[0]) {
            // Number of trigger decreased
            $status = 'off';
        } else {
            // Number of trigger increased
            $status = 'on';
        }
        $files_apdx = array(5 => 'disaster', 4 => 'high', 3 => 'average', 2 => 'warning', 1 => 'information', 0 => 'not_classified');
        $prior_dif = $new[0] - $old[0];
        krsort($files_apdx);
        foreach ($files_apdx as $priority => $apdx) {
// IBM_DB2
if (zbx_is_callable(array('db2_connect', 'db2_set_option', 'db2_prepare', 'db2_execute', 'db2_fetch_assoc'))) {
    $ZBX_CONFIG['allowed_db']['IBM_DB2'] = 'IBM DB2';
}
// SQLITE3. The false is here to avoid autoloading of the class.
if (class_exists('SQLite3', false) && zbx_is_callable(array('ftok', 'sem_acquire', 'sem_release', 'sem_get'))) {
    $ZBX_CONFIG['allowed_db']['SQLITE3'] = 'SQLite3';
}
if (count($ZBX_CONFIG['allowed_db']) == 0) {
    $ZBX_CONFIG['allowed_db']['no'] = 'No';
}
/*
 * Setup wizard
 */
global $ZBX_SETUP_WIZARD;
$ZBX_SETUP_WIZARD = new CSetupWizard($ZBX_CONFIG);
zbx_set_post_cookie('ZBX_CONFIG', serialize($ZBX_CONFIG));
require_once dirname(__FILE__) . '/include/page_header.php';
include 'include/views/js/setup.js.php';
/*
 * Check configuration
 */
global $ZBX_CONFIGURATION_FILE;
if (file_exists($ZBX_CONFIGURATION_FILE)) {
    if (isset($_REQUEST['message'])) {
        show_error_message($_REQUEST['message']);
    }
}
$ZBX_SETUP_WIZARD->show();
unset($_POST);
require_once dirname(__FILE__) . '/include/page_footer.php';
Exemple #3
0
function init_nodes()
{
    /* Init CURRENT NODE ID */
    global $USER_DETAILS, $ZBX_LOCALNODEID, $ZBX_LOCMASTERID, $ZBX_CURRENT_NODEID, $ZBX_CURRENT_SUBNODES, $ZBX_CURMASTERID, $ZBX_NODES, $ZBX_NODES_IDS, $ZBX_WITH_SUBNODES;
    $ZBX_CURRENT_SUBNODES = array();
    $ZBX_NODES_IDS = array();
    $ZBX_NODES = array();
    if (!defined('ZBX_PAGE_NO_AUTHERIZATION') && ZBX_DISTRIBUTED) {
        $ZBX_CURRENT_NODEID = get_cookie('zbx_current_nodeid', $ZBX_LOCALNODEID);
        // Selected node
        $ZBX_WITH_SUBNODES = get_cookie('zbx_with_subnodes', false);
        // Show elements FROM subnodes
        if (isset($_REQUEST['switch_node'])) {
            if ($node_data = DBfetch(DBselect('SELECT * FROM nodes WHERE nodeid=' . $_REQUEST['switch_node']))) {
                $ZBX_CURRENT_NODEID = $_REQUEST['switch_node'];
            }
            unset($node_data);
        }
        if (isset($_REQUEST['show_subnodes'])) {
            $ZBX_WITH_SUBNODES = !empty($_REQUEST['show_subnodes']);
        }
        if ($node_data = DBfetch(DBselect('SELECT * FROM nodes WHERE nodeid=' . $ZBX_CURRENT_NODEID))) {
            $ZBX_CURMASTERID = $node_data['masterid'];
        }
        if ($USER_DETAILS['type'] == USER_TYPE_SUPER_ADMIN) {
            $sql = 'SELECT DISTINCT n.nodeid,n.name,n.masterid FROM nodes n';
        } else {
            $sql = 'SELECT DISTINCT n.nodeid,n.name,n.masterid ' . ' FROM nodes n, groups hg,rights r, users_groups g ' . ' WHERE r.id=hg.groupid ' . ' AND r.groupid=g.usrgrpid ' . ' AND g.userid=' . $USER_DETAILS['userid'] . ' AND ' . DBid2nodeid('hg.groupid') . '=n.nodeid;';
        }
        $db_nodes = DBselect($sql);
        while ($node = DBfetch($db_nodes)) {
            $ZBX_NODES_IDS[$node['nodeid']] = $node['nodeid'];
            $ZBX_NODES[$node['nodeid']] = $node;
        }
        if (!isset($ZBX_NODES[$ZBX_CURRENT_NODEID])) {
            $denyed_page_requested = true;
            $ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID;
            $ZBX_CURMASTERID = $ZBX_LOCMASTERID;
        }
        foreach ($ZBX_NODES as $nodeid => $node_data) {
            $curr_node =& $node_data;
            if ($curr_node['masterid'] != 0 && bccomp($curr_node['masterid'], $ZBX_CURRENT_NODEID) != 0) {
                $curr_node =& $ZBX_NODES[$curr_node['masterid']];
            }
            if (bccomp($curr_node['masterid'], $ZBX_CURRENT_NODEID) == 0) {
                $ZBX_CURRENT_SUBNODES[$nodeid] = $nodeid;
            }
        }
        zbx_set_post_cookie('zbx_current_nodeid', $ZBX_CURRENT_NODEID);
        zbx_set_post_cookie('zbx_with_subnodes', $ZBX_WITH_SUBNODES);
    } else {
        $ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID;
        $ZBX_CURMASTERID = $ZBX_LOCMASTERID;
        $ZBX_WITH_SUBNODES = false;
    }
    $ZBX_CURRENT_SUBNODES[$ZBX_CURRENT_NODEID] = $ZBX_CURRENT_NODEID;
    if (count($ZBX_CURRENT_SUBNODES) < 2 && !defined('ZBX_DISABLE_SUBNODES')) {
        define('ZBX_DISABLE_SUBNODES', 1);
    } else {
        $ZBX_CURRENT_SUBNODES = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_LIST, PERM_RES_IDS_ARRAY, $ZBX_CURRENT_SUBNODES);
    }
}