예제 #1
0
function make_favorite_graphs()
{
    $table = new CTableInfo();
    $fav_graphs = get_favorites('web.favorite.graphids');
    foreach ($fav_graphs as $key => $favorite) {
        $source = $favorite['source'];
        $sourceid = $favorite['value'];
        if ('itemid' == $source) {
            if (!($item = get_item_by_itemid($sourceid))) {
                continue;
            }
            $host = get_host_by_itemid($sourceid);
            $item["description"] = item_description($item);
            $link = new CLink(get_node_name_by_elid($sourceid) . $host['host'] . ':' . $item['description'], 'history.php?action=showgraph&itemid=' . $sourceid);
            $link->setTarget('blank');
            $capt = new CSpan($link);
            $capt->setAttribute('style', 'line-height: 14px; vertical-align: middle;');
            $icon = new CLink(new CImg('images/general/chart.png', 'chart', 18, 18, 'borderless'), 'history.php?action=showgraph&itemid=' . $sourceid . '&fullscreen=1');
            $icon->setTarget('blank');
        } else {
            if (!($graph = get_graph_by_graphid($sourceid))) {
                continue;
            }
            if (!graph_accessible($sourceid)) {
                continue;
            }
            $result = get_hosts_by_graphid($sourceid);
            $ghost = DBFetch($result);
            $link = new CLink(get_node_name_by_elid($sourceid) . $ghost['host'] . ':' . $graph['name'], 'charts.php?graphid=' . $sourceid);
            $link->setTarget('blank');
            $capt = new CSpan($link);
            $capt->setAttribute('style', 'line-height: 14px; vertical-align: middle;');
            $icon = new CLink(new CImg('images/general/chart.png', 'chart', 18, 18, 'borderless'), 'charts.php?graphid=' . $sourceid . '&fullscreen=1');
            $icon->setTarget('blank');
        }
        $table->addRow(new CCol(array($icon, SPACE, $capt)));
    }
    $td = new CCol(array(new CLink(S_GRAPHS . ' »', 'charts.php', 'highlight')));
    $td->setAttribute('style', 'text-align: right;');
    $table->setFooter($td);
    return $table;
}
예제 #2
0
파일: charts.php 프로젝트: rennhak/zabbix
if (!$ZBX_WITH_SUBNODES) {
    array_push($options, 'only_current_node');
}
$params = array();
foreach ($options as $option) {
    $params[$option] = 1;
}
$PAGE_GROUPS = get_viewed_groups(PERM_READ_ONLY, $params);
$PAGE_HOSTS = get_viewed_hosts(PERM_READ_ONLY, $PAGE_GROUPS['selected'], $params);
validate_group_with_host($PAGE_GROUPS, $PAGE_HOSTS);
//SDI($_REQUEST['groupid'].' : '.$_REQUEST['hostid']);
$available_groups = $PAGE_GROUPS['groupids'];
$available_hosts = $PAGE_HOSTS['hostids'];
$available_graphs = get_accessible_graphs(PERM_READ_LIST, $available_hosts, PERM_RES_IDS_ARRAY, get_current_nodeid(true));
if ($_REQUEST['graphid'] > 0 && ($row = DBfetch(DBselect('SELECT DISTINCT graphid, name FROM graphs WHERE graphid=' . $_REQUEST['graphid'])))) {
    if (!graph_accessible($_REQUEST['graphid'])) {
        update_profile('web.charts.graphid', 0);
        access_deny();
    }
    array_push($h1, $row['name']);
} else {
    $_REQUEST['graphid'] = 0;
    array_push($h1, S_SELECT_GRAPH_TO_DISPLAY);
}
$p_elements = array();
$r_form = new CForm();
$r_form->setMethod('get');
$r_form->addVar('fullscreen', $_REQUEST['fullscreen']);
$cmbGroups = new CComboBox('groupid', $PAGE_GROUPS['selected'], 'javascript: submit();');
$cmbHosts = new CComboBox('hostid', $PAGE_HOSTS['selected'], 'javascript: submit();');
foreach ($PAGE_GROUPS['groups'] as $groupid => $name) {
예제 #3
0
function get_screen_item_form()
{
    global $USER_DETAILS;
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, get_current_nodeid(true));
    $form = new CFormTable(S_SCREEN_CELL_CONFIGURATION, 'screenedit.php#form');
    $form->SetHelp('web.screenedit.cell.php');
    if (isset($_REQUEST['screenitemid'])) {
        $iresult = DBSelect('SELECT * FROM screens_items' . ' WHERE screenid=' . $_REQUEST['screenid'] . ' AND screenitemid=' . $_REQUEST['screenitemid']);
        $form->AddVar('screenitemid', $_REQUEST['screenitemid']);
    } else {
        $form->AddVar('x', $_REQUEST['x']);
        $form->AddVar('y', $_REQUEST['y']);
    }
    if (isset($_REQUEST['screenitemid']) && !isset($_REQUEST['form_refresh'])) {
        $irow = DBfetch($iresult);
        $resourcetype = $irow['resourcetype'];
        $resourceid = $irow['resourceid'];
        $width = $irow['width'];
        $height = $irow['height'];
        $colspan = $irow['colspan'];
        $rowspan = $irow['rowspan'];
        $elements = $irow['elements'];
        $valign = $irow['valign'];
        $halign = $irow['halign'];
        $style = $irow['style'];
        $url = $irow['url'];
        $dynamic = $irow['dynamic'];
    } else {
        $resourcetype = get_request('resourcetype', 0);
        $resourceid = get_request('resourceid', 0);
        $width = get_request('width', 500);
        $height = get_request('height', 100);
        $colspan = get_request('colspan', 0);
        $rowspan = get_request('rowspan', 0);
        $elements = get_request('elements', 25);
        $valign = get_request('valign', VALIGN_DEFAULT);
        $halign = get_request('halign', HALIGN_DEFAULT);
        $style = get_request('style', 0);
        $url = get_request('url', '');
        $dynamic = get_request('dynamic', SCREEN_SIMPLE_ITEM);
    }
    $form->addVar('screenid', $_REQUEST['screenid']);
    $cmbRes = new CCombobox('resourcetype', $resourcetype, 'submit()');
    $cmbRes->addItem(SCREEN_RESOURCE_GRAPH, S_GRAPH);
    $cmbRes->addItem(SCREEN_RESOURCE_SIMPLE_GRAPH, S_SIMPLE_GRAPH);
    $cmbRes->addItem(SCREEN_RESOURCE_PLAIN_TEXT, S_PLAIN_TEXT);
    $cmbRes->addItem(SCREEN_RESOURCE_MAP, S_MAP);
    $cmbRes->addItem(SCREEN_RESOURCE_SCREEN, S_SCREEN);
    $cmbRes->addItem(SCREEN_RESOURCE_SERVER_INFO, S_SERVER_INFO);
    $cmbRes->addItem(SCREEN_RESOURCE_HOSTS_INFO, S_HOSTS_INFO);
    $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_INFO, S_TRIGGERS_INFO);
    $cmbRes->addItem(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, S_TRIGGERS_OVERVIEW);
    $cmbRes->addItem(SCREEN_RESOURCE_STATUS_OF_TRIGGERS, S_STATUS_OF_TRIGGERS);
    $cmbRes->addItem(SCREEN_RESOURCE_DATA_OVERVIEW, S_DATA_OVERVIEW);
    $cmbRes->addItem(SCREEN_RESOURCE_CLOCK, S_CLOCK);
    $cmbRes->addItem(SCREEN_RESOURCE_URL, S_URL);
    $cmbRes->addItem(SCREEN_RESOURCE_ACTIONS, S_HISTORY_OF_ACTIONS);
    $cmbRes->addItem(SCREEN_RESOURCE_EVENTS, S_HISTORY_OF_EVENTS);
    $form->addRow(S_RESOURCE, $cmbRes);
    if ($resourcetype == SCREEN_RESOURCE_GRAPH) {
        // User-defined graph
        $resourceid = graph_accessible($resourceid) ? $resourceid : 0;
        $caption = '';
        $id = 0;
        if ($resourceid > 0) {
            $result = DBselect('SELECT DISTINCT g.graphid,g.name,n.name as node_name, h.host' . ' FROM graphs g ' . ' LEFT JOIN graphs_items gi ON g.graphid=gi.graphid ' . ' LEFT JOIN items i ON gi.itemid=i.itemid ' . ' LEFT JOIN hosts h ON h.hostid=i.hostid ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.graphid') . ' WHERE g.graphid=' . $resourceid);
            while ($row = DBfetch($result)) {
                $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                $caption = $row['node_name'] . $row['host'] . ':' . $row['name'];
                $id = $resourceid;
            }
        }
        $form->addVar('resourceid', $id);
        $textfield = new Ctextbox('caption', $caption, 75, 'yes');
        $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=graphs&srcfld1=graphid&srcfld2=name',800,450);");
        $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
        $form->AddRow(S_GRAPH_NAME, array($textfield, SPACE, $selectbtn));
    } else {
        if ($resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH) {
            // Simple graph
            $caption = '';
            $id = 0;
            if ($resourceid > 0) {
                $result = DBselect('SELECT n.name as node_name,h.host,i.description,i.itemid,i.key_ ' . ' FROM hosts h,items i ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('i.itemid') . ' WHERE h.hostid=i.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('i.hostid', $available_hosts) . ' AND i.itemid=' . $resourceid);
                while ($row = DBfetch($result)) {
                    $description_ = item_description($row);
                    $row["node_name"] = isset($row["node_name"]) ? "(" . $row["node_name"] . ") " : '';
                    $caption = $row['node_name'] . $row['host'] . ': ' . $description_;
                    $id = $resourceid;
                }
            }
            $form->AddVar('resourceid', $id);
            $textfield = new Ctextbox('caption', $caption, 75, 'yes');
            $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=simple_graph&srcfld1=itemid&srcfld2=description',800,450);");
            $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
            $form->AddRow(S_PARAMETER, array($textfield, SPACE, $selectbtn));
        } else {
            if ($resourcetype == SCREEN_RESOURCE_MAP) {
                // Map
                $caption = '';
                $id = 0;
                if ($resourceid > 0) {
                    $result = DBselect('SELECT n.name as node_name, s.sysmapid,s.name ' . ' FROM sysmaps s' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('s.sysmapid') . ' WHERE s.sysmapid=' . $resourceid);
                    while ($row = DBfetch($result)) {
                        if (!sysmap_accessible($row['sysmapid'], PERM_READ_ONLY)) {
                            continue;
                        }
                        $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                        $caption = $row['node_name'] . $row['name'];
                        $id = $resourceid;
                    }
                }
                $form->AddVar('resourceid', $id);
                $textfield = new Ctextbox('caption', $caption, 60, 'yes');
                $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=sysmaps&srcfld1=sysmapid&srcfld2=name',400,450);");
                $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                $form->AddRow(S_PARAMETER, array($textfield, SPACE, $selectbtn));
            } else {
                if ($resourcetype == SCREEN_RESOURCE_PLAIN_TEXT) {
                    // Plain text
                    $caption = '';
                    $id = 0;
                    if ($resourceid > 0) {
                        $result = DBselect('SELECT n.name as node_name,h.host,i.description,i.itemid,i.key_ ' . ' FROM hosts h,items i ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('i.itemid') . ' WHERE h.hostid=i.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('i.hostid', $available_hosts) . ' AND i.itemid=' . $resourceid);
                        while ($row = DBfetch($result)) {
                            $description_ = item_description($row);
                            $row["node_name"] = isset($row["node_name"]) ? '(' . $row["node_name"] . ') ' : '';
                            $caption = $row['node_name'] . $row['host'] . ': ' . $description_;
                            $id = $resourceid;
                        }
                    }
                    $form->AddVar('resourceid', $id);
                    $textfield = new Ctextbox('caption', $caption, 75, 'yes');
                    $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=plain_text&srcfld1=itemid&srcfld2=description',800,450);");
                    $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                    $form->addRow(S_PARAMETER, array($textfield, SPACE, $selectbtn));
                    $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2));
                    $form->addRow(S_SHOW_TEXT_AS_HTML, new CCheckBox('style', $style, null, 1));
                } else {
                    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_EVENTS, SCREEN_RESOURCE_STATUS_OF_TRIGGERS, SCREEN_RESOURCE_ACTIONS))) {
                        // History of actions
                        // History of events
                        // Status of triggers
                        $form->addRow(S_SHOW_LINES, new CNumericBox('elements', $elements, 2));
                        $form->addVar('resourceid', 0);
                    } else {
                        if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) {
                            // Overviews
                            $caption = '';
                            $id = 0;
                            if ($resourceid > 0) {
                                $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY);
                                $result = DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name ' . ' FROM hosts_groups hg,hosts h,groups g ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=hg.groupid ' . ' AND hg.hostid=h.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND g.groupid=' . $resourceid);
                                while ($row = DBfetch($result)) {
                                    $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                                    $caption = $row['node_name'] . $row['name'];
                                    $id = $resourceid;
                                }
                            }
                            $form->AddVar('resourceid', $id);
                            $textfield = new Ctextbox('caption', $caption, 75, 'yes');
                            $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=overview&srcfld1=groupid&srcfld2=name',800,450);");
                            $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                            $form->AddRow(S_GROUP, array($textfield, SPACE, $selectbtn));
                        } else {
                            if ($resourcetype == SCREEN_RESOURCE_SCREEN) {
                                // Screens
                                $caption = '';
                                $id = 0;
                                if ($resourceid > 0) {
                                    $result = DBselect('SELECT DISTINCT n.name as node_name,s.screenid,s.name ' . ' FROM screens s ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('s.screenid') . ' WHERE s.screenid=' . $resourceid);
                                    while ($row = DBfetch($result)) {
                                        if (!screen_accessible($row['screenid'], PERM_READ_ONLY)) {
                                            continue;
                                        }
                                        if (check_screen_recursion($_REQUEST['screenid'], $row['screenid'])) {
                                            continue;
                                        }
                                        $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                                        $caption = $row['node_name'] . $row['name'];
                                        $id = $resourceid;
                                    }
                                }
                                $form->addVar('resourceid', $id);
                                $textfield = new Ctextbox('caption', $caption, 60, 'yes');
                                $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=screens2&srcfld1=screenid&srcfld2=name&screenid=" . $_REQUEST['screenid'] . "',800,450);");
                                $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                                $form->AddRow(S_PARAMETER, array($textfield, SPACE, $selectbtn));
                            } else {
                                if ($resourcetype == SCREEN_RESOURCE_HOSTS_INFO || $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) {
                                    // HOSTS info
                                    $caption = '';
                                    $id = 0;
                                    $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY);
                                    if (remove_nodes_from_id($resourceid) > 0) {
                                        $result = DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name ' . ' FROM hosts_groups hg, groups g ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=' . $resourceid);
                                        while ($row = DBfetch($result)) {
                                            $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                                            $caption = $row['node_name'] . $row['name'];
                                            $id = $resourceid;
                                        }
                                    } else {
                                        if (remove_nodes_from_id($resourceid) == 0) {
                                            $result = DBselect('SELECT DISTINCT n.name as node_name ' . ' FROM nodes n ' . ' WHERE n.nodeid=' . id2nodeid($resourceid));
                                            while ($row = DBfetch($result)) {
                                                $row['node_name'] = isset($row['node_name']) ? '(' . $row['node_name'] . ') ' : '';
                                                $caption = $row['node_name'] . S_MINUS_ALL_GROUPS_MINUS;
                                                $id = $resourceid;
                                            }
                                        }
                                    }
                                    $form->AddVar('resourceid', $id);
                                    $textfield = new CTextbox('caption', $caption, 60, 'yes');
                                    $selectbtn = new Cbutton('select', S_SELECT, "javascript: return PopUp('popup.php?dstfrm=" . $form->getName() . "&dstfld1=resourceid&dstfld2=caption&srctbl=host_group_scr&srcfld1=groupid&srcfld2=name',480,450);");
                                    $selectbtn->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
                                    $form->AddRow(S_GROUP, array($textfield, SPACE, $selectbtn));
                                } else {
                                    // SCREEN_RESOURCE_CLOCK
                                    $form->addVar('resourceid', 0);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_HOSTS_INFO, SCREEN_RESOURCE_TRIGGERS_INFO))) {
        $cmbStyle = new CComboBox("style", $style);
        $cmbStyle->AddItem(STYLE_HORISONTAL, S_HORIZONTAL);
        $cmbStyle->AddItem(STYLE_VERTICAL, S_VERTICAL);
        $form->AddRow(S_STYLE, $cmbStyle);
    } else {
        if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_TRIGGERS_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW))) {
            $cmbStyle = new CComboBox('style', $style);
            $cmbStyle->AddItem(STYLE_LEFT, S_LEFT);
            $cmbStyle->AddItem(STYLE_TOP, S_TOP);
            $form->AddRow(S_HOSTS_LOCATION, $cmbStyle);
        } else {
            if ($resourcetype == SCREEN_RESOURCE_CLOCK) {
                $cmbStyle = new CComboBox('style', $style);
                $cmbStyle->AddItem(TIME_TYPE_LOCAL, S_LOCAL_TIME);
                $cmbStyle->AddItem(TIME_TYPE_SERVER, S_SERVER_TIME);
                $form->AddRow(S_TIME_TYPE, $cmbStyle);
            } else {
                $form->AddVar('style', 0);
            }
        }
    }
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_URL))) {
        $form->AddRow(S_URL, new CTextBox('url', $url, 60));
    } else {
        $form->AddVar('url', '');
    }
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) {
        $form->AddRow(S_WIDTH, new CNumericBox('width', $width, 5));
        $form->AddRow(S_HEIGHT, new CNumericBox('height', $height, 5));
    } else {
        $form->AddVar('width', 500);
        $form->AddVar('height', 100);
    }
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_MAP, SCREEN_RESOURCE_CLOCK, SCREEN_RESOURCE_URL))) {
        $cmbHalign = new CComboBox('halign', $halign);
        $cmbHalign->AddItem(HALIGN_CENTER, S_CENTRE);
        $cmbHalign->AddItem(HALIGN_LEFT, S_LEFT);
        $cmbHalign->AddItem(HALIGN_RIGHT, S_RIGHT);
        $form->AddRow(S_HORIZONTAL_ALIGN, $cmbHalign);
    } else {
        $form->AddVar('halign', 0);
    }
    $cmbValign = new CComboBox('valign', $valign);
    $cmbValign->AddItem(VALIGN_MIDDLE, S_MIDDLE);
    $cmbValign->AddItem(VALIGN_TOP, S_TOP);
    $cmbValign->AddItem(VALIGN_BOTTOM, S_BOTTOM);
    $form->AddRow(S_VERTICAL_ALIGN, $cmbValign);
    $form->AddRow(S_COLUMN_SPAN, new CNumericBox('colspan', $colspan, 2));
    $form->AddRow(S_ROW_SPAN, new CNumericBox('rowspan', $rowspan, 2));
    // dynamic AddOn
    if (uint_in_array($resourcetype, array(SCREEN_RESOURCE_GRAPH, SCREEN_RESOURCE_SIMPLE_GRAPH, SCREEN_RESOURCE_PLAIN_TEXT))) {
        $form->AddRow(S_DYNAMIC_ITEM, new CCheckBox('dynamic', $dynamic, null, 1));
    }
    $form->AddItemToBottomRow(new CButton('save', S_SAVE));
    if (isset($_REQUEST['screenitemid'])) {
        $form->addItemToBottomRow(SPACE);
        $form->addItemToBottomRow(new CButtonDelete(null, url_param('form') . url_param('screenid') . url_param('screenitemid')));
    }
    $form->addItemToBottomRow(SPACE);
    $form->addItemToBottomRow(new CButtonCancel(url_param('screenid')));
    return $form;
}