Beispiel #1
0
function make_acktab_by_eventid($eventid)
{
    $table = new CTableInfo();
    $table->SetHeader(array(S_TIME, S_USER, S_COMMENTS));
    $acks = get_acknowledges_by_eventid($eventid);
    while ($ack = DBfetch($acks)) {
        $user = get_user_by_userid($ack['userid']);
        $table->AddRow(array(date('d-m-Y h:i:s A', $ack['clock']), $user['alias'], new CCol(zbx_nl2br($ack['message']), 'wraptext')));
    }
    return $table;
}
function make_acktab_by_eventid($eventid)
{
    $table = new CTableInfo();
    $table->SetHeader(array(S_TIME, S_USER, S_COMMENTS));
    $acks = get_acknowledges_by_eventid($eventid);
    while ($ack = DBfetch($acks)) {
        //$users = CUser::get(array('userids' => $ack['userid'],  'output' => API_OUTPUT_EXTEND));
        //$user = reset($users);
        $table->addRow(array(zbx_date2str(S_ACKNOWINC_BY_EVENTS_DATE_FORMAT, $ack['clock']), $ack['alias'], new CCol(zbx_nl2br($ack['message']), 'wraptext')));
    }
    return $table;
}
Beispiel #3
0
     $triggers[$rowz['triggerid']] = $rowz;
     $triggerids[$rowz['triggerid']] = $rowz['triggerid'];
 }
 $sql = 'SELECT f.triggerid, i.* ' . ' FROM functions f, items i ' . ' WHERE ' . DBcondition('f.triggerid', $triggerids) . ' AND i.itemid=f.itemid';
 $result = DBselect($sql);
 while ($row = DBfetch($result)) {
     $item['itemid'] = $row['itemid'];
     $item['action'] = str_in_array($row['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64)) ? 'showgraph' : 'showvalues';
     $item['description'] = item_description($row);
     $triggers[$row['triggerid']]['items'][$row['itemid']] = $item;
 }
 $sql_cond = $show_unknown == 0 ? ' AND e.value<>' . TRIGGER_VALUE_UNKNOWN . ' ' : '';
 $sql_cond .= ' AND e.clock>' . $start;
 $sql_cond .= ' AND e.clock<' . $end;
 $table = new CTableInfo(S_NO_EVENTS_FOUND);
 $table->SetHeader(array(make_sorting_link(S_TIME, 'e.clock'), is_show_subnodes() ? S_NODE : null, $_REQUEST['hostid'] == 0 ? S_HOST : null, S_DESCRIPTION, S_STATUS, S_SEVERITY, S_DURATION, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS));
 if (!empty($triggers)) {
     $col = 0;
     $sql = 'SELECT e.eventid, e.objectid as triggerid, e.clock, e.value, e.acknowledged ' . ' FROM events e ' . ' WHERE ' . DBcondition('e.objectid', $triggerids) . ' AND (e.object+0)=' . EVENT_OBJECT_TRIGGER . $sql_cond . order_by('e.clock');
     //SDI($sql);
     $result = DBselect($sql);
     while ($row = DBfetch($result)) {
         $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;
         }
         $duration = zbx_date2age($row['clock']);
         if ($next_event = get_next_event($row, $show_unknown)) {
             $duration = zbx_date2age($row['clock'], $next_event['clock']);
         }
Beispiel #4
0
$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';
        }
        $discovery_info[$dhost['ip']] = array('class' => $class, 'time' => $dhost[$time], 'druleid' => $dhost['druleid']);
        $db_dservices = DBselect('SELECT type,port,key_,status,lastup,lastdown FROM dservices ' . ' WHERE dhostid=' . $dhost['dhostid'] . ' order by status,type,port');
        while ($dservice = DBfetch($db_dservices)) {
            $class = 'active';
function get_screen($screenid, $editmode, $effectiveperiod = NULL)
{
    global $USER_DETAILS;
    if ($screenid == 0) {
        return new CTableInfo(S_NO_SCREENS_DEFINED);
    }
    $r = CScreen::get(array('screenids' => $screenid, 'editable' => $editmode == 1 ? 1 : null, 'output' => API_OUTPUT_SHORTEN));
    if (empty($r)) {
        access_deny();
    }
    if (is_null($effectiveperiod)) {
        $effectiveperiod = ZBX_MIN_PERIOD;
    }
    $result = DBselect('SELECT name,hsize,vsize FROM screens WHERE screenid=' . $screenid);
    $row = DBfetch($result);
    if (!$row) {
        return new CTableInfo(S_NO_SCREENS_DEFINED);
    }
    $sql = 'SELECT * FROM screens_items WHERE screenid=' . $screenid;
    $iresult = DBSelect($sql);
    $skip_field = array();
    $irows = array();
    while ($irow = DBfetch($iresult)) {
        $irows[] = $irow;
        for ($i = 0; $i < $irow['rowspan'] || $i == 0; $i++) {
            for ($j = 0; $j < $irow['colspan'] || $j == 0; $j++) {
                if ($i != 0 || $j != 0) {
                    if (!isset($skip_field[$irow['y'] + $i])) {
                        $skip_field[$irow['y'] + $i] = array();
                    }
                    $skip_field[$irow['y'] + $i][$irow['x'] + $j] = 1;
                }
            }
        }
    }
    $table = new CTable(new CLink(S_NO_ROWS_IN_SCREEN . SPACE . $row['name'], 'screenconf.php?config=0&form=update&screenid=' . $screenid), $editmode == 0 || $editmode == 2 ? 'screen_view' : 'screen_edit');
    $table->setAttribute('id', 'iframe');
    if ($editmode == 1) {
        $new_cols = array(new Ccol(new Cimg('images/general/zero.gif', 'zero', 1, 1)));
        for ($c = 0; $c < $row['hsize'] + 1; $c++) {
            $add_icon = new Cimg('images/general/closed.gif', NULL, NULL, NULL, 'pointer');
            $add_icon->addAction('onclick', "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&add_col={$c}';");
            array_push($new_cols, new Ccol($add_icon));
        }
        $table->addRow($new_cols);
    }
    $empty_screen_col = array();
    for ($r = 0; $r < $row['vsize']; $r++) {
        $new_cols = array();
        $empty_screen_row = true;
        if ($editmode == 1) {
            $add_icon = new Cimg('images/general/closed.gif', NULL, NULL, NULL, 'pointer');
            $add_icon->addAction('onclick', "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&add_row={$r}';");
            array_push($new_cols, new Ccol($add_icon));
        }
        for ($c = 0; $c < $row['hsize']; $c++) {
            $item = array();
            if (isset($skip_field[$r][$c])) {
                continue;
            }
            $item_form = false;
            $irow = false;
            foreach ($irows as $tmprow) {
                if ($tmprow['x'] == $c && $tmprow['y'] == $r) {
                    $irow = $tmprow;
                    break;
                }
            }
            if ($irow) {
                $screenitemid = $irow['screenitemid'];
                $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 {
                $screenitemid = 0;
                $resourcetype = 0;
                $resourceid = 0;
                $width = 0;
                $height = 0;
                $colspan = 0;
                $rowspan = 0;
                $elements = 0;
                $valign = VALIGN_DEFAULT;
                $halign = HALIGN_DEFAULT;
                $style = 0;
                $url = '';
                $dynamic = 0;
            }
            if ($screenitemid > 0) {
                $empty_screen_row = false;
                $empty_screen_col[$c] = 1;
            }
            if ($editmode == 1 && $screenitemid != 0) {
                $onclick_action = "ZBX_SCREENS['" . $_REQUEST['screenid'] . "'].screen.element_onclick('screenedit.php?form=update" . url_param('screenid') . '&screenitemid=' . $screenitemid . "#form');";
                $action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitemid . '#form';
            } else {
                if ($editmode == 1 && $screenitemid == 0) {
                    $onclick_action = "ZBX_SCREENS['" . $_REQUEST['screenid'] . "'].screen.element_onclick('screenedit.php?form=update" . url_param('screenid') . '&x=' . $c . '&y=' . $r . "#form');";
                    $action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r . '#form';
                } else {
                    $action = NULL;
                }
            }
            if ($editmode == 1 && isset($_REQUEST['form']) && isset($_REQUEST['x']) && $_REQUEST['x'] == $c && isset($_REQUEST['y']) && $_REQUEST['y'] == $r) {
                // click on empty field
                $item = get_screen_item_form();
                $item_form = true;
            } else {
                if ($editmode == 1 && isset($_REQUEST['form']) && isset($_REQUEST['screenitemid']) && bccomp($_REQUEST['screenitemid'], $screenitemid) == 0) {
                    // click on element
                    $item = get_screen_item_form();
                    $item_form = true;
                } else {
                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_GRAPH) {
                        if ($editmode == 0) {
                            $action = 'charts.php?graphid=' . $resourceid . url_param('period') . url_param('stime');
                        }
                        // GRAPH & ZOOM features
                        $dom_graph_id = 'graph_' . $screenitemid . '_' . $resourceid;
                        $containerid = 'graph_cont_' . $screenitemid . '_' . $resourceid;
                        $graphDims = getGraphDims($resourceid);
                        $graphDims['graphHeight'] = $height;
                        $graphDims['width'] = $width;
                        $graph = get_graph_by_graphid($resourceid);
                        $graphid = $graph['graphid'];
                        $legend = $graph['show_legend'];
                        $graph3d = $graph['show_3d'];
                        //-------------
                        // Host feature
                        if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) {
                            $options = array('hostids' => $_REQUEST['hostid'], 'output' => array('hostid', 'host'));
                            $hosts = CHost::get($options);
                            $host = reset($hosts);
                            $options = array('graphids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'select_hosts' => API_OUTPUT_REFER, 'select_graph_items' => API_OUTPUT_EXTEND);
                            $graph = CGraph::get($options);
                            $graph = reset($graph);
                            if (count($graph['hosts']) == 1) {
                                // if items from one host we change them, or set calculated if not exist on that host
                                if ($graph['ymax_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $graph['ymax_itemid']) {
                                    $new_dinamic = get_same_graphitems_for_host(array(array('itemid' => $graph['ymax_itemid'])), $_REQUEST['hostid'], false);
                                    $new_dinamic = reset($new_dinamic);
                                    if (isset($new_dinamic['itemid']) && $new_dinamic['itemid'] > 0) {
                                        $graph['ymax_itemid'] = $new_dinamic['itemid'];
                                    } else {
                                        $graph['ymax_type'] = GRAPH_YAXIS_TYPE_CALCULATED;
                                    }
                                }
                                if ($graph['ymin_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $graph['ymin_itemid']) {
                                    $new_dinamic = get_same_graphitems_for_host(array(array('itemid' => $graph['ymin_itemid'])), $_REQUEST['hostid'], false);
                                    $new_dinamic = reset($new_dinamic);
                                    if (isset($new_dinamic['itemid']) && $new_dinamic['itemid'] > 0) {
                                        $graph['ymin_itemid'] = $new_dinamic['itemid'];
                                    } else {
                                        $graph['ymin_type'] = GRAPH_YAXIS_TYPE_CALCULATED;
                                    }
                                }
                            }
                            $url = $graph['graphtype'] == GRAPH_TYPE_PIE || $graph['graphtype'] == GRAPH_TYPE_EXPLODED ? 'chart7.php' : 'chart3.php';
                            $url = new Curl($url);
                            foreach ($graph as $name => $value) {
                                if ($name == 'width' || $name == 'height') {
                                    continue;
                                }
                                $url->setArgument($name, $value);
                            }
                            $new_items = get_same_graphitems_for_host($graph['gitems'], $_REQUEST['hostid'], false);
                            foreach ($new_items as $gitem) {
                                unset($gitem['gitemid']);
                                unset($gitem['graphid']);
                                foreach ($gitem as $name => $value) {
                                    $url->setArgument('items[' . $gitem['itemid'] . '][' . $name . ']', $value);
                                }
                            }
                            $url->setArgument('name', $host['host'] . ': ' . $graph['name']);
                            $url = $url->getUrl();
                        }
                        //-------------
                        $objData = array('id' => $resourceid, 'domid' => $dom_graph_id, 'containerid' => $containerid, 'objDims' => $graphDims, 'loadSBox' => 0, 'loadImage' => 1, 'loadScroll' => 0, 'dynamic' => 0);
                        $default = false;
                        if ($graphDims['graphtype'] == GRAPH_TYPE_PIE || $graphDims['graphtype'] == GRAPH_TYPE_EXPLODED) {
                            if ($dynamic == SCREEN_SIMPLE_ITEM || empty($url)) {
                                $url = 'chart6.php?graphid=' . $resourceid;
                                $default = true;
                            }
                            $timeline = array();
                            $timeline['period'] = $effectiveperiod;
                            $timeline['starttime'] = date('YmdHis', get_min_itemclock_by_graphid($resourceid));
                            if (isset($_REQUEST['stime'])) {
                                $timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']);
                            }
                            // $src = $url.'&width='.$width.'&height='.$height.'&legend='.$legend.'&graph3d='.$graph3d;
                            $src = $url . '&width=' . $width . '&height=' . $height . '&legend=' . $legend . '&graph3d=' . $graph3d . '&period=' . $effectiveperiod . url_param('stime');
                            $objData['src'] = $src;
                        } else {
                            if ($dynamic == SCREEN_SIMPLE_ITEM || empty($url)) {
                                $url = 'chart2.php?graphid=' . $resourceid;
                                $default = true;
                            }
                            $src = $url . '&width=' . $width . '&height=' . $height . '&period=' . $effectiveperiod . url_param('stime');
                            $timeline = array();
                            if (isset($graphid) && !is_null($graphid) && $editmode != 1) {
                                $timeline['period'] = $effectiveperiod;
                                $timeline['starttime'] = date('YmdHis', time() - ZBX_MAX_PERIOD);
                                //get_min_itemclock_by_graphid($graphid);
                                if (isset($_REQUEST['stime'])) {
                                    $timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']);
                                }
                                $objData['loadSBox'] = 1;
                            }
                            $objData['src'] = $src;
                        }
                        if ($editmode || !$default) {
                            $item = new CDiv();
                        } else {
                            $item = new CLink(null, $action);
                        }
                        $item->setAttribute('id', $containerid);
                        $item = array($item);
                        if ($editmode == 1) {
                            $item[] = BR();
                            $item[] = new CLink(S_CHANGE, $action);
                        }
                        if ($editmode == 2) {
                            insert_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
                        } else {
                            zbx_add_post_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
                        }
                    } else {
                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH) {
                            $dom_graph_id = 'graph_' . $screenitemid . '_' . $resourceid;
                            $containerid = 'graph_cont_' . $screenitemid . '_' . $resourceid;
                            $graphDims = getGraphDims();
                            $graphDims['graphHeight'] = $height;
                            $graphDims['width'] = $width;
                            $objData = array('id' => $resourceid, 'domid' => $dom_graph_id, 'containerid' => $containerid, 'objDims' => $graphDims, 'loadSBox' => 0, 'loadImage' => 1, 'loadScroll' => 0, 'dynamic' => 0);
                            // Host feature
                            if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) {
                                if ($newitemid = get_same_item_for_host($resourceid, $_REQUEST['hostid'])) {
                                    $resourceid = $newitemid;
                                } else {
                                    $resourceid = '';
                                }
                            }
                            //-------------
                            if ($editmode == 0 && !empty($resourceid)) {
                                $action = 'history.php?action=showgraph&itemid=' . $resourceid . url_param('period') . url_param('stime');
                            }
                            $timeline = array();
                            $timeline['starttime'] = date('YmdHis', time() - ZBX_MAX_PERIOD);
                            if (!zbx_empty($resourceid) && $editmode != 1) {
                                $timeline['period'] = $effectiveperiod;
                                if (isset($_REQUEST['stime'])) {
                                    $timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']);
                                }
                                $objData['loadSBox'] = 1;
                            }
                            $src = zbx_empty($resourceid) ? 'chart3.php?' : 'chart.php?itemid=' . $resourceid . '&';
                            $src .= $url . 'width=' . $width . '&height=' . $height;
                            $objData['src'] = $src;
                            if ($editmode) {
                                $item = new CDiv();
                            } else {
                                $item = new CLink(null, $action);
                            }
                            $item->setAttribute('id', $containerid);
                            $item = array($item);
                            if ($editmode == 1) {
                                $item[] = BR();
                                $item[] = new CLink(S_CHANGE, $action);
                            }
                            if ($editmode == 2) {
                                insert_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
                            } else {
                                zbx_add_post_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');');
                            }
                        } else {
                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_MAP) {
                                $image_map = new CImg("map.php?noedit=1&sysmapid={$resourceid}" . "&width={$width}&height={$height}&curtime=" . time());
                                if ($editmode == 0) {
                                    $options = array('sysmapids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'select_selements' => API_OUTPUT_EXTEND, 'nopermissions' => 1);
                                    $sysmaps = CMap::get($options);
                                    $sysmap = reset($sysmaps);
                                    $action_map = getActionMapBySysmap($sysmap);
                                    $image_map->setMap($action_map->getName());
                                    $item = array($action_map, $image_map);
                                } else {
                                    $item = $image_map;
                                    //						$item = new CLink($image_map, $action);
                                }
                            } else {
                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_PLAIN_TEXT) {
                                    // Host feature
                                    if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) {
                                        if ($newitemid = get_same_item_for_host($resourceid, $_REQUEST['hostid'])) {
                                            $resourceid = $newitemid;
                                        } else {
                                            $resourceid = 0;
                                        }
                                    }
                                    //-------------
                                    $item = array(get_screen_plaintext($resourceid, $elements, $style));
                                    if ($editmode == 1) {
                                        array_push($item, new CLink(S_CHANGE, $action));
                                    }
                                } else {
                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOSTGROUP_TRIGGERS) {
                                        $params = array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => $elements);
                                        $tr_form = S_ALL_S;
                                        if ($resourceid > 0) {
                                            $options = array('groupids' => $resourceid, 'output' => API_OUTPUT_EXTEND);
                                            $hostgroups = CHostgroup::get($options);
                                            $hostgroup = reset($hostgroups);
                                            $tr_form = new CSpan(S_GROUP . ': ' . $hostgroup['name'], 'white');
                                            $params['groupids'] = $hostgroup['groupid'];
                                        } else {
                                            $groupid = get_request('tr_groupid', CProfile::get('web.screens.tr_groupid', 0));
                                            $hostid = get_request('tr_hostid', CProfile::get('web.screens.tr_hostid', 0));
                                            CProfile::update('web.screens.tr_groupid', $groupid, PROFILE_TYPE_ID);
                                            CProfile::update('web.screens.tr_hostid', $hostid, PROFILE_TYPE_ID);
                                            $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND);
                                            $groups = CHostGroup::get($options);
                                            order_result($groups, 'name');
                                            $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND);
                                            if ($groupid > 0) {
                                                $options['groupids'] = $groupid;
                                            }
                                            $hosts = CHost::get($options);
                                            $hosts = zbx_toHash($hosts, 'hostid');
                                            order_result($hosts, 'host');
                                            if (!isset($hosts[$hostid])) {
                                                $hostid = 0;
                                            }
                                            $tr_form = new CForm();
                                            $cmbGroup = new CComboBox('tr_groupid', $groupid, 'submit()');
                                            $cmbHosts = new CComboBox('tr_hostid', $hostid, 'submit()');
                                            $cmbGroup->addItem(0, S_ALL_SMALL);
                                            $cmbHosts->addItem(0, S_ALL_SMALL);
                                            foreach ($groups as $gnum => $group) {
                                                $cmbGroup->addItem($group['groupid'], get_node_name_by_elid($group['groupid'], null, ': ') . $group['name']);
                                            }
                                            foreach ($hosts as $hnum => $host) {
                                                $cmbHosts->addItem($host['hostid'], get_node_name_by_elid($host['hostid'], null, ': ') . $host['host']);
                                            }
                                            $tr_form->addItem(array(S_GROUP . SPACE, $cmbGroup));
                                            $tr_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts));
                                            if ($groupid > 0) {
                                                $params['groupids'] = $groupid;
                                            }
                                            if ($hostid > 0) {
                                                $params['hostids'] = $hostid;
                                            }
                                        }
                                        $item = array(get_table_header(array(S_STATUS_OF_TRIGGERS_BIG, SPACE, zbx_date2str(S_SCREENS_TRIGGER_FORM_DATE_FORMAT)), $tr_form));
                                        $item[] = make_latest_issues($params);
                                        if ($editmode == 1) {
                                            array_push($item, new CLink(S_CHANGE, $action));
                                        }
                                        ///-----------------------
                                    } else {
                                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOST_TRIGGERS) {
                                            $params = array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => $elements);
                                            $tr_form = S_ALL_S;
                                            if ($resourceid > 0) {
                                                $options = array('hostids' => $resourceid, 'output' => API_OUTPUT_EXTEND);
                                                $hosts = CHost::get($options);
                                                $host = reset($hosts);
                                                $tr_form = new CSpan(S_HOST . ': ' . $host['host'], 'white');
                                                $params['hostids'] = $host['hostid'];
                                            } else {
                                                $groupid = get_request('tr_groupid', CProfile::get('web.screens.tr_groupid', 0));
                                                $hostid = get_request('tr_hostid', CProfile::get('web.screens.tr_hostid', 0));
                                                CProfile::update('web.screens.tr_groupid', $groupid, PROFILE_TYPE_ID);
                                                CProfile::update('web.screens.tr_hostid', $hostid, PROFILE_TYPE_ID);
                                                $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND);
                                                $groups = CHostGroup::get($options);
                                                order_result($groups, 'name');
                                                $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND);
                                                if ($groupid > 0) {
                                                    $options['groupids'] = $groupid;
                                                }
                                                $hosts = CHost::get($options);
                                                $hosts = zbx_toHash($hosts, 'hostid');
                                                order_result($hosts, 'host');
                                                if (!isset($hosts[$hostid])) {
                                                    $hostid = 0;
                                                }
                                                $tr_form = new CForm();
                                                $cmbGroup = new CComboBox('tr_groupid', $groupid, 'submit()');
                                                $cmbHosts = new CComboBox('tr_hostid', $hostid, 'submit()');
                                                $cmbGroup->addItem(0, S_ALL_SMALL);
                                                $cmbHosts->addItem(0, S_ALL_SMALL);
                                                foreach ($groups as $gnum => $group) {
                                                    $cmbGroup->addItem($group['groupid'], get_node_name_by_elid($group['groupid'], null, ': ') . $group['name']);
                                                }
                                                foreach ($hosts as $hnum => $host) {
                                                    $cmbHosts->addItem($host['hostid'], get_node_name_by_elid($host['hostid'], null, ': ') . $host['host']);
                                                }
                                                $tr_form->addItem(array(S_GROUP . SPACE, $cmbGroup));
                                                $tr_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts));
                                                if ($groupid > 0) {
                                                    $params['groupids'] = $groupid;
                                                }
                                                if ($hostid > 0) {
                                                    $params['hostids'] = $hostid;
                                                }
                                            }
                                            ///-----------------------
                                            $item = array(get_table_header(array(S_STATUS_OF_TRIGGERS_BIG, SPACE, zbx_date2str(S_SCREENS_TRIGGER_FORM_DATE_FORMAT)), $tr_form));
                                            $item[] = make_latest_issues($params);
                                            if ($editmode == 1) {
                                                array_push($item, new CLink(S_CHANGE, $action));
                                            }
                                        } else {
                                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SYSTEM_STATUS) {
                                                $params = array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => null, 'extAck' => 0);
                                                $item = array(get_table_header(array(S_SYSTEM_STATUS, SPACE, zbx_date2str(S_SCREENS_TRIGGER_FORM_DATE_FORMAT))));
                                                $item[] = make_system_status($params);
                                                if ($editmode == 1) {
                                                    array_push($item, new CLink(S_CHANGE, $action));
                                                }
                                            } else {
                                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOSTS_INFO) {
                                                    $item = array(new CHostsInfo($resourceid, $style));
                                                    if ($editmode == 1) {
                                                        array_push($item, new CLink(S_CHANGE, $action));
                                                    }
                                                } else {
                                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) {
                                                        $item = new CTriggersInfo($resourceid, null, $style);
                                                        $item = array($item);
                                                        if ($editmode == 1) {
                                                            array_push($item, new CLink(S_CHANGE, $action));
                                                        }
                                                    } else {
                                                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SERVER_INFO) {
                                                            //					$item = array(get_table_header(S_STATUS_OF_ZABBIX_BIG),make_status_of_zbx());
                                                            $item = array(new CServerInfo());
                                                            if ($editmode == 1) {
                                                                array_push($item, new CLink(S_CHANGE, $action));
                                                            }
                                                        } else {
                                                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_CLOCK) {
                                                                $item = new CFlashClock($width, $height, $style, $action);
                                                            } else {
                                                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SCREEN) {
                                                                    $item = array(get_screen($resourceid, 2, $effectiveperiod));
                                                                    if ($editmode == 1) {
                                                                        array_push($item, new CLink(S_CHANGE, $action));
                                                                    }
                                                                } else {
                                                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_TRIGGERS_OVERVIEW) {
                                                                        $hostids = array();
                                                                        $res = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . $resourceid);
                                                                        while ($tmp_host = DBfetch($res)) {
                                                                            $hostids[$tmp_host['hostid']] = $tmp_host['hostid'];
                                                                        }
                                                                        $item = array(get_triggers_overview($hostids, $style));
                                                                        if ($editmode == 1) {
                                                                            array_push($item, new CLink(S_CHANGE, $action));
                                                                        }
                                                                    } else {
                                                                        if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_DATA_OVERVIEW) {
                                                                            $hostids = array();
                                                                            $res = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . $resourceid);
                                                                            while ($tmp_host = DBfetch($res)) {
                                                                                $hostids[$tmp_host['hostid']] = $tmp_host['hostid'];
                                                                            }
                                                                            $item = array(get_items_data_overview($hostids, $style));
                                                                            if ($editmode == 1) {
                                                                                array_push($item, new CLink(S_CHANGE, $action));
                                                                            }
                                                                        } else {
                                                                            if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_URL) {
                                                                                $item = array(new CIFrame($url, $width, $height, "auto"));
                                                                                if ($editmode == 1) {
                                                                                    array_push($item, BR(), new CLink(S_CHANGE, $action));
                                                                                }
                                                                            } else {
                                                                                if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_ACTIONS) {
                                                                                    $item = array(get_history_of_actions($elements));
                                                                                    if ($editmode == 1) {
                                                                                        array_push($item, new CLink(S_CHANGE, $action));
                                                                                    }
                                                                                } else {
                                                                                    if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_EVENTS) {
                                                                                        $options = array('monitored' => 1, 'value' => array(TRIGGER_VALUE_TRUE, TRIGGER_VALUE_FALSE), 'limit' => $elements);
                                                                                        $hide_unknown = CProfile::get('web.events.filter.hide_unknown', 0);
                                                                                        if ($hide_unknown) {
                                                                                            $options['value'] = array(TRIGGER_VALUE_TRUE, TRIGGER_VALUE_FALSE);
                                                                                        }
                                                                                        $item = new CTableInfo(S_NO_EVENTS_FOUND);
                                                                                        $item->SetHeader(array(S_TIME, is_show_all_nodes() ? S_NODE : null, S_HOST, S_DESCRIPTION, S_VALUE, S_SEVERITY));
                                                                                        $events = getLastEvents($options);
                                                                                        foreach ($events as $enum => $event) {
                                                                                            $trigger = $event['trigger'];
                                                                                            $host = $event['host'];
                                                                                            $value = new CCol(trigger_value2str($event['value']), get_trigger_value_style($event['value']));
                                                                                            //						$row = zbx_array_merge($triggers[$row['triggerid']],$row);
                                                                                            //						if((1 == $hide_unknown) && (!event_initial_time($row,$hide_unknown))) continue;
                                                                                            $item->addRow(array(zbx_date2str(S_EVENTS_TRIGGERS_EVENTS_HISTORY_LIST_DATE_FORMAT, $event['clock']), get_node_name_by_elid($event['objectid']), $host['host'], new CLink($trigger['description'], 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid']), $value, new CCol(get_severity_description($trigger['priority']), get_severity_style($trigger['priority']))));
                                                                                        }
                                                                                        $item = array($item);
                                                                                        if ($editmode == 1) {
                                                                                            array_push($item, new CLink(S_CHANGE, $action));
                                                                                        }
                                                                                    } else {
                                                                                        $item = array(SPACE);
                                                                                        if ($editmode == 1) {
                                                                                            array_push($item, BR(), new CLink(S_CHANGE, $action));
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $str_halign = 'def';
            if ($halign == HALIGN_CENTER) {
                $str_halign = 'cntr';
            }
            if ($halign == HALIGN_LEFT) {
                $str_halign = 'left';
            }
            if ($halign == HALIGN_RIGHT) {
                $str_halign = 'right';
            }
            $str_valign = 'def';
            if ($valign == VALIGN_MIDDLE) {
                $str_valign = 'mdl';
            }
            if ($valign == VALIGN_TOP) {
                $str_valign = 'top';
            }
            if ($valign == VALIGN_BOTTOM) {
                $str_valign = 'bttm';
            }
            if ($editmode == 1 && !$item_form) {
                $item = new CDiv($item, 'draggable');
                $item->setAttribute('id', 'position_' . $r . '_' . $c);
                if ($editmode == 1) {
                    $item->setAttribute('onclick', 'javascript: ' . $onclick_action);
                }
            }
            $new_col = new CCol($item, $str_halign . '_' . $str_valign);
            if ($colspan) {
                $new_col->SetColSpan($colspan);
            }
            if ($rowspan) {
                $new_col->SetRowSpan($rowspan);
            }
            array_push($new_cols, $new_col);
        }
        if ($editmode == 1) {
            $rmv_icon = new Cimg('images/general/opened.gif', NULL, NULL, NULL, 'pointer');
            if ($empty_screen_row) {
                $rmv_row_link = "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_row={$r}';";
            } else {
                $rmv_row_link = "javascript: if(Confirm('" . S_THIS_SCREEN_ROW_NOT_EMPTY . '. ' . S_DELETE_IT_Q . "')){" . " location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_row={$r}';}";
            }
            $rmv_icon->addAction('onclick', $rmv_row_link);
            array_push($new_cols, new Ccol($rmv_icon));
        }
        $table->addRow(new CRow($new_cols));
    }
    if ($editmode == 1) {
        $add_icon = new Cimg('images/general/closed.gif', NULL, NULL, NULL, 'pointer');
        $add_icon->addAction('onclick', "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&add_row={$row['vsize']}';");
        $new_cols = array(new Ccol($add_icon));
        for ($c = 0; $c < $row['hsize']; $c++) {
            $rmv_icon = new Cimg('images/general/opened.gif', NULL, NULL, NULL, 'pointer');
            if (isset($empty_screen_col[$c])) {
                $rmv_col_link = "javascript: if(Confirm('" . S_THIS_SCREEN_COLUMN_NOT_EMPTY . '. ' . S_DELETE_IT_Q . "')){" . " location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_col={$c}';}";
            } else {
                $rmv_col_link = "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_col={$c}';";
            }
            $rmv_icon->addAction('onclick', $rmv_col_link);
            array_push($new_cols, new Ccol($rmv_icon));
        }
        array_push($new_cols, new Ccol(new Cimg('images/general/zero.gif', 'zero', 1, 1)));
        $table->addRow($new_cols);
    }
    return $table;
}
Beispiel #6
0
function get_triggers_overview($hostids, $view_style = null)
{
    $available_triggers = get_accessible_triggers(PERM_READ_ONLY, $hostids);
    if (is_null($view_style)) {
        $view_style = get_profile('web.overview.view.style', STYLE_TOP);
    }
    $table = new CTableInfo(S_NO_TRIGGERS_DEFINED);
    $result = DBselect('SELECT DISTINCT t.triggerid,t.description,t.expression,t.value,t.priority,t.lastchange,h.hostid,h.host' . ' FROM hosts h,items i,triggers t, functions f ' . ' WHERE h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid' . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' ORDER BY t.description');
    unset($triggers);
    unset($hosts);
    $triggers = array();
    while ($row = DBfetch($result)) {
        if (trigger_dependent($row['triggerid'])) {
            continue;
        }
        $row['host'] = get_node_name_by_elid($row['hostid']) . $row['host'];
        $row['description'] = expand_trigger_description_constants($row['description'], $row);
        $hosts[strtolower($row['host'])] = $row['host'];
        // A little tricky check for attempt to overwrite active trigger (value=1) with
        // inactive or active trigger with lower priority.
        if (!isset($triggers[$row['description']][$row['host']]) || ($triggers[$row['description']][$row['host']]['value'] == TRIGGER_VALUE_FALSE && $row['value'] == TRIGGER_VALUE_TRUE || ($triggers[$row['description']][$row['host']]['value'] == TRIGGER_VALUE_FALSE || $row['value'] == TRIGGER_VALUE_TRUE) && $row['priority'] > $triggers[$row['description']][$row['host']]['priority'])) {
            $triggers[$row['description']][$row['host']] = array('hostid' => $row['hostid'], 'triggerid' => $row['triggerid'], 'value' => $row['value'], 'lastchange' => $row['lastchange'], 'priority' => $row['priority']);
        }
    }
    if (!isset($hosts)) {
        return $table;
    }
    ksort($hosts);
    if ($view_style == STYLE_TOP) {
        $header = array(new CCol(S_TRIGGERS, 'center'));
        foreach ($hosts as $hostname) {
            $header = array_merge($header, array(new CImg('vtext.php?text=' . $hostname)));
        }
        $table->setHeader($header, 'vertical_header');
        foreach ($triggers as $descr => $trhosts) {
            $table_row = array(nbsp($descr));
            foreach ($hosts as $hostname) {
                $table_row = get_trigger_overview_cells($table_row, $trhosts, $hostname);
            }
            $table->AddRow($table_row);
        }
    } else {
        $header = array(new CCol(S_HOSTS, 'center'));
        foreach ($triggers as $descr => $trhosts) {
            $descr = array(new CImg('vtext.php?text=' . $descr));
            array_push($header, $descr);
        }
        $table->SetHeader($header, 'vertical_header');
        foreach ($hosts as $hostname) {
            $table_row = array(nbsp($hostname));
            foreach ($triggers as $descr => $trhosts) {
                $table_row = get_trigger_overview_cells($table_row, $trhosts, $hostname);
            }
            $table->AddRow($table_row);
        }
    }
    return $table;
}
Beispiel #7
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";
Beispiel #8
0
 $form->SetMethod('get');
 $cmbSource = new CComboBox('eventsource', $_REQUEST['eventsource'], 'submit()');
 $cmbSource->addItem(EVENT_SOURCE_TRIGGERS, S_TRIGGERS);
 $cmbSource->addItem(EVENT_SOURCE_DISCOVERY, S_DISCOVERY);
 $form->addItem(array(S_EVENT_SOURCE, SPACE, $cmbSource));
 $row_count = 0;
 $numrows = new CSpan(null, 'info');
 $numrows->addOption('name', 'numrows');
 $header = get_table_header(array(S_ACTIONS_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
 show_table_header($header, $form);
 unset($form, $cmbSource);
 /* table */
 $form = new CForm();
 $form->SetName('actions');
 $tblActions = new CTableInfo(S_NO_ACTIONS_DEFINED);
 $tblActions->SetHeader(array(array(new CCheckBox('all_items', null, 'CheckAll("' . $form->GetName() . '","all_items");'), make_sorting_link(S_NAME, 'a.name')), S_CONDITIONS, S_OPERATIONS, make_sorting_link(S_STATUS, 'a.status')));
 $db_actions = DBselect('SELECT a.* ' . ' FROM actions a' . ' WHERE a.eventsource=' . $_REQUEST['eventsource'] . ' AND ' . DBin_node('actionid') . order_by('a.name,a.status', 'a.actionid'));
 while ($action_data = DBfetch($db_actions)) {
     if (!action_accessible($action_data['actionid'], PERM_READ_WRITE)) {
         continue;
     }
     $conditions = array();
     $db_conditions = DBselect('select * from conditions where actionid=' . $action_data['actionid'] . ' order by conditiontype,conditionid');
     while ($condition_data = DBfetch($db_conditions)) {
         array_push($conditions, array(get_condition_desc($condition_data['conditiontype'], $condition_data['operator'], $condition_data['value']), BR()));
     }
     unset($db_conditions, $condition_data);
     $operations = array();
     $db_operations = DBselect('select * from operations where actionid=' . $action_data['actionid'] . ' order by operationtype,operationid');
     while ($operation_data = DBfetch($db_operations)) {
         array_push($operations, array(get_operation_desc(SHORT_DESCRITION, $operation_data), BR()));
Beispiel #9
0
    $cmbTimeZone = new CComboBox('timezone', $timezone);
    for ($i = -12; $i <= 13; $i++) {
        $cmbTimeZone->addItem($i, 'GMT' . sprintf('%+03d:00', $i));
    }
    $frmNode->addRow(S_TIME_ZONE, $cmbTimeZone);
    $frmNode->addRow(S_IP, new CTextBox('ip', $ip, 15));
    $frmNode->addRow(S_PORT, new CNumericBox('port', $port, 5));
    $frmNode->addRow(S_DO_NOT_KEEP_HISTORY_OLDER_THAN, new CNumericBox('slave_history', $slave_history, 6));
    $frmNode->addRow(S_DO_NOT_KEEP_TRENDS_OLDER_THAN, new CNumericBox('slave_trends', $slave_trends, 6));
    $frmNode->addItemToBottomRow(new CButton('save', S_SAVE));
    if (isset($_REQUEST['nodeid']) && $node_type != ZBX_NODE_LOCAL) {
        $frmNode->addItemToBottomRow(SPACE);
        $frmNode->addItemToBottomRow(new CButtonDelete('Delete selected node?', url_param('form') . url_param('nodeid')));
    }
    $frmNode->addItemToBottomRow(SPACE);
    $frmNode->addItemToBottomRow(new CButtonCancel(url_param('config')));
    $frmNode->Show();
} else {
    show_table_header(S_NODES_BIG);
    $table = new CTableInfo(S_NO_NODES_DEFINED);
    $table->SetHeader(array(make_sorting_link(S_ID, 'n.nodeid'), make_sorting_link(S_NAME, 'n.name'), make_sorting_link(S_TYPE, 'n.nodetype'), make_sorting_link(S_TIME_ZONE, 'n.timezone'), make_sorting_link(S_IP . ':' . S_PORT, 'n.ip')));
    $sql = 'SELECT n.* ' . ' FROM nodes n' . ' WHERE ' . DBcondition('n.nodeid', $available_nodes) . order_by('n.nodeid,n.name,n.nodetype,n.timezone,n.ip', 'n.masterid');
    $db_nodes = DBselect($sql);
    while ($row = DBfetch($db_nodes)) {
        $node_type = detect_node_type($row);
        $node_type_name = node_type2str($node_type);
        $table->AddRow(array($row['nodeid'], array(get_node_path($row['masterid']), new CLink($row['nodetype'] ? new CSpan($row['name'], 'bold') : $row['name'], '?&form=update&nodeid=' . $row['nodeid'], 'action')), $node_type == ZBX_NODE_LOCAL ? new CSpan($node_type_name, 'bold') : $node_type_name, new CSpan('GMT' . sprintf('%+03d:00', $row['timezone']), $row['nodetype'] ? 'bold' : null), new CSpan($row['ip'] . ':' . $row['port'], $row['nodetype'] ? 'bold' : null)));
    }
    $table->Show();
}
include_once 'include/page_footer.php';
Beispiel #10
0
                 }
             }
         }
     }
     $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["config"] == 2) {
         $arr = array();
         $table->SetHeader(array(S_NEXT_CHECK, S_DELAYED_BY, is_show_all_nodes() ? S_NODE : null, S_HOST, S_DESCRIPTION));
         while ($row = DBfetch($result)) {
             $res = calculate_item_nextcheck($row['itemid'], $row['type'], $row['delay'], $row['delay_flex'], $row['lastclock']);
             if (0 != $row['proxy_hostid']) {
                 $res['nextcheck'] = $row['lastclock'] + $res['delay'];
             }
             $diff = $now - $res['nextcheck'];
             if ($diff <= 5) {
                 continue;
             }
             array_push($arr, array($res['nextcheck'], $row['hostid'], $row['host'], item_description($row)));
         }
         $rows = 0;
         sort($arr);
         foreach ($arr as $r) {
             $rows++;
Beispiel #11
0
    echo $dstfrm;
    ?>
'];
<!--
<?php 
    foreach ($new_group as $id => $name) {
        echo 'add_var_to_opener_obj(form,"new_group[' . $id . ']","' . $name . '")' . "\r";
    }
    ?>
if(form)
{
	form.submit();
	close_window();
}
-->
</script>
<?php 
}
$form = new CForm();
$form->AddVar('dstfrm', $dstfrm);
$form->SetName('groups');
$table = new CTableInfo(S_NO_GROUPS_DEFINED);
$table->SetHeader(array(array(new CCheckBox("all_groups", NULL, "CheckAll('" . $form->GetName() . "','all_groups');"), S_NAME)));
$result = DBselect('select * from usrgrp where ' . DBin_node('usrgrpid') . ' order by name');
while ($row = DBfetch($result)) {
    $table->AddRow(array(array(new CCheckBox('new_group[' . $row['usrgrpid'] . ']', isset($new_group[$row['usrgrpid']]), NULL, $row['name']), $row['name'])));
}
$table->SetFooter(new CButton('select', S_SELECT));
$form->AddItem($table);
$form->Show();
include_once "include/page_footer.php";
Beispiel #12
0
function get_items_data_overview($hostids, $view_style = null)
{
    if (is_null($view_style)) {
        $view_style = get_profile('web.overview.view.style', STYLE_TOP);
    }
    $table = new CTableInfo(S_NO_ITEMS_DEFINED);
    COpt::profiling_start('prepare data');
    $result = DBselect('SELECT DISTINCT h.hostid, h.host,i.itemid, i.key_, i.value_type, i.lastvalue, i.units, ' . ' i.description, t.priority, i.valuemapid, t.value as tr_value, t.triggerid ' . ' FROM hosts h, items i ' . ' LEFT JOIN functions f on f.itemid=i.itemid ' . ' LEFT JOIN triggers t on t.triggerid=f.triggerid ' . ' WHERE ' . DBcondition('h.hostid', $hostids) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' ORDER BY i.description,i.itemid');
    unset($items);
    unset($hosts);
    // get rid of warnings about $triggers undefined
    $items = array();
    while ($row = DBfetch($result)) {
        $descr = item_description($row);
        $row['host'] = get_node_name_by_elid($row['hostid']) . $row['host'];
        $hosts[strtolower($row['host'])] = $row['host'];
        // A little tricky check for attempt to overwrite active trigger (value=1) with
        // inactive or active trigger with lower priority.
        if (!isset($items[$descr][$row['host']]) || ($items[$descr][$row['host']]['tr_value'] == TRIGGER_VALUE_FALSE && $row['tr_value'] == TRIGGER_VALUE_TRUE || ($items[$descr][$row['host']]['tr_value'] == TRIGGER_VALUE_FALSE || $row['tr_value'] == TRIGGER_VALUE_TRUE) && $row['priority'] > $items[$descr][$row['host']]['severity'])) {
            $items[$descr][$row['host']] = array('itemid' => $row['itemid'], 'value_type' => $row['value_type'], 'lastvalue' => $row['lastvalue'], 'units' => $row['units'], 'description' => $row['description'], 'valuemapid' => $row['valuemapid'], 'severity' => $row['priority'], 'tr_value' => $row['tr_value'], 'triggerid' => $row['triggerid']);
        }
    }
    if (!isset($hosts)) {
        return $table;
    }
    ksort($hosts);
    COpt::profiling_stop('prepare data');
    COpt::profiling_start('prepare table');
    if ($view_style == STYLE_TOP) {
        $header = array(new CCol(S_ITEMS, 'center'));
        foreach ($hosts as $hostname) {
            $header = array_merge($header, array(new CImg('vtext.php?text=' . $hostname)));
        }
        $table->SetHeader($header, 'vertical_header');
        $curr_rime = time();
        foreach ($items as $descr => $ithosts) {
            $table_row = array(nbsp($descr));
            foreach ($hosts as $hostname) {
                $table_row = get_item_data_overview_cells($table_row, $ithosts, $hostname);
            }
            $table->AddRow($table_row);
        }
    } else {
        $header = array(new CCol(S_HOSTS, 'center'));
        foreach ($items as $descr => $ithosts) {
            $header = array_merge($header, array(new CImg('vtext.php?text=' . $descr)));
        }
        $table->SetHeader($header, 'vertical_header');
        $curr_rime = time();
        foreach ($hosts as $hostname) {
            $table_row = array(nbsp($hostname));
            foreach ($items as $descr => $ithosts) {
                $table_row = get_item_data_overview_cells($table_row, $ithosts, $hostname);
            }
            $table->AddRow($table_row);
        }
    }
    COpt::profiling_stop('prepare table');
    return $table;
}
Beispiel #13
0
}
//--------------------------------------------	</PARENT SERVICES LIST>  --------------------------------------------
//---------------------------------------------- <CHILD SERVICES LIST> --------------------------------------------
if (isset($_REQUEST['cservices'])) {
    if (isset($service)) {
        $service = get_service_by_serviceid($service['serviceid']);
    }
    // update date after ACTIONS
    show_table_header(S_IT_SERVICES_BIG);
    $form = new CForm();
    $form->SetName("services");
    if (isset($service)) {
        $form->AddVar("serviceid", $service['serviceid']);
    }
    $table = new CTableInfo();
    $table->SetHeader(array(S_SERVICE, S_STATUS_CALCULATION, S_TRIGGER));
    if (isset($service)) {
        $childs = get_service_childs($service['serviceid'], 1);
        $childs_str = implode(',', $childs);
        !empty($childs_str) ? $childs_str .= ',' : '';
        $query = 'SELECT DISTINCT s.* ' . ' FROM services s ' . ' WHERE ' . DBin_node('s.serviceid') . ' AND (s.triggerid IS NULL OR ' . DBcondition('s.triggerid', $available_triggers) . ') ' . ' AND s.serviceid NOT IN (' . $childs_str . $service['serviceid'] . ') ' . ' ORDER BY s.sortorder,s.name';
    } else {
        $query = 'SELECT DISTINCT s.* ' . ' FROM services s ' . ' WHERE ' . DBin_node('s.serviceid') . ' AND (s.triggerid IS NULL OR ' . DBcondition('s.triggerid', $available_triggers) . ') ' . ' ORDER BY s.sortorder,s.name';
    }
    $db_services = DBselect($query);
    while ($db_service_data = DBfetch($db_services)) {
        $prefix = null;
        $trigger = "-";
        $description = $db_service_data["name"];
        if (isset($db_service_data["triggerid"])) {
            $trigger = expand_trigger_description($db_service_data["triggerid"]);
Beispiel #14
0
if (ZBX_DISTRIBUTED) {
    $available_nodes = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_WRITE, PERM_RES_IDS_ARRAY);
    $cmbResourceNode = new CComboBox('nodeid', $nodeid, 'submit();');
    $cmbResourceNode->AddItem(0, S_ALL_S);
    $sql = 'SELECT name,nodeid FROM nodes WHERE ' . DBcondition('nodeid', $available_nodes);
    $db_nodes = DBselect($sql);
    while ($node = DBfetch($db_nodes)) {
        $cmbResourceNode->AddItem($node['nodeid'], $node['name']);
    }
    $frmTitle->AddItem(array(S_NODE, SPACE, $cmbResourceNode));
}
show_table_header(permission2str($permission), $frmTitle);
$form = new CForm();
$form->addOption('id', 'groups');
$table = new CTableInfo(S_NO_RESOURCES_DEFINED);
$table->SetHeader(new CCol(array(new CCheckBox("all_groups", NULL, 'check_all(this.checked)'), S_NAME)));
$result = DBselect('SELECT n.name as node_name, g.name as name, g.groupid as id' . ' FROM groups g ' . ' LEFT JOIN nodes n on ' . DBid2nodeid('g.groupid') . '=n.nodeid ' . ($nodeid ? ' WHERE nodeid=' . $nodeid : '') . ' ORDER BY n.name, g.name');
$grouplist = array();
while ($row = DBfetch($result)) {
    if (isset($row['node_name'])) {
        $row['name'] = $row['node_name'] . ':' . $row['name'];
    }
    $grouplist[$row['id']] = array('name' => $row['name'], 'permission' => $permission);
    $table->addRow(new CCol(array(new CCheckBox('groups[' . $row['id'] . ']', NULL, NULL, $row['id']), $row['name'])));
}
insert_js('var grouplist = ' . zbx_jsvalue($grouplist) . ';');
$button = new CButton('select', S_SELECT, 'add_groups("' . $dstfrm . '")');
$button->setType('button');
$table->setFooter(new CCol($button, 'right'));
$form->addItem($table);
$form->show();
Beispiel #15
0
CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR);
$options = array('groups' => array('real_hosts' => true, 'with_httptests' => true), 'hosts' => array('with_monitored_items' => true, 'with_httptests' => true), 'hostid' => getRequest('hostid'), 'groupid' => getRequest('groupid'));
$pageFilter = new CPageFilter($options);
$_REQUEST['groupid'] = $pageFilter->groupid;
$_REQUEST['hostid'] = $pageFilter->hostid;
$r_form = new CForm('get');
$r_form->addVar('fullscreen', $_REQUEST['fullscreen']);
$r_form->addItem(array(_('Group') . SPACE, $pageFilter->getGroupsCB()));
$r_form->addItem(array(SPACE . _('Host') . SPACE, $pageFilter->getHostsCB()));
$httpmon_wdgt = new CWidget();
$httpmon_wdgt->addPageHeader(_('STATUS OF WEB MONITORING'), get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen'])));
$httpmon_wdgt->addHeader(_('Web scenarios'), $r_form);
$httpmon_wdgt->addHeaderRowNumber();
// TABLE
$table = new CTableInfo(_('No web scenarios found.'));
$table->SetHeader(array($_REQUEST['hostid'] == 0 ? make_sorting_header(_('Host'), 'hostname', $sortField, $sortOrder) : null, make_sorting_header(_('Name'), 'name', $sortField, $sortOrder), _('Number of steps'), _('Last check'), _('Status')));
$paging = null;
if ($pageFilter->hostsSelected) {
    $options = array('output' => array('httptestid', 'name', 'hostid'), 'selectHosts' => array('name', 'status'), 'selectSteps' => API_OUTPUT_COUNT, 'templated' => false, 'preservekeys' => true, 'filter' => array('status' => HTTPTEST_STATUS_ACTIVE), 'limit' => $config['search_limit'] + 1);
    if ($pageFilter->hostid > 0) {
        $options['hostids'] = $pageFilter->hostid;
    } elseif ($pageFilter->groupid > 0) {
        $options['groupids'] = $pageFilter->groupid;
    }
    $httpTests = API::HttpTest()->get($options);
    foreach ($httpTests as &$httpTest) {
        $httpTest['host'] = reset($httpTest['hosts']);
        $httpTest['hostname'] = $httpTest['host']['name'];
        unset($httpTest['hosts']);
    }
    unset($httpTest);
Beispiel #16
0
                     $imagetype = S_UNKNOWN;
                 }
             }
             $name = new CLink($row['name'], 'config.php?form=update' . url_param('config') . '&imageid=' . $row['imageid'], 'action');
             $table->addRow(array($name, $imagetype, $actions = new CLink(new CImg('image.php?height=24&imageid=' . $row['imageid'], 'no image', NULL), 'image.php?imageid=' . $row['imageid'])));
         }
         $table->show();
     }
 } elseif ($_REQUEST['config'] == 6) {
     echo SBR;
     if (isset($_REQUEST['form'])) {
         insert_value_mapping_form();
     } else {
         show_table_header(S_VALUE_MAPPING_BIG);
         $table = new CTableInfo();
         $table->SetHeader(array(S_NAME, S_VALUE_MAP));
         $db_valuemaps = DBselect('SELECT * FROM valuemaps WHERE ' . DBin_node('valuemapid'));
         while ($db_valuemap = DBfetch($db_valuemaps)) {
             $mappings_row = array();
             $db_maps = DBselect('SELECT * FROM mappings' . ' WHERE valuemapid=' . $db_valuemap['valuemapid']);
             while ($db_map = DBfetch($db_maps)) {
                 array_push($mappings_row, $db_map['value'], SPACE . RARR . SPACE, $db_map['newvalue'], BR());
             }
             $table->AddRow(array(new CLink($db_valuemap['name'], 'config.php?form=update&' . 'valuemapid=' . $db_valuemap['valuemapid'] . url_param('config'), 'action'), empty($mappings_row) ? SPACE : $mappings_row));
         }
         $table->Show();
     }
 } else {
     if ($_REQUEST['config'] == 10) {
         if (isset($_REQUEST["form"])) {
             $frmRegExp = new CForm('config.php', 'post');
Beispiel #17
0
}
navigation_bar_calc();
// Header
$text = array(S_DETAILS_OF_SCENARIO_BIG . ' / ', bold($httptest_data['name']), ' [' . date(S_DATE_FORMAT_YMDHMS, $httptest_data['lastcheck']) . ']');
$url = '?httptestid=' . $_REQUEST['httptestid'] . '&fullscreen=' . ($_REQUEST['fullscreen'] ? '0' : '1');
$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 . "';"));
$icon_tab = new CTable();
$icon_tab->AddRow(array($fs_icon, SPACE, $text));
$text = $icon_tab;
show_table_header($text, new CLink(S_CANCEL, 'httpmon.php' . url_param('groupid') . url_param('hostid')));
//-------------
// TABLE
$table = new CTableInfo();
$table->SetHeader(array(S_STEP, S_SPEED, S_RESPONSE_TIME, S_RESPONSE_CODE, S_STATUS));
$items = array();
$total_data = array(HTTPSTEP_ITEM_TYPE_IN => null, HTTPSTEP_ITEM_TYPE_TIME => null);
$color = array('current' => 0, 0 => array('next' => '1'), 1 => array('color' => 'Red', 'next' => '2'), 2 => array('color' => 'Dark Green', 'next' => '3'), 3 => array('color' => 'Blue', 'next' => '4'), 4 => array('color' => 'Dark Yellow', 'next' => '5'), 5 => array('color' => 'Cyan', 'next' => '6'), 6 => array('color' => 'Gray', 'next' => '7'), 7 => array('color' => 'Dark Red', 'next' => '8'), 8 => array('color' => 'Green', 'next' => '9'), 9 => array('color' => 'Dark Blue', 'next' => '10'), 10 => array('color' => 'Yellow', 'next' => '11'), 11 => array('color' => 'Black', 'next' => '1'));
$db_httpsteps = DBselect('select * from httpstep where httptestid=' . $httptest_data['httptestid'] . ' order by no');
while ($httpstep_data = DBfetch($db_httpsteps)) {
    $status['msg'] = S_OK_BIG;
    $status['style'] = 'enabled';
    if (HTTPTEST_STATE_BUSY == $httptest_data['curstate']) {
        if ($httptest_data['curstep'] == $httpstep_data['no']) {
            $status['msg'] = S_IN_PROGRESS;
            $status['style'] = 'unknown';
            $status['skip'] = true;
        } else {
            if ($httptest_data['curstep'] < $httpstep_data['no']) {
                $status['msg'] = S_UNKNOWN;
Beispiel #18
0
$form->SetMethod('get');
if (!isset($_REQUEST["form"])) {
    $form->AddItem(new CButton('form', S_CREATE_RULE));
}
show_table_header(S_CONFIGURATION_OF_DISCOVERY_BIG, $form);
echo SBR;
if (isset($_REQUEST["form"])) {
    /* form */
    insert_drule_form();
} else {
    show_table_header(S_DISCOVERY_BIG);
    /* table */
    $form = new CForm();
    $form->SetName('frmdrules');
    $tblDiscovery = new CTableInfo(S_NO_DISCOVERY_RULES_DEFINED);
    $tblDiscovery->SetHeader(array(array(new CCheckBox('all_drules', null, "CheckAll('" . $form->GetName() . "','all_drules');"), make_sorting_link(S_NAME, 'd.name')), make_sorting_link(S_IP_RANGE, 'd.iprange'), make_sorting_link(S_DELAY, 'd.delay'), S_CHECKS, S_STATUS));
    $db_rules = DBselect('SELECT d.* ' . ' FROM drules d' . ' WHERE ' . DBin_node('druleid') . order_by('d.name,d.iprange,d.delay', 'd.druleid'));
    while ($rule_data = DBfetch($db_rules)) {
        $cheks = array();
        $db_checks = DBselect("select * from dchecks where druleid=" . $rule_data["druleid"] . " order by type,druleid");
        while ($check_data = DBfetch($db_checks)) {
            $cheks[] = discovery_check_type2str($check_data['type']);
        }
        $status = new CCol(new CLink(discovery_status2str($rule_data["status"]), '?g_druleid%5B%5D=' . $rule_data['druleid'] . ($rule_data["status"] == DRULE_STATUS_ACTIVE ? '&group_disable=1' : '&group_enable=1'), discovery_status2style($rule_data["status"])));
        $description = array();
        if ($rule_data["proxy_hostid"]) {
            $proxy = get_host_by_hostid($rule_data["proxy_hostid"]);
            array_push($description, $proxy["host"], ":");
        }
        array_push($description, new CLink($rule_data['name'], "?form=update&druleid=" . $rule_data['druleid'], 'action'));
        $drule = new CCol(array(new CCheckBox('g_druleid[' . $rule_data["druleid"] . ']', null, null, $rule_data["druleid"]), SPACE, $description));
Beispiel #19
0
function get_act_operations_form($action = null)
{
    $tblOper = new CTableInfo(S_NO_OPERATIONS_DEFINED);
    $tblOper->addOption('style', 'background-color: #CCC;');
    if (isset($_REQUEST['actionid']) && empty($action)) {
        $action = get_action_by_actionid($_REQUEST['actionid']);
    }
    $operations = get_request('operations', array());
    if (isset($_REQUEST['actionid']) && !isset($_REQUEST['form_refresh'])) {
        $eventsource = $action['eventsource'];
        $evaltype = $action['evaltype'];
        $esc_period = $action['esc_period'];
        /* prepate operations */
        $db_operations = DBselect('SELECT * ' . ' FROM operations' . ' WHERE actionid=' . $_REQUEST['actionid'] . ' ORDER BY esc_step_from,operationtype,object,operationid');
        while ($operation_data = DBfetch($db_operations)) {
            $operation_data = array('operationtype' => $operation_data['operationtype'], 'operationid' => $operation_data['operationid'], 'object' => $operation_data['object'], 'objectid' => $operation_data['objectid'], 'shortdata' => $operation_data['shortdata'], 'longdata' => $operation_data['longdata'], 'esc_period' => $operation_data['esc_period'], 'esc_step_from' => $operation_data['esc_step_from'], 'esc_step_to' => $operation_data['esc_step_to'], 'default_msg' => $operation_data['default_msg'], 'evaltype' => $operation_data['evaltype']);
            $operation_data['opconditions'] = array();
            $sql = 'SELECT * FROM opconditions WHERE operationid=' . $operation_data['operationid'];
            $db_opconds = DBselect($sql);
            while ($db_opcond = DBfetch($db_opconds)) {
                $operation_data['opconditions'][] = $db_opcond;
            }
            if (str_in_array($operation_data, $operations)) {
                continue;
            }
            array_push($operations, $operation_data);
        }
        unset($db_operations, $operation_data);
    } else {
        $eventsource = get_request('eventsource');
        $evaltype = get_request('evaltype');
        $esc_period = get_request('esc_period');
    }
    $esc_step_from = array();
    foreach ($operations as $key => $operation) {
        $esc_step_from[$key] = $operation['esc_step_from'];
    }
    array_multisort($esc_step_from, SORT_ASC, $operations);
    $tblOper->SetHeader(array(new CCheckBox('all_operations', null, 'CheckAll("' . S_ACTION . '","all_operations","g_operationid");'), isset($_REQUEST['escalation']) ? S_STEPS : null, S_DETAILS, isset($_REQUEST['escalation']) ? S_PERIOD . ' (' . S_SEC_SMALL . ')' : null, isset($_REQUEST['escalation']) ? S_DELAY : null, S_ACTION));
    $allowed_operations = get_operations_by_eventsource($eventsource);
    zbx_rksort($operations);
    $delay = count_operations_delay($operations, $esc_period);
    foreach ($operations as $id => $val) {
        if (!str_in_array($val['operationtype'], $allowed_operations)) {
            continue;
        }
        if (!isset($val['default_msg'])) {
            $val['default_msg'] = 0;
        }
        if (!isset($val['opconditions'])) {
            $val['opconditions'] = array();
        }
        $oper_details = new CSpan(get_operation_desc(SHORT_DESCRITION, $val));
        $oper_details->SetHint(nl2br(get_operation_desc(LONG_DESCRITION, $val)));
        $esc_steps_txt = null;
        $esc_period_txt = null;
        $esc_delay_txt = null;
        if ($val['esc_step_from'] < 1) {
            $val['esc_step_from'] = 1;
        }
        if (isset($_REQUEST['escalation'])) {
            $esc_steps_txt = $val['esc_step_from'] . ' - ' . $val['esc_step_to'];
            $esc_period_txt = $val['esc_period'] ? $val['esc_period'] : S_DEFAULT;
            $esc_delay_txt = $delay[$val['esc_step_from']] ? convert_units($delay[$val['esc_step_from']], 'uptime') : S_AT_MOMENT;
        }
        $tblOper->addRow(array(new CCheckBox("g_operationid[]", 'no', null, $id), $esc_steps_txt, $oper_details, $esc_period_txt, $esc_delay_txt, new CButton('edit_operationid[' . $id . ']', S_EDIT)));
        $tblOper->addItem(new CVar('operations[' . $id . '][operationtype]', $val['operationtype']));
        $tblOper->addItem(new CVar('operations[' . $id . '][object]', $val['object']));
        $tblOper->addItem(new CVar('operations[' . $id . '][objectid]', $val['objectid']));
        $tblOper->addItem(new CVar('operations[' . $id . '][shortdata]', $val['shortdata']));
        $tblOper->addItem(new CVar('operations[' . $id . '][longdata]', $val['longdata']));
        $tblOper->addItem(new CVar('operations[' . $id . '][esc_period]', $val['esc_period']));
        $tblOper->addItem(new CVar('operations[' . $id . '][esc_step_from]', $val['esc_step_from']));
        $tblOper->addItem(new CVar('operations[' . $id . '][esc_step_to]', $val['esc_step_to']));
        $tblOper->addItem(new CVar('operations[' . $id . '][default_msg]', $val['default_msg']));
        $tblOper->addItem(new CVar('operations[' . $id . '][evaltype]', $val['evaltype']));
        foreach ($val['opconditions'] as $opcondid => $opcond) {
            foreach ($opcond as $field => $value) {
                $tblOper->addItem(new CVar('operations[' . $id . '][opconditions][' . $opcondid . '][' . $field . ']', $value));
            }
        }
    }
    unset($operations);
    $tblOperFooter = new CTableInfo(null);
    $oper_buttons = array();
    if (!isset($_REQUEST['new_operation'])) {
        $oper_buttons[] = new CButton('new_operation', S_NEW);
    }
    if ($tblOper->ItemsCount() > 0) {
        $oper_buttons[] = new CButton('del_operation', S_DELETE_SELECTED);
    }
    $td = new CCol($oper_buttons);
    $td->addOption('colspan', isset($_REQUEST['escalation']) ? 6 : 3);
    $td->addOption('style', 'text-align: right;');
    $tblOperFooter->SetFooter($td);
    // end of condition list preparation
    return array($tblOper, $tblOperFooter);
}
Beispiel #20
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;
}
Beispiel #21
0
            $time = mktime(0, 0, 0, 1, 1, $year);
            $wd = date("w", $time);
            $wd = $wd == 0 ? 6 : $wd - 1;
            return $time + ($w * 7 - $wd) * 24 * 3600;
        }
        function format_time($t)
        {
            return date("d M Y H:i", $t);
        }
        function format_time2($t)
        {
            return format_time($t);
        }
        break;
}
$table->SetHeader($header);
for ($t = $from; $t <= $to; $t++) {
    if (($start = get_time($t)) > time()) {
        break;
    }
    if (($end = get_time($t + 1)) > time()) {
        $end = time();
    }
    $stat = calculate_service_availability($service["serviceid"], $start, $end);
    $ok = new CSpan(sprintf("%dd %dh %dm", $stat["ok_time"] / (24 * 3600), $stat["ok_time"] % (24 * 3600) / 3600, $stat["ok_time"] % 3600 / 60), "off");
    $problems = new CSpan(sprintf("%dd %dh %dm", $stat["problem_time"] / (24 * 3600), $stat["problem_time"] % (24 * 3600) / 3600, $stat["problem_time"] % 3600 / 60), "on");
    $downtime = sprintf("%dd %dh %dm", $stat["downtime_time"] / (24 * 3600), $stat["downtime_time"] % (24 * 3600) / 3600, $stat["downtime_time"] % 3600 / 60);
    $percentage = new CSpan(sprintf("%2.2f%%", $stat["ok"]), "off");
    $table->AddRow(array(format_time($start), format_time2($end), $ok, $problems, $downtime, $percentage, $service["showsla"] == 1 ? new CSpan($service["goodsla"], $stat["ok"] >= $service["goodsla"] ? "off" : "on") : "-"));
}
$table->Show();
Beispiel #22
0
     case ITEM_VALUE_TYPE_FLOAT:
         $h_table = "history";
         break;
     case ITEM_VALUE_TYPE_UINT64:
         $h_table = "history_uint";
         break;
     case ITEM_VALUE_TYPE_TEXT:
         $h_table = "history_text";
         break;
     default:
         $h_table = "history_str";
 }
 $result = DBselect('SELECT h.clock,h.value,i.valuemapid ' . ' FROM ' . $h_table . ' h, items i ' . ' WHERE h.itemid=i.itemid ' . ' AND i.itemid=' . $_REQUEST['itemid'] . $cond_clock . ' ORDER BY clock desc', $limit);
 if (!isset($_REQUEST["plaintext"])) {
     $table = new CTableInfo();
     $table->SetHeader(array(S_TIMESTAMP, S_VALUE));
     $table->AddOption('id', 'graph');
     $table->ShowStart();
     // to solve memory leak we call 'Show' method by steps
 } else {
     echo "<pre>\n";
 }
 COpt::profiling_start("history");
 while ($row = DBfetch($result)) {
     if ($DB['TYPE'] == "ORACLE" && $item_type == ITEM_VALUE_TYPE_TEXT) {
         if (isset($row["value"])) {
             $row["value"] = $row["value"]->load();
         } else {
             $row["value"] = "";
         }
     }
Beispiel #23
0
            $time = mktime(0, 0, 0, 1, 1, $year);
            $wd = date("w", $time);
            $wd = $wd == 0 ? 6 : $wd - 1;
            return $time + ($w * 7 - $wd) * 24 * 3600;
        }
        function format_time($t)
        {
            return date("d M Y H:i", $t);
        }
        function format_time2($t)
        {
            return format_time($t);
        }
        break;
}
$table->SetHeader($header, "vertical_header");
for ($t = $from; $t <= $to; $t++) {
    if (($start = get_time($t)) > time()) {
        break;
    }
    if (($end = get_time($t + 1)) > time()) {
        $end = time();
    }
    $table_row = array(format_time($start), format_time2($end));
    foreach ($users as $userid => $alias) {
        $all = 0;
        $cnt_by_type = array();
        foreach ($media_types as $mediatypeid => $description) {
            $cnt_data = DBfetch(DBselect("select count(*) as cnt from alerts a " . " where a.userid=" . $userid . " and a.mediatypeid=" . $mediatypeid . " and clock>{$start} and clock<{$end} "));
            if (!$cnt_data) {
                $cnt_data = 0;
Beispiel #24
0
$r_form->addVar('fullscreen', $_REQUEST['fullscreen']);
$r_form->addItem(array(S_GROUP . SPACE, $pageFilter->getGroupsCB(true)));
$r_form->addItem(array(SPACE . S_HOST . SPACE, $pageFilter->getHostsCB(true)));
$httpmon_wdgt->addHeader(S_WEB_CHECKS_BIG, $r_form);
$httpmon_wdgt->addItem(SPACE);
// TABLE
$form = new CForm(null, 'get');
$form->setName('scenarios');
$form->addVar('hostid', $_REQUEST['hostid']);
if (isset($show_all_apps)) {
    $link = new CLink(new CImg('images/general/opened.gif'), '?close=1' . url_param('groupid') . url_param('hostid'));
} else {
    $link = new CLink(new CImg('images/general/closed.gif'), '?open=1' . url_param('groupid') . url_param('hostid'));
}
$table = new CTableInfo();
$table->SetHeader(array(is_show_all_nodes() ? make_sorting_header(S_NODE, 'h.hostid') : null, $_REQUEST['hostid'] == 0 ? make_sorting_header(S_HOST, 'h.host') : NULL, make_sorting_header(array($link, SPACE, S_NAME), 'wt.name'), S_NUMBER_OF_STEPS, S_STATE, S_LAST_CHECK, S_STATUS));
$any_app_exist = false;
$db_apps = array();
$db_appids = array();
$sql_where = '';
if ($_REQUEST['hostid'] > 0) {
    $sql_where = ' AND h.hostid=' . $_REQUEST['hostid'];
}
$sql = 'SELECT DISTINCT h.host,h.hostid,a.* ' . ' FROM applications a,hosts h ' . ' WHERE a.hostid=h.hostid ' . $sql_where . ' AND ' . DBcondition('h.hostid', $available_hosts) . order_by('a.applicationid,h.host,h.hostid', 'a.name');
//SDI($sql);
$db_app_res = DBselect($sql);
while ($db_app = DBfetch($db_app_res)) {
    $db_app['scenarios_cnt'] = 0;
    $db_apps[$db_app['applicationid']] = $db_app;
    $db_appids[$db_app['applicationid']] = $db_app['applicationid'];
}
Beispiel #25
0
/* limit opened application count */
while (count($_REQUEST['applications']) > 25) {
    array_shift($_REQUEST['applications']);
}
update_profile('web.latest.applications', $_REQUEST['applications'], PROFILE_TYPE_ARRAY_ID);
if (isset($show_all_apps)) {
    $url = '?close=1' . 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' . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select');
    $link = new CLink(new CImg('images/general/closed.gif'), $url);
    //		$link = new CLink(new CImg('images/general/closed.gif'),$url,null,"javascript: return updater.onetime_update('".ZBX_PAGE_MAIN_HAT."','".$url."');");
}
$table = new CTableInfo();
$table->SetHeader(array(is_show_subnodes() ? make_sorting_link(S_NODE, 'h.hostid') : null, $_REQUEST['hostid'] == 0 ? make_sorting_link(S_HOST, 'h.host') : NULL, array($link, SPACE, make_sorting_link(S_DESCRIPTION, 'i.description')), make_sorting_link(S_LAST_CHECK, 'i.lastclock'), S_LAST_VALUE, S_CHANGE, S_HISTORY));
//	$table->ShowStart();
$db_apps = array();
$db_appids = array();
$sql_where .= $_REQUEST['hostid'] > 0 ? ' AND h.hostid=' . $_REQUEST['hostid'] : '';
$sql = 'SELECT DISTINCT h.host,h.hostid, a.* ' . ' FROM applications a, hosts h ' . $sql_from . ' WHERE a.hostid=h.hostid' . $sql_where . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND h.status=' . HOST_STATUS_MONITORED . order_by('h.host,h.hostid', 'a.name,a.applicationid');
//SDI($sql);
$db_app_res = DBselect($sql);
while ($db_app = DBfetch($db_app_res)) {
    $db_app['item_cnt'] = 0;
    $db_apps[$db_app['applicationid']] = $db_app;
    $db_appids[$db_app['applicationid']] = $db_app['applicationid'];
}
$tab_rows = array();
$sql = 'SELECT DISTINCT i.*, ia.applicationid ' . ' FROM items i,items_applications ia' . ' WHERE ' . DBcondition('ia.applicationid', $db_appids) . ' AND i.itemid=ia.itemid AND i.lastvalue IS NOT NULL' . ' AND (i.status=' . ITEM_STATUS_ACTIVE . ' OR i.status=' . ITEM_STATUS_NOTSUPPORTED . ')' . order_by('i.description,i.itemid,i.lastclock');
//SDI($sql);
Beispiel #26
0
        $table->setFooter(new CCol(array($goBox, $goButton)));
        $form->addItem($table);
        $form->show();
    }
} else {
    if (isset($_REQUEST["form"])) {
        insert_slideshow_form();
    } else {
        $form = new CForm();
        $form->setName('frm_shows');
        $numrows = new CSpan(null, 'info');
        $numrows->setAttribute('name', 'numrows');
        $header = get_table_header(array(S_SLIDESHOWS_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
        show_table_header($header);
        $table = new CTableInfo(S_NO_SLIDESHOWS_DEFINED);
        $table->SetHeader(array(new CCheckBox('all_shows', NULL, "checkAll('" . $form->getName() . "','all_shows','shows');"), make_sorting_link(S_NAME, 's.name'), make_sorting_link(S_DELAY, 's.delay'), make_sorting_link(S_COUNT_OF_SLIDES, 'cnt')));
        $db_slides = DBselect('SELECT s.slideshowid, s.name, s.delay, count(*) as cnt ' . ' FROM slideshows s ' . ' left join slides sl on sl.slideshowid=s.slideshowid ' . ' WHERE ' . DBin_node('s.slideshowid') . ' GROUP BY s.slideshowid,s.name,s.delay ' . order_by('s.name,s.delay,cnt', 's.slideshowid'));
        while ($slide_data = DBfetch($db_slides)) {
            if (!slideshow_accessible($slide_data['slideshowid'], PERM_READ_WRITE)) {
                continue;
            }
            $table->AddRow(array(new CCheckBox('shows[' . $slide_data['slideshowid'] . ']', NULL, NULL, $slide_data['slideshowid']), new CLink($slide_data['name'], '?config=1&form=update&slideshowid=' . $slide_data['slideshowid'], 'action'), $slide_data['delay'], $slide_data['cnt']));
        }
        //----- GO ------
        $goBox = new CComboBox('go');
        $goBox->addItem('delete', S_DELETE_SELECTED);
        // goButton name is necessary!!!
        $goButton = new CButton('goButton', S_GO . ' (0)');
        $goButton->setAttribute('id', 'goButton');
        zbx_add_post_js('chkbxRange.pageGoName = "shows";');
        $table->setFooter(new CCol(array($goBox, $goButton)));
Beispiel #27
0
$form = new CForm();
$form->SetMethod('get');
$form->AddItem(new CButton("form", S_CREATE_MAP));
show_table_header(S_CONFIGURATION_OF_NETWORK_MAPS, $form);
echo SBR;
if (isset($_REQUEST["form"])) {
    insert_map_form();
} else {
    $form = new CForm();
    $form->setName('frm_maps');
    $numrows = new CSpan(null, 'info');
    $numrows->setAttribute('name', 'numrows');
    $header = get_table_header(array(S_MAPS_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
    show_table_header($header);
    $table = new CTableInfo(S_NO_MAPS_DEFINED);
    $table->SetHeader(array(new CCheckBox('all_maps', NULL, "checkAll('" . $form->getName() . "','all_maps','maps');"), make_sorting_link(S_NAME, 'sm.name'), make_sorting_link(S_WIDTH, 'sm.width'), make_sorting_link(S_HEIGHT, 'sm.height'), S_MAP));
    $result = DBselect('SELECT sm.sysmapid,sm.name,sm.width,sm.height ' . ' FROM sysmaps sm' . ' WHERE ' . DBin_node('sm.sysmapid') . order_by('sm.name,sm.width,sm.height', 'sm.sysmapid'));
    while ($row = DBfetch($result)) {
        if (!sysmap_accessible($row["sysmapid"], PERM_READ_WRITE)) {
            continue;
        }
        $table->AddRow(array(new CCheckBox('maps[' . $row['sysmapid'] . ']', NULL, NULL, $row['sysmapid']), new CLink($row["name"], "sysmaps.php?form=update" . "&sysmapid=" . $row["sysmapid"] . "#form", 'action'), $row["width"], $row["height"], new CLink(S_EDIT, "sysmap.php?sysmapid=" . $row["sysmapid"])));
    }
    //----- GO ------
    $goBox = new CComboBox('go');
    $goBox->addItem('delete', S_DELETE_SELECTED);
    // goButton name is necessary!!!
    $goButton = new CButton('goButton', S_GO . ' (0)');
    $goButton->setAttribute('id', 'goButton');
    zbx_add_post_js('chkbxRange.pageGoName = "maps";');
    $table->setFooter(new CCol(array($goBox, $goButton)));
Beispiel #28
0
                continue;
            }
            $table->AddRow(array(new CLink($row["name"], "?config=0&form=update&screenid=" . $row["screenid"], 'action'), $row["hsize"] . " x " . $row["vsize"], new CLink(S_EDIT, "screenedit.php?screenid=" . $row["screenid"])));
            $row_count++;
        }
        $table->Show();
    }
} else {
    if (isset($_REQUEST["form"])) {
        insert_slideshow_form();
    } else {
        $row_count = 0;
        $numrows = new CSpan(null, 'info');
        $numrows->addOption('name', 'numrows');
        $header = get_table_header(array(S_SLIDESHOWS_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
        show_table_header($header);
        $table = new CTableInfo(S_NO_SLIDESHOWS_DEFINED);
        $table->SetHeader(array(make_sorting_link(S_NAME, 's.name'), make_sorting_link(S_DELAY, 's.delay'), make_sorting_link(S_COUNT_OF_SLIDES, 'cnt')));
        $db_slides = DBselect('SELECT s.slideshowid, s.name, s.delay, count(*) as cnt ' . ' FROM slideshows s ' . ' left join slides sl on sl.slideshowid=s.slideshowid ' . ' WHERE ' . DBin_node('s.slideshowid') . ' GROUP BY s.slideshowid,s.name,s.delay ' . order_by('s.name,s.delay,cnt', 's.slideshowid'));
        while ($slide_data = DBfetch($db_slides)) {
            if (!slideshow_accessible($slide_data['slideshowid'], PERM_READ_WRITE)) {
                continue;
            }
            $table->AddRow(array(new CLink($slide_data['name'], '?config=1&form=update&slideshowid=' . $slide_data['slideshowid'], 'action'), $slide_data['delay'], $slide_data['cnt']));
            $row_count++;
        }
        $table->Show();
    }
}
zbx_add_post_js('insert_in_element("numrows","' . $row_count . '");');
include_once "include/page_footer.php";
Beispiel #29
0
$options = array('groups' => array('real_hosts' => true, 'with_httptests' => true), 'hosts' => array('with_monitored_items' => true, 'with_httptests' => true), 'hostid' => get_request('hostid', null), 'groupid' => get_request('groupid', null));
$pageFilter = new CPageFilter($options);
$_REQUEST['groupid'] = $pageFilter->groupid;
$_REQUEST['hostid'] = $pageFilter->hostid;
$displayNodes = is_array(get_current_nodeid()) && $pageFilter->groupid == 0 && $pageFilter->hostid == 0;
$r_form = new CForm('get');
$r_form->addVar('fullscreen', $_REQUEST['fullscreen']);
$r_form->addItem(array(_('Group') . SPACE, $pageFilter->getGroupsCB(true)));
$r_form->addItem(array(SPACE . _('Host') . SPACE, $pageFilter->getHostsCB(true)));
$httpmon_wdgt = new CWidget();
$httpmon_wdgt->addPageHeader(_('STATUS OF WEB MONITORING'), get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen'])));
$httpmon_wdgt->addHeader(_('Web scenarios'), $r_form);
$httpmon_wdgt->addHeaderRowNumber();
// TABLE
$table = new CTableInfo(_('No web scenarios found.'));
$table->SetHeader(array($displayNodes ? _('Node') : null, $_REQUEST['hostid'] == 0 ? make_sorting_header(_('Host'), 'hostname') : null, make_sorting_header(_('Name'), 'name'), _('Number of steps'), _('Last check'), _('Status')));
$paging = null;
if ($pageFilter->hostsSelected) {
    $options = array('output' => array('httptestid'), 'templated' => false, 'filter' => array('status' => HTTPTEST_STATUS_ACTIVE), 'limit' => $config['search_limit'] + 1);
    if ($pageFilter->hostid > 0) {
        $options['hostids'] = $pageFilter->hostid;
    } elseif ($pageFilter->groupid > 0) {
        $options['groupids'] = $pageFilter->groupid;
    }
    $httpTests = API::HttpTest()->get($options);
    $paging = getPagingLine($httpTests);
    $httpTests = API::HttpTest()->get(array('httptestids' => zbx_objectValues($httpTests, 'httptestid'), 'preservekeys' => true, 'output' => API_OUTPUT_EXTEND, 'selectHosts' => array('name', 'status'), 'selectSteps' => API_OUTPUT_COUNT));
    foreach ($httpTests as &$httpTest) {
        $httpTest['host'] = reset($httpTest['hosts']);
        $httpTest['hostname'] = $httpTest['host']['name'];
        unset($httpTest['hosts']);
Beispiel #30
0
         while ($row = DBfetch($result)) {
             $row['name'] = $row['name'] . ':' . discovery_check2str($row['type'], $row['snmp_community'], $row['key_'], $row['ports']);
             $name = new CLink($row["name"], "#", "action");
             if (isset($_REQUEST['reference']) && $_REQUEST['reference'] == 'dashboard') {
                 $action = get_window_opener($dstfrm, $dstfld1, $srcfld2) . get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) . "window.opener.setTimeout('add2favorites();', 1000);";
             } else {
                 $action = get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : '');
             }
             $name->SetAction($action . " close_window(); return false;");
             $table->addRow($name);
         }
         $table->Show();
     } else {
         if ($srctbl == "proxies") {
             $table = new CTableInfo(S_NO_DISCOVERY_RULES_DEFINED);
             $table->SetHeader(S_NAME);
             $result = DBselect('SELECT DISTINCT hostid,host ' . ' FROM hosts' . ' WHERE ' . DBin_node('hostid', $nodeid) . ' AND status=' . HOST_STATUS_PROXY . ' ORDER BY host,hostid');
             while ($row = DBfetch($result)) {
                 $name = new CLink($row["host"], "#", "action");
                 if (isset($_REQUEST['reference']) && $_REQUEST['reference'] == 'dashboard') {
                     $action = get_window_opener($dstfrm, $dstfld1, $srcfld2) . get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) . "window.opener.setTimeout('add2favorites();', 1000);";
                 } else {
                     $action = get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : '');
                 }
                 $name->SetAction($action . " close_window(); return false;");
                 $table->addRow($name);
             }
             $table->Show();
         }
     }
 }