コード例 #1
1
 public function bodyToString()
 {
     $this->cleanItems();
     $total = 0;
     // fetch accessible host ids
     $hosts = API::Host()->get(array('nodeids' => get_current_nodeid(true), 'output' => array('hostid'), 'preservekeys' => true));
     $hostIds = array_keys($hosts);
     if (remove_nodes_from_id($this->groupid) > 0) {
         $cond_from = ',hosts_groups hg';
         $cond_where = ' AND hg.hostid=h.hostid AND hg.groupid=' . zbx_dbstr($this->groupid);
     } else {
         $cond_from = '';
         $cond_where = andDbNode('h.hostid', $this->nodeid);
     }
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_TRUE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $avail = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_FALSE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $notav = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_UNKNOWN . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $uncn = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $node = get_node_by_nodeid($this->nodeid);
     $header_str = _('Hosts info') . SPACE;
     if ($node > 0) {
         $header_str .= '(' . $node['name'] . ')' . SPACE;
     }
     if (remove_nodes_from_id($this->groupid) > 0) {
         $group = get_hostgroup_by_groupid($this->groupid);
         $header_str .= _('Group') . SPACE . '"' . $group['name'] . '"';
     } else {
         $header_str .= _('All groups');
     }
     $header = new CCol($header_str, 'header');
     if ($this->style == STYLE_HORISONTAL) {
         $header->setColspan(4);
     }
     $this->addRow($header);
     $avail = new CCol($avail . '  ' . _('Available'), 'avail');
     $notav = new CCol($notav . '  ' . _('Not available'), 'notav');
     $uncn = new CCol($uncn . '  ' . _('Unknown'), 'uncn');
     $total = new CCol($total . '  ' . _('Total'), 'total');
     if ($this->style == STYLE_HORISONTAL) {
         $this->addRow(array($avail, $notav, $uncn, $total));
     } else {
         $this->addRow($avail);
         $this->addRow($notav);
         $this->addRow($uncn);
         $this->addRow($total);
     }
     return parent::bodyToString();
 }
コード例 #2
0
ファイル: class.chostsinfo.php プロジェクト: rennhak/zabbix
 public function bodyToString()
 {
     global $USER_DETAILS;
     $this->cleanItems();
     $total = 0;
     $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, get_current_nodeid(true));
     $cond_from = '';
     if (remove_nodes_from_id($this->groupid) > 0) {
         $cond_from = ', hosts_groups hg ';
         $cond_where = 'AND hg.hostid=h.hostid AND hg.groupid=' . $this->groupid;
     } else {
         $cond_where = ' AND ' . DBin_node('h.hostid', $this->nodeid);
     }
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_TRUE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $avail = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_FALSE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $notav = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_UNKNOWN . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where);
     $host_cnt = DBfetch($db_host_cnt);
     $uncn = $host_cnt['cnt'];
     $total += $host_cnt['cnt'];
     $node = get_node_by_nodeid($this->nodeid);
     $header_str = S_HOSTS_INFO . SPACE;
     $header_str .= S_FOR_GROUP_SMALL . SPACE . '"';
     if ($node > 0) {
         $header_str .= '(' . $node['name'] . ')' . SPACE;
     }
     if (remove_nodes_from_id($this->groupid) > 0) {
         $group = get_hostgroup_by_groupid($this->groupid);
         $header_str .= $group['name'] . '"';
     } else {
         $header_str .= S_ALL_S . '"';
     }
     $header = new CCol($header_str, "header");
     if ($this->style == STYLE_HORISONTAL) {
         $header->SetColspan(4);
     }
     $this->addRow($header);
     $avail = new CCol($avail . '  ' . S_AVAILABLE, 'avail');
     $notav = new CCol($notav . '  ' . S_NOT_AVAILABLE, 'notav');
     $uncn = new CCol($uncn . '  ' . S_UNKNOWN, 'uncn');
     $total = new CCol($total . '  ' . S_TOTAL, 'total');
     if ($this->style == STYLE_HORISONTAL) {
         $this->addRow(array($avail, $notav, $uncn, $total));
     } else {
         $this->addRow($avail);
         $this->addRow($notav);
         $this->addRow($uncn);
         $this->addRow($total);
     }
     return parent::bodyToString();
 }
コード例 #3
0
 public function setDoubleHeader($left, $right)
 {
     $table = new CTable();
     $table->addStyle('width: 100%;');
     $lCol = new CCol($left);
     $lCol->addStyle('text-align: left; border: 0;');
     $rCol = new CCol($right);
     $rCol->addStyle('text-align: right; border: 0;');
     $table->addRow(array($lCol, $rCol));
     $this->_header = new CDiv(null, 'nowrap ui-corner-all ui-widget-header ' . $this->css_class);
     $this->_header->addItem($table);
     return $this->_header;
 }
// create table
$servicesParentTable = new CTableInfo();
$servicesParentTable->setHeader(array(_('Service'), _('Status calculation'), _('Trigger')));
$prefix = null;
// root
$description = new CLink(_('root'), '#', null, 'javascript:
	jQuery(\'#parent_name\', window.opener.document).val(' . zbx_jsvalue(_('root')) . ');
	jQuery(\'#parentname\', window.opener.document).val(' . zbx_jsvalue(_('root')) . ');
	jQuery(\'#parentid\', window.opener.document).val(' . zbx_jsvalue(0) . ');
	self.close();
	return false;');
$servicesParentTable->addRow(array(array($prefix, $description), _('Note'), '-'));
// others
foreach ($this->data['db_pservices'] as $db_service) {
    $description = new CSpan($db_service['name'], 'link');
    $description->setAttribute('onclick', 'javascript:
		jQuery(\'#parent_name\', window.opener.document).val(' . zbx_jsvalue($db_service['name']) . ');
		jQuery(\'#parentname\', window.opener.document).val(' . zbx_jsvalue($db_service['name']) . ');
		jQuery(\'#parentid\', window.opener.document).val(' . zbx_jsvalue($db_service['serviceid']) . ');
		self.close();
		return false;');
    $servicesParentTable->addRow(array(array($prefix, $description), serviceAlgorythm($db_service['algorithm']), $db_service['trigger']));
}
$column = new CCol(new CButton('cancel', _('Cancel'), 'javascript: self.close();'));
$column->setAttribute('style', 'text-align:right;');
$servicesParentTable->setFooter($column);
// append table to form
$servicesParentForm->addItem($servicesParentTable);
// append form to widget
$servicesParentWidget->addItem($servicesParentForm);
return $servicesParentWidget;
コード例 #5
0
        $dns = $h_data['dns'] == '' ? '' : ' (' . $h_data['dns'] . ')';
        $row = array($h_data['type'] == 'primary' ? new CSpan($ip . $dns, $h_data['class']) : new CSpan(SPACE . SPACE . $ip . $dns), new CSpan(empty($h_data['host']) ? '-' : $h_data['host']), new CSpan($h_data['time'] == 0 || $h_data['type'] === 'slave' ? '' : convert_units(array('value' => time() - $h_data['time'], 'units' => 'uptime')), $h_data['class']));
        foreach ($this->data['services'] as $name => $foo) {
            $class = null;
            $time = SPACE;
            $hint = new CDiv(SPACE, $class);
            $hintTable = null;
            if (isset($h_data['services'][$name])) {
                $class = $h_data['services'][$name]['class'];
                $time = $h_data['services'][$name]['time'];
                $hintTable = new CTableInfo();
                $hintTable->setAttribute('style', 'width: auto;');
                if ($class == 'active') {
                    $hintTable->setHeader(_('Uptime'));
                } elseif ($class == 'inactive') {
                    $hintTable->setHeader(_('Downtime'));
                }
                $timeColumn = new CCol(zbx_date2age($h_data['services'][$name]['time']), $class);
                $hintTable->addRow($timeColumn);
            }
            $column = new CCol($hint, $class);
            if (!is_null($hintTable)) {
                $column->setHint($hintTable);
            }
            $row[] = $column;
        }
        $discoveryTable->addRow($row);
    }
}
$discoveryWidget->addItem($discoveryTable);
return $discoveryWidget;
コード例 #6
0
            }
        }
    } else {
        if (empty($apps)) {
            $url = '?open=1&applicationid=0';
        } else {
            if (isset($apps[0])) {
                $url = '?close=1' . url_param($tmp_apps, false, 'apps');
            } else {
                $url = '?close=1&applicationid=0' . url_param($tmp_apps, false, 'apps');
            }
        }
    }
    $url .= url_param('groupid') . url_param('hostid') . url_param('fullscreen') . url_param('select');
    $link = new CLink($img, $url);
    $col = new CCol(array(bold('- ' . 'other' . ' -'), SPACE . '(' . _n('%1$s Item', '%1$s Items', $db_host['item_cnt']) . ')'));
    $col->setColSpan(5);
    // host JS menu link
    $hostSpan = null;
    if ($_REQUEST['hostid'] == 0) {
        $hostSpan = new CSpan($host['name'], 'link_menu menu-host');
        $scripts = $hostScripts[$host['hostid']];
        $hostSpan->setAttribute('data-menu', hostMenuData($host, $scripts));
    }
    $table->addRow(array($link, get_node_name_by_elid($db_host['hostid']), $hostSpan, $col));
    foreach ($app_rows as $row) {
        $table->addRow($row);
    }
}
$latest_wdgt->addItem($table);
$latest_wdgt->show();
コード例 #7
0
ファイル: menu.inc.php プロジェクト: sogaoh/hyclops
/**
 * NOTE - menu array format:
 * first level:
 *	'label' = main menu title.
 *	'default_page_id	= default page url from 'pages' then opened menu.
 *	'pages' = collection of pages which are displayed from this menu.
 *	these pages are saved a last visited submenu of main menu.
 *
 * second level (pages):
 *	'url' = real url for this page
 *	'label' =  submenu title, if missing, menu skipped, but remembered as last visited page.
 *	'sub_pages' = collection of pages for displaying but not remembered as last visited.
 */
function zbx_construct_menu(&$main_menu, &$sub_menus, &$page)
{
    global $ZBX_MENU;
    $denied_page_requested = false;
    $page_exists = false;
    $deny = !defined('ZBX_PAGE_NO_AUTHORIZATION');
    foreach ($ZBX_MENU as $label => $menu) {
        $show_menu = true;
        if (isset($menu['user_type'])) {
            $show_menu &= $menu['user_type'] <= CWebUser::$data['type'];
        }
        if ($label == 'login') {
            $show_menu = false;
        }
        $menu_class = 'horizontal_menu_n';
        $sub_menus[$label] = array();
        foreach ($menu['pages'] as $sub_page) {
            $show_sub_menu = true;
            // show check
            if (!isset($sub_page['label'])) {
                $show_sub_menu = false;
            }
            if (!isset($sub_page['user_type'])) {
                $sub_page['user_type'] = $menu['user_type'];
            }
            if (CWebUser::$data['type'] < $sub_page['user_type']) {
                $show_sub_menu = false;
            }
            $row = array('menu_text' => isset($sub_page['label']) ? $sub_page['label'] : '', 'menu_url' => $sub_page['url'], 'class' => 'highlight', 'selected' => false);
            $sub_menu_active = $page['file'] == $sub_page['url'];
            $sub_menu_active |= isset($sub_page['sub_pages']) && str_in_array($page['file'], $sub_page['sub_pages']);
            if ($sub_menu_active) {
                // permition check
                $deny &= CWebUser::$data['type'] < $menu['user_type'] || CWebUser::$data['type'] < $sub_page['user_type'];
                $menu_class = 'active';
                $page_exists = true;
                $page['menu'] = $label;
                $row['selected'] = true;
                if (!defined('ZBX_PAGE_NO_MENU')) {
                    CProfile::update('web.menu.' . $label . '.last', $sub_page['url'], PROFILE_TYPE_STR);
                }
            }
            if ($show_sub_menu) {
                $sub_menus[$label][] = $row;
            }
        }
        if ($page_exists && !defined('ZBX_NOT_ALLOW_ALL_NODES') && (isset($menu['force_disable_all_nodes']) || isset($sub_page['force_disable_all_nodes']))) {
            define('ZBX_NOT_ALLOW_ALL_NODES', 1);
        }
        if ($page_exists && $deny) {
            $denied_page_requested = true;
        }
        if (!$show_menu) {
            unset($sub_menus[$label]);
            continue;
        }
        $menu_url = $sub_menus[$label][$menu['default_page_id']]['menu_url'];
        $mmenu_entry = new CCol($menu['label'], $menu_class);
        $mmenu_entry->setAttribute('id', $label);
        $mmenu_entry->addAction('onclick', 'javascript: redirect(\'' . $menu_url . '\');');
        $mmenu_entry->addAction('onmouseover', 'javascript: MMenu.mouseOver(\'' . $label . '\');');
        $mmenu_entry->addAction('onmouseout', 'javascript: MMenu.mouseOut();');
        array_push($main_menu, $mmenu_entry);
    }
    if (!$page_exists && $page['type'] != PAGE_TYPE_XML && $page['type'] != PAGE_TYPE_CSV && $page['type'] != PAGE_TYPE_TEXT_FILE) {
        $denied_page_requested = true;
    }
    return $denied_page_requested;
}
コード例 #8
0
ファイル: page_header.php プロジェクト: hujingguang/work
 }
 if (isset($ZBX_SERVER_NAME) && !zbx_empty($ZBX_SERVER_NAME)) {
     $table = new CTable();
     $table->addStyle('width: 100%;');
     $tableColumn = new CCol(new CSpan($ZBX_SERVER_NAME, 'textcolorstyles'));
     if (is_null($node_form)) {
         $tableColumn->addStyle('padding-right: 5px;');
     } else {
         $tableColumn->addStyle('padding-right: 20px; padding-bottom: 2px;');
     }
     $table->addRow(array($tableColumn, $node_form));
     $node_form = $table;
 }
 // 1st level menu
 $table = new CTable(null, 'maxwidth');
 $r_col = new CCol($node_form, 'right');
 $r_col->setAttribute('style', 'line-height: 1.8em;');
 $table->addRow(array($menu_table, $r_col));
 $page_menu = new CDiv(null, 'textwhite');
 $page_menu->setAttribute('id', 'mmenu');
 $page_menu->addItem($table);
 // 2nd level menu
 $sub_menu_table = new CTable(null, 'sub_menu maxwidth ui-widget-header');
 $menu_divs = array();
 $menu_selected = false;
 foreach ($sub_menus as $label => $sub_menu) {
     $sub_menu_row = array();
     foreach ($sub_menu as $id => $sub_page) {
         if (empty($sub_page['menu_text'])) {
             $sub_page['menu_text'] = SPACE;
         }
コード例 #9
0
ファイル: func.inc.php プロジェクト: itnihao/Zabbix_
function show_messages($bool = true, $okmsg = null, $errmsg = null)
{
    global $page, $ZBX_MESSAGES;
    if (!defined('PAGE_HEADER_LOADED')) {
        return null;
    }
    if (defined('ZBX_API_REQUEST')) {
        return null;
    }
    if (!isset($page['type'])) {
        $page['type'] = PAGE_TYPE_HTML;
    }
    $message = array();
    $width = 0;
    $height = 0;
    if (!$bool && !is_null($errmsg)) {
        $msg = _('ERROR') . ': ' . $errmsg;
    } elseif ($bool && !is_null($okmsg)) {
        $msg = $okmsg;
    }
    if (isset($msg)) {
        switch ($page['type']) {
            case PAGE_TYPE_IMAGE:
                array_push($message, array('text' => $msg, 'color' => !$bool ? array('R' => 255, 'G' => 0, 'B' => 0) : array('R' => 34, 'G' => 51, 'B' => 68), 'font' => 2));
                $width = max($width, imagefontwidth(2) * zbx_strlen($msg) + 1);
                $height += imagefontheight(2) + 1;
                break;
            case PAGE_TYPE_XML:
                echo htmlspecialchars($msg) . "\n";
                break;
            case PAGE_TYPE_HTML:
            default:
                $msg_tab = new CTable($msg, $bool ? 'msgok' : 'msgerr');
                $msg_tab->setCellPadding(0);
                $msg_tab->setCellSpacing(0);
                $row = array();
                $msg_col = new CCol(bold($msg), 'msg_main msg');
                $msg_col->setAttribute('id', 'page_msg');
                $row[] = $msg_col;
                if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) {
                    $msg_details = new CDiv(_('Details'), 'blacklink');
                    $msg_details->setAttribute('onclick', 'javascript: showHide("msg_messages", IE ? "block" : "table");');
                    $msg_details->setAttribute('title', _('Maximize') . '/' . _('Minimize'));
                    array_unshift($row, new CCol($msg_details, 'clr'));
                }
                $msg_tab->addRow($row);
                $msg_tab->show();
                break;
        }
    }
    if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) {
        if ($page['type'] == PAGE_TYPE_IMAGE) {
            $msg_font = 2;
            foreach ($ZBX_MESSAGES as $msg) {
                if ($msg['type'] == 'error') {
                    array_push($message, array('text' => $msg['message'], 'color' => array('R' => 255, 'G' => 55, 'B' => 55), 'font' => $msg_font));
                } else {
                    array_push($message, array('text' => $msg['message'], 'color' => array('R' => 155, 'G' => 155, 'B' => 55), 'font' => $msg_font));
                }
                $width = max($width, imagefontwidth($msg_font) * zbx_strlen($msg['message']) + 1);
                $height += imagefontheight($msg_font) + 1;
            }
        } elseif ($page['type'] == PAGE_TYPE_XML) {
            foreach ($ZBX_MESSAGES as $msg) {
                echo '[' . $msg['type'] . '] ' . $msg['message'] . "\n";
            }
        } else {
            $lst_error = new CList(null, 'messages');
            foreach ($ZBX_MESSAGES as $msg) {
                $lst_error->addItem($msg['message'], $msg['type']);
                $bool = $bool && 'error' != zbx_strtolower($msg['type']);
            }
            $msg_show = 6;
            $msg_count = count($ZBX_MESSAGES);
            if ($msg_count > $msg_show) {
                $msg_count = $msg_show * 16;
                $lst_error->setAttribute('style', 'height: ' . $msg_count . 'px;');
            }
            $tab = new CTable(null, $bool ? 'msgok' : 'msgerr');
            $tab->setCellPadding(0);
            $tab->setCellSpacing(0);
            $tab->setAttribute('id', 'msg_messages');
            $tab->setAttribute('style', 'width: 100%;');
            if (isset($msg_tab) && $bool) {
                $tab->setAttribute('style', 'display: none;');
            }
            $tab->addRow(new CCol($lst_error, 'msg'));
            $tab->show();
        }
        $ZBX_MESSAGES = null;
    }
    if ($page['type'] == PAGE_TYPE_IMAGE && count($message) > 0) {
        $width += 2;
        $height += 2;
        $canvas = imagecreate($width, $height);
        imagefilledrectangle($canvas, 0, 0, $width, $height, imagecolorallocate($canvas, 255, 255, 255));
        foreach ($message as $id => $msg) {
            $message[$id]['y'] = 1 + (isset($previd) ? $message[$previd]['y'] + $message[$previd]['h'] : 0);
            $message[$id]['h'] = imagefontheight($msg['font']);
            imagestring($canvas, $msg['font'], 1, $message[$id]['y'], $msg['text'], imagecolorallocate($canvas, $msg['color']['R'], $msg['color']['G'], $msg['color']['B']));
            $previd = $id;
        }
        imageOut($canvas);
        imagedestroy($canvas);
    }
}
コード例 #10
0
    $helpTextWhenDragInterfaceJMX->addClass('dragHelpText');
    $buttonCol = new CCol(new CButton('addJMXInterface', _('Add'), null, 'link_menu'), 'interface-add-control');
    $col = new CCol($helpTextWhenDragInterfaceJMX);
    $col->setAttribute('colspan', 6);
    $buttonRow = new CRow(array($buttonCol, $col));
    $buttonRow->setAttribute('id', 'JMXIterfacesFooter');
    $ifTab->addRow($buttonRow);
    $hostList->addRow(_('JMX interfaces'), new CDiv($ifTab, 'border_dotted objectgroup inlineblock interface-group'), false, null, 'interface-row');
    // table for IPMI interfaces with footer
    $ifTab = new CTable(null, 'formElementTable');
    $ifTab->setAttribute('id', 'IPMIInterfaces');
    $ifTab->setAttribute('data-type', 'ipmi');
    $helpTextWhenDragInterfaceIPMI = new CSpan(_('Drag here to change the type of the interface to "IPMI" type.'));
    $helpTextWhenDragInterfaceIPMI->addClass('dragHelpText');
    $buttonCol = new CCol(new CButton('addIPMIInterface', _('Add'), null, 'link_menu'), 'interface-add-control');
    $col = new CCol($helpTextWhenDragInterfaceIPMI);
    $col->setAttribute('colspan', 6);
    $buttonRow = new CRow(array($buttonCol, $col));
    $buttonRow->setAttribute('id', 'IPMIIterfacesFooter');
    $ifTab->addRow($buttonRow);
    $hostList->addRow(_('IPMI interfaces'), new CDiv($ifTab, 'border_dotted objectgroup inlineblock interface-group'), false, null, 'interface-row');
} else {
    $interfaces = array();
    $existingInterfaceTypes = array();
    foreach ($dbHost['interfaces'] as $interface) {
        $interface['locked'] = true;
        $existingInterfaceTypes[$interface['type']] = true;
        $interfaces[$interface['interfaceid']] = $interface;
    }
    zbx_add_post_js('hostInterfacesManager.add(' . CJs::encodeJson($interfaces) . ');');
    zbx_add_post_js('hostInterfacesManager.disable()');
コード例 #11
0
 public function bodyToString()
 {
     $res = parent::bodyToString();
     $tbl = new CTable(null, $this->tableclass);
     $tbl->setCellSpacing(0);
     $tbl->setCellPadding(1);
     $tbl->setAlign($this->align);
     // add first row
     if (!is_null($this->title)) {
         $col = new CCol(null, 'form_row_first');
         $col->setColSpan(2);
         if (isset($this->help)) {
             $col->addItem($this->help);
         }
         if (isset($this->title)) {
             $col->addItem($this->title);
         }
         $tbl->setHeader($col);
     }
     // add last row
     $tbl->setFooter($this->bottom_items);
     // add center rows
     foreach ($this->center_items as $item) {
         $tbl->addRow($item);
     }
     return $res . $tbl->toString();
 }
コード例 #12
0
ファイル: actions.inc.php プロジェクト: rennhak/zabbix
function get_event_actions_stat_hints($eventid)
{
    $actions = new CTable(' - ');
    $sql = 'SELECT COUNT(a.alertid) as cnt ' . ' FROM alerts a ' . ' WHERE a.eventid=' . $eventid . ' AND a.alerttype in (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')';
    $alerts = DBfetch(DBselect($sql));
    if (isset($alerts['cnt']) && $alerts['cnt'] > 0) {
        $sql = 'SELECT COUNT(a.alertid) as sent ' . ' FROM alerts a ' . ' WHERE a.eventid=' . $eventid . ' AND a.alerttype in (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . ' AND a.status=' . ALERT_STATUS_SENT;
        $alerts = DBfetch(DBselect($sql));
        $alert_cnt = new CSpan($alerts['sent'], 'green');
        if ($alerts['sent']) {
            $hint = get_actions_hint_by_eventid($eventid, ALERT_STATUS_SENT);
            $alert_cnt->SetHint($hint);
        }
        $tdl = new CCol($alerts['sent'] ? $alert_cnt : SPACE);
        $tdl->addOption('width', '10');
        $sql = 'SELECT COUNT(a.alertid) as inprogress ' . ' FROM alerts a ' . ' WHERE a.eventid=' . $eventid . ' AND a.alerttype in (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . ' AND a.status=' . ALERT_STATUS_NOT_SENT;
        $alerts = DBfetch(DBselect($sql));
        $alert_cnt = new CSpan($alerts['inprogress'], 'orange');
        if ($alerts['inprogress']) {
            $hint = get_actions_hint_by_eventid($eventid, ALERT_STATUS_NOT_SENT);
            $alert_cnt->setHint($hint);
        }
        $tdc = new CCol($alerts['inprogress'] ? $alert_cnt : SPACE);
        $tdc->addOption('width', '10');
        $sql = 'SELECT COUNT(a.alertid) as failed ' . ' FROM alerts a ' . ' WHERE a.eventid=' . $eventid . ' AND a.alerttype in (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . ' AND a.status=' . ALERT_STATUS_FAILED;
        $alerts = DBfetch(DBselect($sql));
        $alert_cnt = new CSpan($alerts['failed'], 'red');
        if ($alerts['failed']) {
            $hint = get_actions_hint_by_eventid($eventid, ALERT_STATUS_FAILED);
            $alert_cnt->setHint($hint);
        }
        $tdr = new CCol($alerts['failed'] ? $alert_cnt : SPACE);
        $tdr->addOption('width', '10');
        $actions->addRow(array($tdl, $tdc, $tdr));
    }
    return $actions;
}
コード例 #13
0
ファイル: actions.inc.php プロジェクト: SandipSingh14/Zabbix_
function getEventActionsStatus($eventIds)
{
    if (empty($eventIds)) {
        return array();
    }
    $actions = array();
    $alerts = DBselect('SELECT a.eventid,a.status,COUNT(a.alertid) AS cnt' . ' FROM alerts a' . ' WHERE a.alerttype IN (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . ' AND ' . dbConditionInt('a.eventid', $eventIds) . ' GROUP BY eventid,status');
    while ($alert = DBfetch($alerts)) {
        $actions[$alert['eventid']][$alert['status']] = $alert['cnt'];
    }
    foreach ($actions as $eventId => $action) {
        $sendCount = isset($action[ALERT_STATUS_SENT]) ? $action[ALERT_STATUS_SENT] : 0;
        $notSendCount = isset($action[ALERT_STATUS_NOT_SENT]) ? $action[ALERT_STATUS_NOT_SENT] : 0;
        $failedCount = isset($action[ALERT_STATUS_FAILED]) ? $action[ALERT_STATUS_FAILED] : 0;
        // calculate total
        $mixed = 0;
        if ($sendCount > 0) {
            $mixed += ALERT_STATUS_SENT;
        }
        if ($failedCount > 0) {
            $mixed += ALERT_STATUS_FAILED;
        }
        // display
        if ($notSendCount > 0) {
            $status = new CSpan(_('In progress'), 'orange');
        } elseif ($mixed == ALERT_STATUS_SENT) {
            $status = new CSpan(_('Ok'), 'green');
        } elseif ($mixed == ALERT_STATUS_FAILED) {
            $status = new CSpan(_('Failed'), 'red');
        } else {
            $columnLeft = new CCol($sendCount > 0 ? new CSpan($sendCount, 'green') : SPACE);
            $columnLeft->setAttribute('width', '10');
            $columnRight = new CCol($failedCount > 0 ? new CSpan($failedCount, 'red') : SPACE);
            $columnRight->setAttribute('width', '10');
            $status = new CRow(array($columnLeft, $columnRight));
        }
        $actions[$eventId] = new CTable(' - ');
        $actions[$eventId]->addRow($status);
    }
    return $actions;
}
コード例 #14
0
 /**
  * Process screen with particular screen objects.
  *
  * @return CTable
  */
 public function show()
 {
     if (empty($this->screen)) {
         return new CTableInfo(_('No screens defined.'));
     }
     $skipedFields = array();
     $screenitems = array();
     $emptyScreenColumns = array();
     // calculate table columns and rows
     foreach ($this->screen['screenitems'] as $screenitem) {
         $screenitems[] = $screenitem;
         for ($i = 0; $i < $screenitem['rowspan'] || $i == 0; $i++) {
             for ($j = 0; $j < $screenitem['colspan'] || $j == 0; $j++) {
                 if ($i != 0 || $j != 0) {
                     if (!isset($skipedFields[$screenitem['y'] + $i])) {
                         $skipedFields[$screenitem['y'] + $i] = array();
                     }
                     $skipedFields[$screenitem['y'] + $i][$screenitem['x'] + $j] = 1;
                 }
             }
         }
     }
     // create screen table
     $screenTable = new CTable();
     $screenTable->setAttribute('class', in_array($this->mode, array(SCREEN_MODE_PREVIEW, SCREEN_MODE_SLIDESHOW)) ? 'screen_view' : 'screen_edit');
     $screenTable->setAttribute('id', 'iframe');
     // action top row
     if ($this->mode == SCREEN_MODE_EDIT) {
         $newColumns = array(new CCol(new CImg('images/general/zero.png', 'zero', 1, 1)));
         for ($i = 0, $size = $this->screen['hsize'] + 1; $i < $size; $i++) {
             $icon = new CImg('images/general/plus.png', null, null, null, 'pointer');
             $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&add_col=' . $i . '";');
             array_push($newColumns, new CCol($icon));
         }
         $screenTable->addRow($newColumns);
     }
     for ($r = 0; $r < $this->screen['vsize']; $r++) {
         $newColumns = array();
         $emptyScreenRow = true;
         // action left cell
         if ($this->mode == SCREEN_MODE_EDIT) {
             $icon = new CImg('images/general/plus.png', null, null, null, 'pointer');
             $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&add_row=' . $r . '";');
             array_push($newColumns, new CCol($icon));
         }
         for ($c = 0; $c < $this->screen['hsize']; $c++) {
             if (isset($skipedFields[$r][$c])) {
                 continue;
             }
             // screen item
             $isEditForm = false;
             $screenitem = array();
             foreach ($screenitems as $tmprow) {
                 if ($tmprow['x'] == $c && $tmprow['y'] == $r) {
                     $screenitem = $tmprow;
                     break;
                 }
             }
             if (empty($screenitem)) {
                 $screenitem = array('screenitemid' => 0, 'resourcetype' => 0, 'resourceid' => 0, 'width' => 0, 'height' => 0, 'colspan' => 1, 'rowspan' => 1, 'elements' => 0, 'valign' => VALIGN_DEFAULT, 'halign' => HALIGN_DEFAULT, 'style' => 0, 'url' => '', 'dynamic' => 0, 'sort_triggers' => SCREEN_SORT_TRIGGERS_DATE_DESC);
             }
             if (!empty($screenitem['screenitemid'])) {
                 $emptyScreenRow = false;
                 $emptyScreenColumns[$c] = 1;
             }
             // action
             if ($this->mode == SCREEN_MODE_EDIT && $screenitem['screenitemid'] != 0) {
                 $action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitem['screenitemid'];
             } elseif ($this->mode == SCREEN_MODE_EDIT && $screenitem['screenitemid'] == 0) {
                 $action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r;
             } else {
                 $action = null;
             }
             // edit form cell
             if ($this->mode == SCREEN_MODE_EDIT && (isset($_REQUEST['form']) && $_REQUEST['form'] == 'update') && (isset($_REQUEST['x']) && $_REQUEST['x'] == $c && isset($_REQUEST['y']) && $_REQUEST['y'] == $r || isset($_REQUEST['screenitemid']) && bccomp($_REQUEST['screenitemid'], $screenitem['screenitemid']) == 0)) {
                 $screenView = new CView('configuration.screen.constructor.edit', array('screen' => $this->screen));
                 $item = $screenView->render();
                 $isEditForm = true;
             } elseif (!empty($screenitem['screenitemid']) && isset($screenitem['resourcetype'])) {
                 $screenBase = CScreenBuilder::getScreen(array('isFlickerfree' => $this->isFlickerfree, 'pageFile' => $this->pageFile, 'mode' => $this->mode, 'timestamp' => $this->timestamp, 'hostid' => $this->hostid, 'profileIdx' => $this->profileIdx, 'profileIdx2' => $this->profileIdx2, 'updateProfile' => $this->updateProfile, 'timeline' => $this->timeline, 'resourcetype' => $screenitem['resourcetype'], 'screenitem' => $screenitem));
                 if (!empty($screenBase)) {
                     if ($this->mode == SCREEN_MODE_EDIT && !empty($screenitem['screenitemid'])) {
                         $screenBase->action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitem['screenitemid'];
                     } elseif ($this->mode == SCREEN_MODE_EDIT && empty($screenitem['screenitemid'])) {
                         $screenBase->action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r;
                     }
                     $item = $screenBase->get();
                 } else {
                     $item = null;
                 }
             } else {
                 $item = array(SPACE);
                 if ($this->mode == SCREEN_MODE_EDIT) {
                     array_push($item, BR(), new CLink(_('Change'), $action, 'empty_change_link'));
                 }
             }
             // align
             $halign = 'def';
             if ($screenitem['halign'] == HALIGN_CENTER) {
                 $halign = 'cntr';
             }
             if ($screenitem['halign'] == HALIGN_LEFT) {
                 $halign = 'left';
             }
             if ($screenitem['halign'] == HALIGN_RIGHT) {
                 $halign = 'right';
             }
             $valign = 'def';
             if ($screenitem['valign'] == VALIGN_MIDDLE) {
                 $valign = 'mdl';
             }
             if ($screenitem['valign'] == VALIGN_TOP) {
                 $valign = 'top';
             }
             if ($screenitem['valign'] == VALIGN_BOTTOM) {
                 $valign = 'bttm';
             }
             if ($this->mode == SCREEN_MODE_EDIT && !$isEditForm) {
                 $item = new CDiv($item, 'draggable');
                 $item->setAttribute('id', 'position_' . $r . '_' . $c);
                 $item->setAttribute('data-xcoord', $c);
                 $item->setAttribute('data-ycoord', $r);
             }
             // colspan/rowspan
             $newColumn = new CCol($item, $halign . '_' . $valign . ' screenitem');
             if (!empty($screenitem['colspan'])) {
                 $newColumn->setColSpan($screenitem['colspan']);
             }
             if (!empty($screenitem['rowspan'])) {
                 $newColumn->setRowSpan($screenitem['rowspan']);
             }
             array_push($newColumns, $newColumn);
         }
         // action right cell
         if ($this->mode == SCREEN_MODE_EDIT) {
             $icon = new CImg('images/general/minus.png', null, null, null, 'pointer');
             if ($emptyScreenRow) {
                 $removeRowLink = 'javascript: location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_row=' . $r . '";';
             } else {
                 $removeRowLink = 'javascript: if (Confirm("' . _('This screen-row is not empty. Delete it?') . '")) {' . ' location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_row=' . $r . '"; }';
             }
             $icon->addAction('onclick', $removeRowLink);
             array_push($newColumns, new CCol($icon));
         }
         $screenTable->addRow(new CRow($newColumns));
     }
     // action bottom row
     if ($this->mode == SCREEN_MODE_EDIT) {
         $icon = new CImg('images/general/plus.png', null, null, null, 'pointer');
         $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&add_row=' . $this->screen['vsize'] . '";');
         $newColumns = array(new CCol($icon));
         for ($i = 0; $i < $this->screen['hsize']; $i++) {
             $icon = new CImg('images/general/minus.png', null, null, null, 'pointer');
             if (isset($emptyScreenColumns[$i])) {
                 $removeColumnLink = 'javascript: if (Confirm("' . _('This screen-column is not empty. Delete it?') . '")) {' . ' location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_col=' . $i . '"; }';
             } else {
                 $removeColumnLink = 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&rmv_col=' . $i . '";';
             }
             $icon->addAction('onclick', $removeColumnLink);
             array_push($newColumns, new CCol($icon));
         }
         array_push($newColumns, new CCol(new CImg('images/general/zero.png', 'zero', 1, 1)));
         $screenTable->addRow($newColumns);
     }
     return $screenTable;
 }
コード例 #15
0
ファイル: page_header.php プロジェクト: phedders/zabbix
         $div_node_tree->setAttribute('id', 'div_node_tree');
         $div_node_tree->addStyle('display: none');
         if (!is_null($combo_node_list)) {
             $node_form->addItem(array(new CSpan(S_CURRENT_NODE, 'textcolorstyles'), $combo_node_list));
         }
         $node_form->addItem($button_show_tree);
         $node_form->addItem($div_node_tree);
         unset($combo_node_list);
     }
 }
 // 1st level menu
 $table = new CTable();
 $table->setCellSpacing(0);
 $table->setCellPadding(0);
 $table->setAttribute('style', 'width: 100%;');
 $r_col = new CCol($node_form);
 $r_col->setAttribute('align', 'right');
 //		$r_col->setAttribute('style','text-align: right;');
 $table->addRow(array($menu_table, $r_col));
 $page_menu = new CDiv();
 $page_menu->setAttribute('id', 'mmenu');
 $page_menu->addItem($table);
 //----
 // 2nd level menu
 $sub_menu_table = new CTable(NULL, 'sub_menu');
 $sub_menu_table->setCellSpacing(0);
 $sub_menu_table->setCellPadding(5);
 $menu_divs = array();
 $menu_selected = false;
 foreach ($sub_menus as $label => $sub_menu) {
     $sub_menu_row = array();
コード例 #16
0
ファイル: blocks.inc.php プロジェクト: SandipSingh14/Zabbix_
/**
 * Create DIV with latest problem triggers.
 *
 * If no sortfield and sortorder are defined, the sort indicater in the column name will not be displayed.
 *
 * @param array  $filter['screenid']
 * @param array  $filter['groupids']
 * @param array  $filter['hostids']
 * @param array  $filter['maintenance']
 * @param int    $filter['extAck']
 * @param int    $filter['severity']
 * @param int    $filter['limit']
 * @param string $filter['sortfield']
 * @param string $filter['sortorder']
 * @param string $filter['backUrl']
 *
 * @return CDiv
 */
function make_latest_issues(array $filter = array())
{
    // hide the sort indicator if no sortfield and sortorder are given
    $showSortIndicator = isset($filter['sortfield']) || isset($filter['sortorder']);
    if (!isset($filter['sortfield'])) {
        $filter['sortfield'] = 'lastchange';
    }
    if (!isset($filter['sortorder'])) {
        $filter['sortorder'] = ZBX_SORT_DOWN;
    }
    $options = array('groupids' => $filter['groupids'], 'hostids' => isset($filter['hostids']) ? $filter['hostids'] : null, 'monitored' => true, 'maintenance' => $filter['maintenance'], 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE));
    $triggers = API::Trigger()->get(array_merge($options, array('withLastEventUnacknowledged' => isset($filter['extAck']) && $filter['extAck'] == EXTACK_OPTION_UNACK ? true : null, 'skipDependent' => true, 'output' => array('triggerid', 'state', 'error', 'url', 'expression', 'description', 'priority', 'lastchange'), 'selectHosts' => array('hostid', 'name'), 'selectLastEvent' => array('eventid', 'acknowledged', 'objectid', 'clock', 'ns'), 'sortfield' => $filter['sortfield'], 'sortorder' => $filter['sortorder'], 'limit' => isset($filter['limit']) ? $filter['limit'] : DEFAULT_LATEST_ISSUES_CNT)));
    // don't use withLastEventUnacknowledged and skipDependent because of performance issues
    $triggersTotalCount = API::Trigger()->get(array_merge($options, array('countOutput' => true)));
    // get acknowledges
    $eventIds = array();
    foreach ($triggers as $trigger) {
        if ($trigger['lastEvent']) {
            $eventIds[] = $trigger['lastEvent']['eventid'];
        }
    }
    if ($eventIds) {
        $eventAcknowledges = API::Event()->get(array('eventids' => $eventIds, 'select_acknowledges' => API_OUTPUT_EXTEND, 'preservekeys' => true));
    }
    foreach ($triggers as $tnum => $trigger) {
        // if trigger is lost (broken expression) we skip it
        if (empty($trigger['hosts'])) {
            unset($triggers[$tnum]);
            continue;
        }
        $host = reset($trigger['hosts']);
        $trigger['hostid'] = $host['hostid'];
        $trigger['hostname'] = $host['name'];
        if ($trigger['lastEvent']) {
            $trigger['lastEvent']['acknowledges'] = isset($eventAcknowledges[$trigger['lastEvent']['eventid']]) ? $eventAcknowledges[$trigger['lastEvent']['eventid']]['acknowledges'] : null;
        }
        $triggers[$tnum] = $trigger;
    }
    $hostIds = zbx_objectValues($triggers, 'hostid');
    // get hosts
    $hosts = API::Host()->get(array('hostids' => $hostIds, 'output' => array('hostid', 'name', 'status', 'maintenance_status', 'maintenance_type', 'maintenanceid'), 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true));
    // actions
    $actions = getEventActionsStatHints($eventIds);
    // ack params
    $ackParams = isset($filter['screenid']) ? array('screenid' => $filter['screenid']) : array();
    $config = select_config();
    // indicator of sort field
    if ($showSortIndicator) {
        $sortDiv = new CDiv(SPACE, $filter['sortorder'] === ZBX_SORT_DOWN ? 'icon_sortdown default_cursor' : 'icon_sortup default_cursor');
        $sortDiv->addStyle('float: left');
        $hostHeaderDiv = new CDiv(array(_('Host'), SPACE));
        $hostHeaderDiv->addStyle('float: left');
        $issueHeaderDiv = new CDiv(array(_('Issue'), SPACE));
        $issueHeaderDiv->addStyle('float: left');
        $lastChangeHeaderDiv = new CDiv(array(_('Time'), SPACE));
        $lastChangeHeaderDiv->addStyle('float: left');
    }
    $table = new CTableInfo(_('No events found.'));
    $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, $showSortIndicator && $filter['sortfield'] === 'hostname' ? array($hostHeaderDiv, $sortDiv) : _('Host'), $showSortIndicator && $filter['sortfield'] === 'priority' ? array($issueHeaderDiv, $sortDiv) : _('Issue'), $showSortIndicator && $filter['sortfield'] === 'lastchange' ? array($lastChangeHeaderDiv, $sortDiv) : _('Last change'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')));
    $scripts = API::Script()->getScriptsByHosts($hostIds);
    // triggers
    foreach ($triggers as $trigger) {
        $host = $hosts[$trigger['hostid']];
        $hostName = new CSpan($host['name'], 'link_menu');
        $hostName->setMenuPopup(getMenuPopupHost($host, $scripts[$host['hostid']]));
        // add maintenance icon with hint if host is in maintenance
        $maintenanceIcon = null;
        if ($host['maintenance_status']) {
            $maintenanceIcon = new CDiv(null, 'icon-maintenance-abs');
            // get maintenance
            $maintenances = API::Maintenance()->get(array('maintenanceids' => $host['maintenanceid'], 'output' => API_OUTPUT_EXTEND, 'limit' => 1));
            if ($maintenance = reset($maintenances)) {
                $hint = $maintenance['name'] . ' [' . ($host['maintenance_type'] ? _('Maintenance without data collection') : _('Maintenance with data collection')) . ']';
                if (isset($maintenance['description'])) {
                    // double quotes mandatory
                    $hint .= "\n" . $maintenance['description'];
                }
                $maintenanceIcon->setHint($hint);
                $maintenanceIcon->addClass('pointer');
            }
            $hostName->addClass('left-to-icon-maintenance-abs');
        }
        $hostDiv = new CDiv(array($hostName, $maintenanceIcon), 'maintenance-abs-cont');
        // unknown triggers
        $unknown = SPACE;
        if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
            $unknown = new CDiv(SPACE, 'status_icon iconunknown');
            $unknown->setHint($trigger['error'], '', 'on');
        }
        // trigger has events
        if ($trigger['lastEvent']) {
            // description
            $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $trigger['lastEvent']['clock'], 'ns' => $trigger['lastEvent']['ns'])));
            // ack
            $ack = getEventAckState($trigger['lastEvent'], empty($filter['backUrl']) ? true : $filter['backUrl'], true, $ackParams);
        } else {
            // description
            $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $trigger['lastchange'], 'ns' => '999999999')));
            // ack
            $ack = new CSpan(_('No events'), 'unknown');
        }
        // description
        if (!zbx_empty($trigger['url'])) {
            $description = new CLink($description, resolveTriggerUrl($trigger), null, null, true);
        } else {
            $description = new CSpan($description, 'pointer');
        }
        $description = new CCol($description, getSeverityStyle($trigger['priority']));
        if ($trigger['lastEvent']) {
            $description->setHint(make_popup_eventlist($trigger['triggerid'], $trigger['lastEvent']['eventid']), '', '', false);
        }
        // clock
        $clock = new CLink(zbx_date2str(_('d M Y H:i:s'), $trigger['lastchange']), 'events.php?triggerid=' . $trigger['triggerid'] . '&source=0&show_unknown=1&nav_time=' . $trigger['lastchange']);
        // actions
        $actionHint = $trigger['lastEvent'] && isset($actions[$trigger['lastEvent']['eventid']]) ? $actions[$trigger['lastEvent']['eventid']] : SPACE;
        $table->addRow(array(get_node_name_by_elid($trigger['triggerid']), $hostDiv, $description, $clock, zbx_date2age($trigger['lastchange']), $unknown, $ack, $actionHint));
    }
    // initialize blinking
    zbx_add_post_js('jqBlink.blink();');
    $script = new CJSScript(get_js("jQuery('#hat_lastiss_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')"));
    $infoDiv = new CDiv(_n('%1$d of %2$d issue is shown', '%1$d of %2$d issues are shown', count($triggers), $triggersTotalCount));
    $infoDiv->addStyle('text-align: right; padding-right: 3px;');
    return new CDiv(array($table, $infoDiv, $script));
}
コード例 #17
0
ファイル: forms.inc.php プロジェクト: omidmt/zabbix-greenplum
function get_timeperiod_form()
{
    $tblPeriod = new CTable(null, 'formElementTable');
    // init new_timeperiod variable
    $new_timeperiod = getRequest('new_timeperiod', array());
    $new = is_array($new_timeperiod);
    if (is_array($new_timeperiod)) {
        if (isset($new_timeperiod['id'])) {
            $tblPeriod->addItem(new CVar('new_timeperiod[id]', $new_timeperiod['id']));
        }
        if (isset($new_timeperiod['timeperiodid'])) {
            $tblPeriod->addItem(new CVar('new_timeperiod[timeperiodid]', $new_timeperiod['timeperiodid']));
        }
    }
    if (!is_array($new_timeperiod)) {
        $new_timeperiod = array();
        $new_timeperiod['timeperiod_type'] = TIMEPERIOD_TYPE_ONETIME;
    }
    if (!isset($new_timeperiod['every'])) {
        $new_timeperiod['every'] = 1;
    }
    if (!isset($new_timeperiod['day'])) {
        $new_timeperiod['day'] = 1;
    }
    if (!isset($new_timeperiod['hour'])) {
        $new_timeperiod['hour'] = 12;
    }
    if (!isset($new_timeperiod['minute'])) {
        $new_timeperiod['minute'] = 0;
    }
    if (!isset($new_timeperiod['start_date'])) {
        $new_timeperiod['start_date'] = 0;
    }
    if (!isset($new_timeperiod['period_days'])) {
        $new_timeperiod['period_days'] = 0;
    }
    if (!isset($new_timeperiod['period_hours'])) {
        $new_timeperiod['period_hours'] = 1;
    }
    if (!isset($new_timeperiod['period_minutes'])) {
        $new_timeperiod['period_minutes'] = 0;
    }
    if (!isset($new_timeperiod['month_date_type'])) {
        $new_timeperiod['month_date_type'] = !(bool) $new_timeperiod['day'];
    }
    // start time
    if (isset($new_timeperiod['start_time'])) {
        $new_timeperiod['hour'] = floor($new_timeperiod['start_time'] / SEC_PER_HOUR);
        $new_timeperiod['minute'] = floor(($new_timeperiod['start_time'] - $new_timeperiod['hour'] * SEC_PER_HOUR) / SEC_PER_MIN);
    }
    // period
    if (isset($new_timeperiod['period'])) {
        $new_timeperiod['period_days'] = floor($new_timeperiod['period'] / SEC_PER_DAY);
        $new_timeperiod['period_hours'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY) / SEC_PER_HOUR);
        $new_timeperiod['period_minutes'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY - $new_timeperiod['period_hours'] * SEC_PER_HOUR) / SEC_PER_MIN);
    }
    // daysofweek
    $dayofweek = '';
    $dayofweek .= !isset($new_timeperiod['dayofweek_mo']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_tu']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_we']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_th']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_fr']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_sa']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_su']) ? '0' : '1';
    if (isset($new_timeperiod['dayofweek'])) {
        $dayofweek = zbx_num2bitstr($new_timeperiod['dayofweek'], true);
    }
    $new_timeperiod['dayofweek_mo'] = $dayofweek[0];
    $new_timeperiod['dayofweek_tu'] = $dayofweek[1];
    $new_timeperiod['dayofweek_we'] = $dayofweek[2];
    $new_timeperiod['dayofweek_th'] = $dayofweek[3];
    $new_timeperiod['dayofweek_fr'] = $dayofweek[4];
    $new_timeperiod['dayofweek_sa'] = $dayofweek[5];
    $new_timeperiod['dayofweek_su'] = $dayofweek[6];
    // months
    $month = '';
    $month .= !isset($new_timeperiod['month_jan']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_feb']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_mar']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_apr']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_may']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jun']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jul']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_aug']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_sep']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_oct']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_nov']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_dec']) ? '0' : '1';
    if (isset($new_timeperiod['month'])) {
        $month = zbx_num2bitstr($new_timeperiod['month'], true);
    }
    $new_timeperiod['month_jan'] = $month[0];
    $new_timeperiod['month_feb'] = $month[1];
    $new_timeperiod['month_mar'] = $month[2];
    $new_timeperiod['month_apr'] = $month[3];
    $new_timeperiod['month_may'] = $month[4];
    $new_timeperiod['month_jun'] = $month[5];
    $new_timeperiod['month_jul'] = $month[6];
    $new_timeperiod['month_aug'] = $month[7];
    $new_timeperiod['month_sep'] = $month[8];
    $new_timeperiod['month_oct'] = $month[9];
    $new_timeperiod['month_nov'] = $month[10];
    $new_timeperiod['month_dec'] = $month[11];
    $bit_dayofweek = strrev($dayofweek);
    $bit_month = strrev($month);
    $cmbType = new CComboBox('new_timeperiod[timeperiod_type]', $new_timeperiod['timeperiod_type'], 'submit()');
    $cmbType->addItem(TIMEPERIOD_TYPE_ONETIME, _('One time only'));
    $cmbType->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $cmbType->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $cmbType->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $tblPeriod->addRow(array(_('Period type'), $cmbType));
    if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_DAILY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month)));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addRow(array(_('Every day(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 3)));
    } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_WEEKLY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month)));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addRow(array(_('Every week(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 2)));
        $tabDays = new CTable();
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday')));
        $tblPeriod->addRow(array(_('Day of week'), $tabDays));
    } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_MONTHLY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tabMonths = new CTable();
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jan]', $month[0], null, 1), _('January'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_jul]', $month[6], null, 1), _('July')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_feb]', $month[1], null, 1), _('February'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_aug]', $month[7], null, 1), _('August')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_mar]', $month[2], null, 1), _('March'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_sep]', $month[8], null, 1), _('September')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_apr]', $month[3], null, 1), _('April'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_oct]', $month[9], null, 1), _('October')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_may]', $month[4], null, 1), _('May'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_nov]', $month[10], null, 1), _('November')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jun]', $month[5], null, 1), _('June'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_dec]', $month[11], null, 1), _('December')));
        $tblPeriod->addRow(array(_('Month'), $tabMonths));
        $tblPeriod->addRow(array(_('Date'), array(new CRadioButton('new_timeperiod[month_date_type]', '0', null, null, !$new_timeperiod['month_date_type'], 'submit()'), _('Day'), SPACE, new CRadioButton('new_timeperiod[month_date_type]', '1', null, null, $new_timeperiod['month_date_type'], 'submit()'), _('Day of week'))));
        if ($new_timeperiod['month_date_type'] > 0) {
            $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
            $cmbCount = new CComboBox('new_timeperiod[every]', $new_timeperiod['every']);
            $cmbCount->addItem(1, _('First'));
            $cmbCount->addItem(2, _('Second'));
            $cmbCount->addItem(3, _('Third'));
            $cmbCount->addItem(4, _('Fourth'));
            $cmbCount->addItem(5, _('Last'));
            $td = new CCol($cmbCount);
            $td->setColSpan(2);
            $tabDays = new CTable();
            $tabDays->addRow($td);
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday')));
            $tblPeriod->addRow(array(_('Day of week'), $tabDays));
        } else {
            $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
            $tblPeriod->addRow(array(_('Day of month'), new CNumericBox('new_timeperiod[day]', $new_timeperiod['day'], 2)));
        }
    } else {
        $tblPeriod->addItem(new CVar('new_timeperiod[every]', $new_timeperiod['every'], 'new_timeperiod_every_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month), 'new_timeperiod_month_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'], 'new_timeperiod_day_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[hour]', $new_timeperiod['hour'], 'new_timeperiod_hour_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[minute]', $new_timeperiod['minute'], 'new_timeperiod_minute_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
        if (isset($_REQUEST['add_timeperiod'])) {
            $date = array('y' => getRequest('new_timeperiod_start_date_year'), 'm' => getRequest('new_timeperiod_start_date_month'), 'd' => getRequest('new_timeperiod_start_date_day'), 'h' => getRequest('new_timeperiod_start_date_hour'), 'i' => getRequest('new_timeperiod_start_date_minute'));
        } else {
            $date = zbxDateToTime($new_timeperiod['start_date'] ? $new_timeperiod['start_date'] : date(TIMESTAMP_FORMAT_ZERO_TIME, time()));
        }
        $tblPeriod->addRow(array(_('Date'), createDateSelector('new_timeperiod_start_date', $date)));
    }
    if ($new_timeperiod['timeperiod_type'] != TIMEPERIOD_TYPE_ONETIME) {
        $tblPeriod->addRow(array(_('At (hour:minute)'), array(new CNumericBox('new_timeperiod[hour]', $new_timeperiod['hour'], 2), ':', new CNumericBox('new_timeperiod[minute]', $new_timeperiod['minute'], 2))));
    }
    $perHours = new CComboBox('new_timeperiod[period_hours]', $new_timeperiod['period_hours'], null, range(0, 23));
    $perMinutes = new CComboBox('new_timeperiod[period_minutes]', $new_timeperiod['period_minutes'], null, range(0, 59));
    $tblPeriod->addRow(array(_('Maintenance period length'), array(new CNumericBox('new_timeperiod[period_days]', $new_timeperiod['period_days'], 3), _('Days') . SPACE . SPACE, $perHours, _('Hours') . SPACE . SPACE, $perMinutes, _('Minutes'))));
    return $tblPeriod;
}
コード例 #18
0
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $this->dataId = 'discovery';
     $sort_field = $this->data['sort'];
     $sort_order = $this->data['sortorder'];
     $druleid = $this->data['druleid'];
     // discovery rules
     $options = ['output' => ['druleid', 'name'], 'selectDHosts' => ['dhostid', 'status', 'lastup', 'lastdown'], 'filter' => ['status' => DRULE_STATUS_ACTIVE]];
     if ($druleid > 0) {
         $options['druleids'] = $druleid;
         // set selected discovery rule id
     }
     $drules = API::DRule()->get($options);
     if ($drules) {
         order_result($drules, 'name');
     }
     // discovery services
     $options = ['selectHosts' => ['hostid', 'name', 'status'], 'output' => ['dserviceid', 'type', 'key_', 'port', 'status', 'lastup', 'lastdown', 'ip', 'dns'], 'sortfield' => $sort_field, 'sortorder' => $sort_order, 'limitSelects' => 1];
     if ($druleid > 0) {
         $options['druleids'] = $druleid;
     } else {
         $options['druleids'] = zbx_objectValues($drules, 'druleid');
     }
     $dservices = API::DService()->get($options);
     // user macros
     $macros = API::UserMacro()->get(['output' => ['macro', 'value'], 'globalmacro' => true]);
     $macros = zbx_toHash($macros, 'macro');
     // services
     $services = [];
     foreach ($dservices as $dservice) {
         $key_ = $dservice['key_'];
         if ($key_ !== '') {
             if (array_key_exists($key_, $macros)) {
                 $key_ = $macros[$key_]['value'];
             }
             $key_ = ': ' . $key_;
         }
         $service_name = discovery_check_type2str($dservice['type']) . discovery_port2str($dservice['type'], $dservice['port']) . $key_;
         $services[$service_name] = 1;
     }
     ksort($services);
     // discovery services to hash
     $dservices = zbx_toHash($dservices, 'dserviceid');
     // discovery hosts
     $dhosts = API::DHost()->get(['druleids' => zbx_objectValues($drules, 'druleid'), 'selectDServices' => ['dserviceid', 'ip', 'dns', 'type', 'status', 'key_'], 'output' => ['dhostid', 'lastdown', 'lastup', 'druleid']]);
     $dhosts = zbx_toHash($dhosts, 'dhostid');
     $header = [make_sorting_header(_('Discovered device'), 'ip', $sort_field, $sort_order, 'zabbix.php?action=discovery.view'), _('Monitored host'), _('Uptime') . '/' . _('Downtime')];
     foreach ($services as $name => $foo) {
         $header[] = (new CColHeader($name))->addClass('vertical_rotation');
     }
     // create table
     $table = (new CTableInfo())->makeVerticalRotation()->setHeader($header);
     foreach ($drules as $drule) {
         $discovery_info = [];
         foreach ($drule['dhosts'] as $dhost) {
             if ($dhost['status'] == DHOST_STATUS_DISABLED) {
                 $hclass = 'disabled';
                 $htime = $dhost['lastdown'];
             } else {
                 $hclass = 'enabled';
                 $htime = $dhost['lastup'];
             }
             // $primary_ip stores the primary host ip of the dhost
             $primary_ip = '';
             foreach ($dhosts[$dhost['dhostid']]['dservices'] as $dservice) {
                 $dservice = $dservices[$dservice['dserviceid']];
                 $hostName = '';
                 $host = reset($dservices[$dservice['dserviceid']]['hosts']);
                 if (!is_null($host)) {
                     $hostName = $host['name'];
                 }
                 if ($primary_ip !== '') {
                     if ($primary_ip === $dservice['ip']) {
                         $htype = 'primary';
                     } else {
                         $htype = 'slave';
                     }
                 } else {
                     $primary_ip = $dservice['ip'];
                     $htype = 'primary';
                 }
                 if (!array_key_exists($dservice['ip'], $discovery_info)) {
                     $discovery_info[$dservice['ip']] = ['ip' => $dservice['ip'], 'dns' => $dservice['dns'], 'type' => $htype, 'class' => $hclass, 'host' => $hostName, 'time' => $htime];
                 }
                 if ($dservice['status'] == DSVC_STATUS_DISABLED) {
                     $class = ZBX_STYLE_INACTIVE_BG;
                     $time = 'lastdown';
                 } else {
                     $class = ZBX_STYLE_ACTIVE_BG;
                     $time = 'lastup';
                 }
                 $key_ = $dservice['key_'];
                 if ($key_ !== '') {
                     if (array_key_exists($key_, $macros)) {
                         $key_ = $macros[$key_]['value'];
                     }
                     $key_ = NAME_DELIMITER . $key_;
                 }
                 $service_name = discovery_check_type2str($dservice['type']) . discovery_port2str($dservice['type'], $dservice['port']) . $key_;
                 $discovery_info[$dservice['ip']]['services'][$service_name] = ['class' => $class, 'time' => $dservice[$time]];
             }
         }
         if ($druleid == 0 && $discovery_info) {
             $col = new CCol([bold($drule['name']), SPACE . '(' . _n('%d device', '%d devices', count($discovery_info)) . ')']);
             $col->setColSpan(count($services) + 3);
             $table->addRow($col);
         }
         order_result($discovery_info, $sort_field, $sort_order);
         foreach ($discovery_info as $ip => $h_data) {
             $dns = $h_data['dns'] == '' ? '' : ' (' . $h_data['dns'] . ')';
             $row = [$h_data['type'] == 'primary' ? (new CSpan($ip . $dns))->addClass($h_data['class']) : new CSpan(SPACE . SPACE . $ip . $dns), new CSpan(array_key_exists('host', $h_data) ? $h_data['host'] : ''), (new CSpan($h_data['time'] == 0 || $h_data['type'] === 'slave' ? '' : convert_units(['value' => time() - $h_data['time'], 'units' => 'uptime'])))->addClass($h_data['class'])];
             foreach ($services as $name => $foo) {
                 $class = null;
                 $time = SPACE;
                 $hint = (new CDiv(SPACE))->addClass($class);
                 $hint_table = null;
                 if (array_key_exists($name, $h_data['services'])) {
                     $class = $h_data['services'][$name]['class'];
                     $time = $h_data['services'][$name]['time'];
                     $hint_table = (new CTableInfo())->setAttribute('style', 'width: auto;');
                     if ($class == ZBX_STYLE_ACTIVE_BG) {
                         $hint_table->setHeader(_('Uptime'));
                     } else {
                         $hint_table->setHeader(_('Downtime'));
                     }
                     $hint_table->addRow((new CCol(zbx_date2age($h_data['services'][$name]['time'])))->addClass($class));
                 }
                 $column = (new CCol($hint))->addClass($class);
                 if (!is_null($hint_table)) {
                     $column->setHint($hint_table);
                 }
                 $row[] = $column;
             }
             $table->addRow($row);
         }
     }
     return $this->getOutput($table, true, $this->data);
 }
コード例 #19
0
        default:
            $details = '';
            break;
    }
    // action list
    $actionLinks = array();
    if (!empty($mediaType['listOfActions'])) {
        foreach ($mediaType['listOfActions'] as $action) {
            $actionLinks[] = new CLink($action['name'], 'actionconf.php?form=update&actionid=' . $action['actionid']);
            $actionLinks[] = ', ';
        }
        array_pop($actionLinks);
    } else {
        $actionLinks = '-';
    }
    $actionColumn = new CCol($actionLinks);
    $actionColumn->setAttribute('style', 'white-space: normal;');
    $statusLink = 'media_types.php?go=' . ($mediaType['status'] == MEDIA_TYPE_STATUS_DISABLED ? 'activate' : 'disable') . '&mediatypeids' . SQUAREBRACKETS . '=' . $mediaType['mediatypeid'];
    $status = MEDIA_TYPE_STATUS_ACTIVE == $mediaType['status'] ? new CLink(_('Enabled'), $statusLink, 'enabled') : new CLink(_('Disabled'), $statusLink, 'disabled');
    // append row
    $mediaTypeTable->addRow(array(new CCheckBox('mediatypeids[' . $mediaType['mediatypeid'] . ']', null, null, $mediaType['mediatypeid']), $this->data['displayNodes'] ? $mediaType['nodename'] : null, new CLink($mediaType['description'], '?form=edit&mediatypeid=' . $mediaType['mediatypeid']), media_type2str($mediaType['typeid']), $status, $actionColumn, $details));
}
// create go button
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('activate', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected media types?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('disable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected media types?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('delete', _('Delete selected'));
コード例 #20
0
    if ($result != '-') {
        $style = $result == 'TRUE' ? 'background-color: #ccf; color: #00f;' : 'background-color: #fcc; color: #f00;';
    }
    $col = new CCol($result);
    $col->setAttribute('style', $style);
    $res_table->addRow(new CRow(array($e['list'], $col)));
}
$result = '-';
if ($allowedTesting && $test) {
    $result = evalExpressionData($expression, $macrosData, $octet);
}
$style = 'text-align: center;';
if ($result != '-') {
    $style = $result == 'TRUE' ? 'background-color: #ccf; color: #00f;' : 'background-color: #fcc; color: #f00;';
}
$col = new CCol($result);
$col->setAttribute('style', $style);
$res_table->setFooter(array($outline, $col), $res_table->headerClass);
$frm_test->addRow(_('Result'), $res_table);
// action buttons
$btn_test = new CSubmit('test_expression', _('Test'));
if (!$allowedTesting) {
    $btn_test->setAttribute('disabled', 'disabled');
}
$frm_test->addItemToBottomRow($btn_test);
$frm_test->addItemToBottomRow(SPACE);
$btn_close = new CButton('close', _('Close'), 'javascript: self.close();');
$frm_test->addItemToBottomRow($btn_close);
$frm_test->show();
//------------------------ </FORM> ---------------------------
require_once dirname(__FILE__) . '/include/page_footer.php';
コード例 #21
0
ファイル: blocks.inc.php プロジェクト: phedders/zabbix
function make_latest_data()
{
    global $USER_DETAILS;
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
    while ($db_app = DBfetch($db_applications)) {
        $db_items = DBselect('SELECT DISTINCT i.* ' . ' FROM items i,items_applications ia' . ' WHERE ia.applicationid=' . $db_app['applicationid'] . ' AND i.itemid=ia.itemid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . order_by('i.description,i.itemid,i.lastclock'));
        $app_rows = array();
        $item_cnt = 0;
        while ($db_item = DBfetch($db_items)) {
            $description = item_description($db_item);
            if (!zbx_empty($_REQUEST['select']) && !zbx_stristr($description, $_REQUEST['select'])) {
                continue;
            }
            ++$item_cnt;
            if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($show_all_apps)) {
                continue;
            }
            if (isset($db_item['lastclock'])) {
                $lastclock = date(S_DATE_FORMAT_YMDHMS, $db_item['lastclock']);
            } else {
                $lastclock = new CCol('-', 'center');
            }
            $lastvalue = format_lastvalue($db_item);
            if (isset($db_item['lastvalue']) && isset($db_item['prevvalue']) && $db_item['value_type'] == 0 && $db_item['lastvalue'] - $db_item['prevvalue'] != 0) {
                if ($db_item['lastvalue'] - $db_item['prevvalue'] < 0) {
                    $change = convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']);
                } else {
                    $change = '+' . convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']);
                }
                $change = nbsp($change);
            } else {
                $change = new CCol('-', 'center');
            }
            if ($db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $db_item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
                $actions = new CLink(S_GRAPH, 'history.php?action=showgraph&itemid=' . $db_item['itemid'], 'action');
            } else {
                $actions = new CLink(S_HISTORY, 'history.php?action=showvalues&period=3600&itemid=' . $db_item['itemid'], 'action');
            }
            array_push($app_rows, new CRow(array(is_show_all_nodes() ? SPACE : null, $_REQUEST['hostid'] > 0 ? NULL : SPACE, str_repeat(SPACE, 6) . $description, $lastclock, new CCol($lastvalue, $lastvalue == '-' ? 'center' : null), $change, $actions)));
        }
        if ($item_cnt > 0) {
            if (uint_in_array($db_app['applicationid'], $_REQUEST['applications']) || isset($show_all_apps)) {
                $link = new CLink(new CImg('images/general/opened.gif'), '?close=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
            } else {
                $link = new CLink(new CImg('images/general/closed.gif'), '?open=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
            }
            $col = new CCol(array($link, SPACE, bold($db_app['name']), SPACE . '(' . $item_cnt . SPACE . S_ITEMS . ')'));
            $col->setColSpan(5);
            $table->ShowRow(array(get_node_name_by_elid($db_app['hostid']), $_REQUEST['hostid'] > 0 ? NULL : $db_app['host'], $col));
            $any_app_exist = true;
            foreach ($app_rows as $row) {
                $table->ShowRow($row);
            }
        }
    }
}
コード例 #22
0
ファイル: search.php プロジェクト: phedders/zabbix
    $hosts_count = CTemplate::get($params);
    $overalCount = $hosts_count['rowscount'];
    $viewCount = count($templates);
    $header = array(is_show_all_nodes() ? new CCol(S_NODE) : null, new CCol(S_TEMPLATES), new CCol(S_ITEMS), new CCol(S_TRIGGERS), new CCol(S_GRAPHS));
    $table = new CTableInfo();
    $table->setHeader($header);
    foreach ($templates as $num => $template) {
        $templateid = $template['hostid'];
        $groupid = isset($hostsgroups[$templateid]) ? $hostsgroups[$templateid] : 0;
        $link = 'groupid=' . $groupid . '&hostid=' . $templateid;
        $caption = make_decoration($template['host'], $search);
        $table->addRow(array(get_node_name_by_elid($templateid), new CLink($caption, 'hosts.php?config=3&hostid=' . $templateid), new CLink(S_GO, 'items.php?' . $link), new CLink(S_GO, 'triggers.php?' . $link), new CLink(S_GO, 'graphs.php?' . $link)));
    }
    $table->setFooter(new CCol(S_DISPLAYING . SPACE . $viewCount . SPACE . S_OF_SMALL . SPACE . $overalCount . SPACE . S_FOUND_SMALL));
    $wdgt_templates = new CWidget('search_templates', $table);
    $wdgt_templates->addHeader(S_TEMPLATES, SPACE);
    $right_tab->addRow($wdgt_templates);
}
//----------------
$td_l = new CCol($left_tab);
$td_l->setAttribute('valign', 'top');
$td_r = new CCol($right_tab);
$td_r->setAttribute('valign', 'top');
$outer_table = new CTable();
$outer_table->setAttribute('border', 0);
$outer_table->setCellPadding(1);
$outer_table->setCellSpacing(1);
$outer_table->addRow(array($td_l, $td_r));
$search_wdgt->addItem($outer_table);
$search_wdgt->show();
include_once 'include/page_footer.php';
コード例 #23
0
                        $ack = new CLink(S_NOT_ACKNOWLEDGED, 'acknow.php?eventid=' . $row_event['eventid'] . '&backurl=' . $page['file'], 'on');
                    }
                } else {
                    $ack = SPACE;
                }
            }
            if ($row_event['acknowledged'] == 0 && $row_event['value'] == TRIGGER_VALUE_TRUE) {
                $ack_cb = new CCheckBox('events[' . $row_event['eventid'] . ']', 'no', NULL, $row_event['eventid']);
            } else {
                $ack_cb = SPACE;
            }
            $clock = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $row_event['clock']), 'tr_events.php?triggerid=' . $trigger['triggerid'] . '&eventid=' . $row_event['eventid']);
            $next_clock = isset($trigger['events'][$enum - 1]) ? $trigger['events'][$enum - 1]['clock'] : time();
            $empty_col = new CCol(SPACE);
            $empty_col->setColSpan(3);
            $ack_cb_col = new CCol($ack_cb);
            $ack_cb_col->setColSpan(2);
            $row = new CRow(array(SPACE, $config['event_ack_enable'] ? $ack_cb_col : null, $status, $clock, zbx_date2age($row_event['clock']), zbx_date2age($next_clock, $row_event['clock']), $config['event_ack_enable'] ? $ack : NULL, is_show_all_nodes() ? SPACE : null, $empty_col), 'odd_row');
            $row->setAttribute('data-parentid', $trigger['triggerid']);
            $row->addStyle('display: none;');
            $table->addRow($row);
            if ($i > $config['event_show_max']) {
                break;
            }
        }
    }
}
//----- GO ------
$footer = null;
if ($config['event_ack_enable']) {
    $goBox = new CComboBox('go');
コード例 #24
0
ファイル: CWidget.php プロジェクト: TonywalkerCN/Zabbix
 private function createFlicker($col1, $col2 = null)
 {
     $table = new CTable(null, 'textwhite maxwidth middle flicker');
     $table->setCellSpacing(0);
     $table->setCellPadding(1);
     if (!is_null($col2)) {
         $td_r = new CCol($col2, 'flicker_r');
         $td_r->setAttribute('align', 'right');
         $table->addRow(array(new CCol($col1, 'flicker_l'), $td_r));
     } else {
         $td_c = new CCol($col1, 'flicker_c');
         $td_c->setAttribute('align', 'center');
         $table->addRow($td_c);
     }
     return $table;
 }
コード例 #25
0
ファイル: triggers.inc.php プロジェクト: rennhak/zabbix
function get_trigger_overview_cells(&$table_row, &$trhosts, &$hostname)
{
    $css_class = NULL;
    unset($tr_ov_menu);
    $ack = null;
    if (isset($trhosts[$hostname])) {
        unset($ack_menu);
        switch ($trhosts[$hostname]['value']) {
            case TRIGGER_VALUE_TRUE:
                $css_class = get_severity_style($trhosts[$hostname]['priority']);
                if ($ack = get_last_event_by_triggerid($trhosts[$hostname]['triggerid'])) {
                    $ack_menu = array(S_ACKNOWLEDGE, 'acknow.php?eventid=' . $ack['eventid'], array('tw' => '_blank'));
                }
                if (1 == $ack['acknowledged']) {
                    $ack = new CImg('images/general/tick.png', 'ack');
                } else {
                    $ack = null;
                }
                break;
            case TRIGGER_VALUE_FALSE:
                $css_class = 'normal';
                break;
            default:
                $css_class = 'unknown_trigger';
        }
        $style = 'cursor: pointer; ';
        if (time(NULL) - $trhosts[$hostname]['lastchange'] < 300) {
            $style .= 'background-image: url(images/gradients/blink1.gif); ' . 'background-position: top left; ' . 'background-repeat: repeat;';
        } else {
            if (time(NULL) - $trhosts[$hostname]['lastchange'] < 900) {
                $style .= 'background-image: url(images/gradients/blink2.gif); ' . 'background-position: top left; ' . 'background-repeat: repeat;';
            }
        }
        unset($item_menu);
        $tr_ov_menu = array(array(S_TRIGGER, null, null, array('outer' => array('pum_oheader'), 'inner' => array('pum_iheader'))), array(S_EVENTS, 'events.php?triggerid=' . $trhosts[$hostname]['triggerid'], array('tw' => '_blank')));
        if (isset($ack_menu)) {
            $tr_ov_menu[] = $ack_menu;
        }
        $db_items = DBselect('select distinct i.itemid, i.description, i.key_, i.value_type ' . ' from items i, functions f ' . ' where f.itemid=i.itemid and f.triggerid=' . $trhosts[$hostname]['triggerid']);
        while ($item_data = DBfetch($db_items)) {
            $description = item_description($item_data);
            switch ($item_data['value_type']) {
                case ITEM_VALUE_TYPE_UINT64:
                case ITEM_VALUE_TYPE_FLOAT:
                    $action = 'showgraph';
                    $status_bar = S_SHOW_GRAPH_OF_ITEM . ' \'' . $description . '\'';
                    break;
                case ITEM_VALUE_TYPE_LOG:
                case ITEM_VALUE_TYPE_STR:
                case ITEM_VALUE_TYPE_TEXT:
                default:
                    $action = 'showlatest';
                    $status_bar = S_SHOW_VALUES_OF_ITEM . ' \'' . $description . '\'';
                    break;
            }
            if (strlen($description) > 25) {
                $description = substr($description, 0, 22) . '...';
            }
            $item_menu[$action][] = array($description, 'history.php?action=' . $action . '&itemid=' . $item_data['itemid'] . '&period=3600', array('tw' => '', 'sb' => $status_bar));
        }
        if (isset($item_menu['showgraph'])) {
            $tr_ov_menu[] = array(S_GRAPHS, null, null, array('outer' => array('pum_oheader'), 'inner' => array('pum_iheader')));
            $tr_ov_menu = array_merge($tr_ov_menu, $item_menu['showgraph']);
        }
        if (isset($item_menu['showlatest'])) {
            $tr_ov_menu[] = array(S_VALUES, null, null, array('outer' => array('pum_oheader'), 'inner' => array('pum_iheader')));
            $tr_ov_menu = array_merge($tr_ov_menu, $item_menu['showlatest']);
        }
        unset($item_menu);
    }
    // dependency
    // TRIGGERS ON WHICH DEPENDS THIS
    $desc = array();
    if (isset($trhosts[$hostname])) {
        $triggerid = $trhosts[$hostname]['triggerid'];
        $dependency = false;
        $dep_table = new CTableInfo();
        $dep_table->AddOption('style', 'width: 200px;');
        $dep_table->addRow(bold(S_DEPENDS_ON . ':'));
        $sql_dep = 'SELECT * FROM trigger_depends WHERE triggerid_down=' . $triggerid;
        $dep_res = DBselect($sql_dep);
        while ($dep_row = DBfetch($dep_res)) {
            $dep_table->addRow(SPACE . '-' . SPACE . expand_trigger_description($dep_row['triggerid_up']));
            $dependency = true;
        }
        if ($dependency) {
            $img = new Cimg('images/general/down_icon.png', 'DEP_DOWN');
            $img->AddOption('style', 'vertical-align: middle; border: 0px;');
            $img->SetHint($dep_table);
            array_push($desc, $img);
        }
        unset($img, $dep_table, $dependency);
        // TRIGGERS THAT DEPEND ON THIS
        $dependency = false;
        $dep_table = new CTableInfo();
        $dep_table->AddOption('style', 'width: 200px;');
        $dep_table->addRow(bold(S_DEPENDENT . ':'));
        $sql_dep = 'SELECT * FROM trigger_depends WHERE triggerid_up=' . $triggerid;
        $dep_res = DBselect($sql_dep);
        while ($dep_row = DBfetch($dep_res)) {
            $dep_table->addRow(SPACE . '-' . SPACE . expand_trigger_description($dep_row['triggerid_down']));
            $dependency = true;
        }
        if ($dependency) {
            $img = new Cimg('images/general/up_icon.png', 'DEP_UP');
            $img->AddOption('style', 'vertical-align: middle; border: 0px;');
            $img->SetHint($dep_table);
            array_push($desc, $img);
        }
        unset($img, $dep_table, $dependency);
    }
    //------------------------
    $status_col = new CCol(array($desc, $ack), $css_class);
    if (isset($style)) {
        $status_col->AddOption('style', $style);
    }
    if (isset($tr_ov_menu)) {
        $tr_ov_menu = new CPUMenu($tr_ov_menu, 170);
        $status_col->OnClick($tr_ov_menu->GetOnActionJS());
        $status_col->AddAction('onmouseover', 'this.old_border=this.style.border; this.style.border=\'1px dotted #0C0CF0\'');
        $status_col->AddAction('onmouseout', 'this.style.border=this.old_border;');
    }
    array_push($table_row, $status_col);
    return $table_row;
}
コード例 #26
0
ファイル: tr_events.php プロジェクト: rennhak/zabbix
$fs_icon = new CDiv(SPACE, 'fullscreen');
$fs_icon->addOption('title', $_REQUEST['fullscreen'] ? S_NORMAL . ' ' . S_VIEW : S_FULLSCREEN);
$fs_icon->addAction('onclick', new CScript("javascript: document.location = '" . $url . "';"));
//-------
$left_tab = new CTable();
$left_tab->setCellPadding(3);
$left_tab->setCellSpacing(3);
$left_tab->addOption('border', 0);
$left_tab->addRow(create_hat(S_EVENT . SPACE . S_SOURCE . SPACE . S_DETAILS, make_trigger_details($_REQUEST['triggerid'], $trigger_data), null, 'hat_triggerdetails'));
$left_tab->addRow(create_hat(S_EVENT_DETAILS, make_event_details($_REQUEST['eventid']), null, 'hat_eventdetails'));
$right_tab = new CTable();
$right_tab->setCellPadding(3);
$right_tab->setCellSpacing(3);
$right_tab->addOption('border', 0);
$right_tab->addRow(create_hat(S_ACKNOWLEDGES, make_acktab_by_eventid($_REQUEST['eventid']), null, 'hat_eventack', get_profile('web.tr_events.hats.hat_eventack.state', 1)));
$right_tab->addRow(create_hat(S_MESSAGE_ACTIONS, get_action_msgs_for_event($_REQUEST['eventid']), null, 'hat_eventactionmsgs', get_profile('web.tr_events.hats.hat_eventactionmsgs.state', 1)));
$right_tab->addRow(create_hat(S_COMMAND_ACTIONS, get_action_cmds_for_event($_REQUEST['eventid']), null, 'hat_eventactioncmds', get_profile('web.tr_events.hats.hat_eventactioncmds.state', 1)));
$right_tab->addRow(create_hat(S_EVENTS . SPACE . S_LIST . SPACE . '[' . S_LAST . ' 20]', make_small_eventlist($_REQUEST['triggerid'], $trigger_data), null, 'hat_eventlist', get_profile('web.tr_events.hats.hat_eventlist.state', 1)));
$td_l = new CCol($left_tab);
$td_l->addOption('valign', 'top');
$td_r = new CCol($right_tab);
$td_r->addOption('valign', 'top');
$outer_table = new CTable();
$outer_table->addOption('border', 0);
$outer_table->setCellPadding(1);
$outer_table->setCellSpacing(1);
$outer_table->addRow(array($td_l, $td_r));
$p_elements[] = $outer_table;
$latest_hat = create_hat($text, $p_elements, array($fs_icon), 'hat_tr_events', get_profile('web.tr_events.hats.hat_tr_events.state', 1));
$latest_hat->show();
include_once 'include/page_footer.php';
コード例 #27
0
$imageComboBoxForm = new CForm();
$imageComboBoxForm->addItem(_('Type') . SPACE);
$imageComboBoxForm->addItem($imageComboBox);
$this->data['widget']->addHeader(_('Images'), $imageComboBoxForm);
// form
$imageForm = new CForm();
$imageForm->setName('imageForm');
$imageForm->addItem(BR());
$imageTable = new CTable(_('No images found.'), 'header_wide padding_standard');
$count = 0;
$imageRow = new CRow();
foreach ($this->data['images'] as $image) {
    $img = $image['imagetype'] == IMAGE_TYPE_BACKGROUND ? new CLink(new CImg('imgstore.php?width=200&height=200&iconid=' . $image['imageid'], 'no image'), 'image.php?imageid=' . $image['imageid']) : new CImg('imgstore.php?iconid=' . $image['imageid'], 'no image');
    $nodeName = $this->data['displayNodes'] ? new CSpan($image['nodename'], 'unknown') : null;
    $name = new CLink($image['name'], 'adm.images.php?form=update&imageid=' . $image['imageid']);
    $imgColumn = new CCol();
    $imgColumn->setAttribute('align', 'center');
    $imgColumn->addItem(array($img, BR(), $nodeName, $name), 'center');
    $imageRow->addItem($imgColumn);
    $count++;
    if ($count % 4 == 0) {
        $imageTable->addRow($imageRow);
        $imageRow = new CRow();
    }
}
if ($count > 0) {
    while ($count % 4 != 0) {
        $imageRow->addItem(SPACE);
        $count++;
    }
    $imageTable->addRow($imageRow);
コード例 #28
0
foreach ($this->data['slides'] as $step => $slides) {
    $name = '';
    if (!empty($slides['screenid'])) {
        $screen = get_screen_by_screenid($slides['screenid']);
        if (!empty($screen['name'])) {
            $name = $screen['name'];
        }
    }
    $delay = new CNumericBox('slides[' . $step . '][delay]', !empty($slides['delay']) ? $slides['delay'] : '', 5, 'no', true, false);
    $delay->setAttribute('placeholder', _('default'));
    $removeButton = new CButton('remove_' . $step, _('Remove'), 'javascript: removeSlide(this);', 'link_menu');
    $removeButton->setAttribute('remove_slide', $step);
    $row = new CRow(array(new CSpan(null, 'ui-icon ui-icon-arrowthick-2-n-s move'), new CSpan($i++ . ':', 'rowNum', 'current_slide_' . $step), $name, $delay, $removeButton), 'sortable', 'slides_' . $step);
    $slideTable->addRow($row);
}
$addButtonColumn = new CCol(empty($this->data['work_slide']) ? new CButton('add', _('Add'), 'return PopUp("popup.php?srctbl=screens&srcfld1=screenid&dstfrm=' . $slideForm->getName() . '&multiselect=1", 450, 450)', 'link_menu') : null, null, 5);
$addButtonColumn->setAttribute('style', 'vertical-align: middle;');
$slideTable->addRow(new CRow($addButtonColumn, null, 'screenListFooter'));
$slideFormList->addRow(_('Slides'), new CDiv($slideTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
// append tabs to form
$slideTab = new CTabView();
$slideTab->addTab('slideTab', _('Slide'), $slideFormList);
$slideForm->addItem($slideTab);
// append buttons to form
if (empty($this->data['slideshowid'])) {
    $slideForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), new CButtonCancel()));
} else {
    $slideForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), array(new CSubmit('clone', _('Clone')), new CButtonDelete(_('Delete slide show?'), url_param('form') . url_param('slideshowid') . url_param('config')), new CButtonCancel())));
}
$slideWidget->addItem($slideForm);
return $slideWidget;
コード例 #29
0
ファイル: latest.php プロジェクト: rennhak/zabbix
unset($db_host);
foreach ($db_hosts as $hostid => $db_host) {
    if (!isset($tab_rows[$hostid])) {
        continue;
    }
    $app_rows = $tab_rows[$hostid];
    if (uint_in_array(0, $_REQUEST['applications']) || isset($show_all_apps)) {
        $url = '?close=1&applicationid=0' . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select');
        $link = new CLink(new CImg('images/general/opened.gif'), $url);
        //			$link = new CLink(new CImg('images/general/opened.gif'),$url,null,"javascript: return updater.onetime_update('".ZBX_PAGE_MAIN_HAT."','".$url."');");
    } else {
        $url = '?open=1&applicationid=0' . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select');
        $link = new CLink(new CImg('images/general/closed.gif'), $url);
        //			$link = new CLink(new CImg('images/general/closed.gif'),$url,null,"javascript: return updater.onetime_update('".ZBX_PAGE_MAIN_HAT."','".$url."');");
    }
    $col = new CCol(array($link, SPACE, bold(S_MINUS_OTHER_MINUS), SPACE . '(' . $db_host['item_cnt'] . SPACE . S_ITEMS . ')'));
    $col->SetColSpan(5);
    $table->AddRow(array(get_node_name_by_elid($db_host['hostid']), $_REQUEST['hostid'] > 0 ? NULL : $db_host['host'], $col));
    foreach ($app_rows as $row) {
        $table->AddRow($row);
    }
}
$p_elements[] = $table;
/*
// Refresh tab
	$refresh_tab = array(
		array('id'	=> ZBX_PAGE_MAIN_HAT,
				'interval' 	=> $USER_DETAILS['refresh'],
				'url'	=>	zbx_empty($_SERVER['QUERY_STRING'])?'':'?'.$_SERVER['QUERY_STRING'],
			)
	);
コード例 #30
-1
ファイル: func.inc.php プロジェクト: TonywalkerCN/Zabbix
function show_messages($bool = true, $okmsg = null, $errmsg = null)
{
    global $page, $ZBX_MESSAGES;
    if (!defined('PAGE_HEADER_LOADED')) {
        return null;
    }
    if (defined('ZBX_API_REQUEST')) {
        return null;
    }
    if (!isset($page['type'])) {
        $page['type'] = PAGE_TYPE_HTML;
    }
    $imageMessages = array();
    if (!$bool && !is_null($errmsg)) {
        $msg = _('ERROR') . ': ' . $errmsg;
    } elseif ($bool && !is_null($okmsg)) {
        $msg = $okmsg;
    }
    if (isset($msg)) {
        switch ($page['type']) {
            case PAGE_TYPE_IMAGE:
                // save all of the messages in an array to display them later in an image
                $imageMessages[] = array('text' => $msg, 'color' => !$bool ? array('R' => 255, 'G' => 0, 'B' => 0) : array('R' => 34, 'G' => 51, 'B' => 68));
                break;
            case PAGE_TYPE_XML:
                echo htmlspecialchars($msg) . "\n";
                break;
            case PAGE_TYPE_HTML:
            default:
                $msg_tab = new CTable($msg, $bool ? 'msgok' : 'msgerr');
                $msg_tab->setCellPadding(0);
                $msg_tab->setCellSpacing(0);
                $row = array();
                $msg_col = new CCol(bold($msg), 'msg_main msg');
                $msg_col->setAttribute('id', 'page_msg');
                $row[] = $msg_col;
                if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) {
                    $msg_details = new CDiv(_('Details'), 'blacklink');
                    $msg_details->setAttribute('onclick', 'javascript: showHide("msg_messages", IE ? "block" : "table");');
                    $msg_details->setAttribute('title', _('Maximize') . '/' . _('Minimize'));
                    array_unshift($row, new CCol($msg_details, 'clr'));
                }
                $msg_tab->addRow($row);
                $msg_tab->show();
                break;
        }
    }
    if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) {
        if ($page['type'] == PAGE_TYPE_IMAGE) {
            foreach ($ZBX_MESSAGES as $msg) {
                // save all of the messages in an array to display them later in an image
                if ($msg['type'] == 'error') {
                    $imageMessages[] = array('text' => $msg['message'], 'color' => array('R' => 255, 'G' => 55, 'B' => 55));
                } else {
                    $imageMessages[] = array('text' => $msg['message'], 'color' => array('R' => 155, 'G' => 155, 'B' => 55));
                }
            }
        } elseif ($page['type'] == PAGE_TYPE_XML) {
            foreach ($ZBX_MESSAGES as $msg) {
                echo '[' . $msg['type'] . '] ' . $msg['message'] . "\n";
            }
        } else {
            $lst_error = new CList(null, 'messages');
            foreach ($ZBX_MESSAGES as $msg) {
                $lst_error->addItem($msg['message'], $msg['type']);
                $bool = $bool && 'error' !== strtolower($msg['type']);
            }
            $msg_show = 6;
            $msg_count = count($ZBX_MESSAGES);
            if ($msg_count > $msg_show) {
                $msg_count = $msg_show * 16;
                $lst_error->setAttribute('style', 'height: ' . $msg_count . 'px;');
            }
            $tab = new CTable(null, $bool ? 'msgok' : 'msgerr');
            $tab->setCellPadding(0);
            $tab->setCellSpacing(0);
            $tab->setAttribute('id', 'msg_messages');
            $tab->setAttribute('style', 'width: 100%;');
            if (isset($msg_tab) && $bool) {
                $tab->setAttribute('style', 'display: none;');
            }
            $tab->addRow(new CCol($lst_error, 'msg'));
            $tab->show();
        }
        $ZBX_MESSAGES = null;
    }
    // draw an image with the messages
    if ($page['type'] == PAGE_TYPE_IMAGE && count($imageMessages) > 0) {
        $imageFontSize = 8;
        // calculate the size of the text
        $imageWidth = 0;
        $imageHeight = 0;
        foreach ($imageMessages as &$msg) {
            $size = imageTextSize($imageFontSize, 0, $msg['text']);
            $msg['height'] = $size['height'] - $size['baseline'];
            // calculate the total size of the image
            $imageWidth = max($imageWidth, $size['width']);
            $imageHeight += $size['height'] + 1;
        }
        unset($msg);
        // additional padding
        $imageWidth += 2;
        $imageHeight += 2;
        // create the image
        $canvas = imagecreate($imageWidth, $imageHeight);
        imagefilledrectangle($canvas, 0, 0, $imageWidth, $imageHeight, imagecolorallocate($canvas, 255, 255, 255));
        // draw each message
        $y = 1;
        foreach ($imageMessages as $msg) {
            $y += $msg['height'];
            imageText($canvas, $imageFontSize, 0, 1, $y, imagecolorallocate($canvas, $msg['color']['R'], $msg['color']['G'], $msg['color']['B']), $msg['text']);
        }
        imageOut($canvas);
        imagedestroy($canvas);
    }
}