// set an ID for the hidden input so that it wouldn't conflict with the ID of the "Go" button list $form->addItem(new CVar('action', HISTORY_BATCH_GRAPH, 'action-hidden')); // table $table = new CTableInfo($filterSet ? _('No values found.') : _('Specify some filter condition to see the values.')); if ($singleHostSelected) { $hostHeader = null; $hostColumn = null; } else { $hostHeader = make_sorting_header(_('Host'), 'host', $sortField, $sortOrder); $hostHeader->addClass('latest-host'); $hostHeader->setAttribute('title', _('Host')); $hostColumn = ''; } $nameHeader = make_sorting_header(_('Name'), 'name', $sortField, $sortOrder); $nameHeader->setAttribute('title', _('Name')); $lastCheckHeader = make_sorting_header(_('Last check'), 'lastclock', $sortField, $sortOrder); $lastCheckHeader->addClass('latest-lastcheck'); $lastCheckHeader->setAttribute('title', _('Last check')); $lastValueHeader = new CCol(new CSpan(_('Last value')), 'latest-lastvalue'); $lastValueHeader->setAttribute('title', _('Last value')); $lastDataHeader = new CCol(new CSpan(_x('Change', 'noun in latest data')), 'latest-data'); $lastDataHeader->setAttribute('title', _x('Change', 'noun in latest data')); $checkAllCheckbox = new CCheckBox('all_items', null, "checkAll('" . $form->getName() . "', 'all_items', 'itemids');"); $checkAllCheckboxCol = new CCol($checkAllCheckbox, 'latest-checkbox'); if ($filter['showDetails']) { $intervalHeader = new CCol(new CSpan(_('Interval')), 'latest-interval'); $intervalHeader->setAttribute('title', _('Interval')); $historyHeader = new CCol(new CSpan(_('History')), 'latest-history'); $historyHeader->setAttribute('title', _('History')); $trendsHeader = new CCol(new CSpan(_('Trends')), 'latest-trends'); $trendsHeader->setAttribute('title', _('Trends'));
// append form header to widget $userGroupListForm = new CForm('get'); $userGroupComboBox = new CComboBox('filter_usrgrpid', $_REQUEST['filter_usrgrpid'], 'submit()'); $userGroupComboBox->addItem(0, _('All')); foreach ($this->data['userGroups'] as $userGroup) { $userGroupComboBox->addItem($userGroup['usrgrpid'], $userGroup['name']); } $userGroupListForm->addItem(array(_('User group') . SPACE, $userGroupComboBox)); $usersWidget->addHeader(_('Users'), $userGroupListForm); $usersWidget->addHeaderRowNumber(); // create form $usersForm = new CForm(); $usersForm->setName('userForm'); // create users table $usersTable = new CTableInfo(_('No users found.')); $usersTable->setHeader(array(new CCheckBox('all_users', null, "checkAll('" . $usersForm->getName() . "', 'all_users', 'group_userid');"), make_sorting_header(_('Alias'), 'alias', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_x('Name', 'user first name'), 'name', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Surname'), 'surname', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('User type'), 'type', $this->data['sort'], $this->data['sortorder']), _('Groups'), _('Is online?'), _('Login'), _('Frontend access'), _('Debug mode'), _('Status'))); foreach ($this->data['users'] as $user) { $userId = $user['userid']; $session = $this->data['usersSessions'][$userId]; // online time if ($session['lastaccess']) { $onlineTime = $user['autologout'] == 0 || ZBX_USER_ONLINE_TIME < $user['autologout'] ? ZBX_USER_ONLINE_TIME : $user['autologout']; $online = $session['lastaccess'] + $onlineTime >= time() ? new CCol(_('Yes') . ' (' . zbx_date2str(DATE_TIME_FORMAT_SECONDS, $session['lastaccess']) . ')', 'enabled') : new CCol(_('No') . ' (' . zbx_date2str(DATE_TIME_FORMAT_SECONDS, $session['lastaccess']) . ')', 'disabled'); } else { $online = new CCol(_('No'), 'disabled'); } // blocked $blocked = $user['attempt_failed'] >= ZBX_LOGIN_ATTEMPTS ? new CLink(_('Blocked'), 'users.php?action=user.massunblock&group_userid[]=' . $userId, 'on') : new CSpan(_('Ok'), 'green'); // user groups order_result($user['usrgrps'], 'name'); $usersGroups = array();
$createForm->addItem(new CSubmit('form', _('Create host prototype'))); $itemsWidget->addPageHeader(_('CONFIGURATION OF HOST PROTOTYPES'), $createForm); // header $itemsWidget->addHeader(array(_('Host prototypes of') . SPACE, new CSpan($this->data['discovery_rule']['name'], 'parent-discovery'))); $itemsWidget->addHeaderRowNumber(); $itemsWidget->addItem(get_header_host_table('hosts', $discoveryRule['hostid'], $this->data['parent_discoveryid'])); // create form $itemForm = new CForm(); $itemForm->setName('hosts'); $itemForm->addVar('parent_discoveryid', $this->data['parent_discoveryid']); // create table $hostTable = new CTableInfo(_('No host prototypes found.')); $sortLink = new CUrl(); $sortLink->setArgument('parent_discoveryid', $this->data['parent_discoveryid']); $sortLink = $sortLink->getUrl(); $hostTable->setHeader(array(new CCheckBox('all_hosts', null, "checkAll('" . $itemForm->getName() . "', 'all_hosts', 'group_hostid');"), make_sorting_header(_('Name'), 'name', $sortLink), _('Templates'), make_sorting_header(_('Status'), 'status', $sortLink))); foreach ($this->data['hostPrototypes'] as $hostPrototype) { // name $name = array(); if ($hostPrototype['templateid']) { $sourceTemplate = $hostPrototype['sourceTemplate']; $name[] = new CLink($sourceTemplate['name'], '?parent_discoveryid=' . $hostPrototype['sourceDiscoveryRuleId'], 'unknown'); $name[] = NAME_DELIMITER; } $name[] = new CLink($hostPrototype['name'], '?form=update&parent_discoveryid=' . $discoveryRule['itemid'] . '&hostid=' . $hostPrototype['hostid']); // template list if (empty($hostPrototype['templates'])) { $hostTemplates = '-'; } else { $hostTemplates = array(); order_result($hostPrototype['templates'], 'name');
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $discoveryWidget = new CWidget(); // create new discovery rule button $createForm = new CForm('get'); $createForm->cleanItems(); $createForm->addItem(new CSubmit('form', _('Create discovery rule'))); $discoveryWidget->addPageHeader(_('CONFIGURATION OF DISCOVERY RULES'), $createForm); $discoveryWidget->addHeader(_('Discovery rules')); $discoveryWidget->addHeaderRowNumber(); // create form $discoveryForm = new CForm(); $discoveryForm->setName('druleForm'); // create table $discoveryTable = new CTableInfo(_('No discovery rules found.')); $discoveryTable->setHeader(array(new CCheckBox('all_drules', null, "checkAll('" . $discoveryForm->getName() . "', 'all_drules', 'g_druleid');"), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('IP range'), _('Delay'), _('Checks'), _('Status'))); foreach ($data['drules'] as $drule) { array_push($drule['description'], new CLink($drule['name'], '?form=update&druleid=' . $drule['druleid'])); $status = new CCol(new CLink(discovery_status2str($drule['status']), '?g_druleid[]=' . $drule['druleid'] . '&action=' . ($drule['status'] == DRULE_STATUS_ACTIVE ? 'drule.massdisable' : 'drule.massenable'), discovery_status2style($drule['status']))); $discoveryTable->addRow(array(new CCheckBox('g_druleid[' . $drule['druleid'] . ']', null, null, $drule['druleid']), $drule['description'], $drule['iprange'], $drule['delay'], !empty($drule['checks']) ? implode(', ', $drule['checks']) : '', $status)); } // create go buttons $goComboBox = new CComboBox('action'); $goOption = new CComboItem('drule.massenable', _('Enable selected')); $goOption->setAttribute('confirm', _('Enable selected discovery rules?')); $goComboBox->addItem($goOption); $goOption = new CComboItem('drule.massdisable', _('Disable selected')); $goOption->setAttribute('confirm', _('Disable selected discovery rules?')); $goComboBox->addItem($goOption); $goOption = new CComboItem('drule.massdelete', _('Delete selected')); $goOption->setAttribute('confirm', _('Delete selected discovery rules?'));
/** * 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); }
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $proxyWidget = new CWidget(); // create new proxy button $createForm = new CForm('get'); $createForm->cleanItems(); $createForm->addItem(new CSubmit('form', _('Create proxy'))); $proxyWidget->addPageHeader(_('CONFIGURATION OF PROXIES'), $createForm); $proxyWidget->addHeader(_('Proxies')); $proxyWidget->addHeaderRowNumber(); // create form $proxyForm = new CForm('get'); $proxyForm->setName('proxyForm'); // create table $proxyTable = new CTableInfo(_('No proxies found.')); $proxyTable->setHeader(array(new CCheckBox('all_hosts', null, "checkAll('" . $proxyForm->getName() . "', 'all_hosts', 'hosts');"), make_sorting_header(_('Name'), 'host', $this->data['sort'], $this->data['sortorder']), _('Mode'), _('Last seen (age)'), _('Host count'), _('Item count'), _('Required performance (vps)'), _('Hosts'))); foreach ($this->data['proxies'] as $proxy) { $hosts = array(); if (!empty($proxy['hosts'])) { $i = 1; foreach ($proxy['hosts'] as $host) { if ($i > $this->data['config']['max_in_table']) { $hosts[] = ' …'; break; } $i++; if ($host['status'] == HOST_STATUS_MONITORED) { $style = 'off'; } elseif ($host['status'] == HOST_STATUS_TEMPLATE) { $style = 'unknown'; } else {
// 'true' means list should be ordered by title $inventoryFieldsComboBox = new CComboBox('groupby', $_REQUEST['groupby'], 'submit()'); $inventoryFieldsComboBox->addItem('', _('not selected')); foreach ($inventoryFields as $inventoryField) { $inventoryFieldsComboBox->addItem($inventoryField['db_field'], $inventoryField['title'], $_REQUEST['groupby'] === $inventoryField['db_field'] ? 'yes' : null); if ($_REQUEST['groupby'] === $inventoryField['db_field']) { $groupFieldTitle = $inventoryField['title']; } } $r_form = new CForm('get'); $r_form->addItem(array(_('Group'), SPACE, $pageFilter->getGroupsCB(true), SPACE)); $r_form->addItem(array(_('Grouping by'), SPACE, $inventoryFieldsComboBox)); $hostinvent_wdgt->addHeader(_('Hosts'), $r_form); $hostinvent_wdgt->addItem(BR()); $table = new CTableInfo(_('No hosts defined.')); $table->setHeader(array(make_sorting_header($groupFieldTitle === '' ? _('Field') : $groupFieldTitle, 'inventory_field'), make_sorting_header(_('Host count'), 'host_count'))); // to show a report, we will need a host group and a field to aggregate if ($pageFilter->groupsSelected && $groupFieldTitle !== '') { $options = array('output' => array('hostid', 'name'), 'selectInventory' => array($_REQUEST['groupby']), 'withInventory' => true); if ($pageFilter->groupid > 0) { $options['groupids'] = $pageFilter->groupid; } $hosts = API::Host()->get($options); // aggregating data by chosen field value $report = array(); foreach ($hosts as $host) { if ($host['inventory'][$_REQUEST['groupby']] !== '') { $lowerValue = zbx_strtolower($host['inventory'][$_REQUEST['groupby']]); if (!isset($report[$lowerValue])) { $report[$lowerValue] = array('inventory_field' => $host['inventory'][$_REQUEST['groupby']], 'host_count' => 1); } else {
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $slideWidget = new CWidget(); // create new hostgroup button $createForm = new CForm('get'); $createForm->cleanItems(); $createForm->addItem(new CSubmit('form', _('Create slide show'))); $slideWidget->addPageHeader(_('CONFIGURATION OF SLIDE SHOWS'), $createForm); $slideWidget->addHeader(_('Slide shows')); $slideWidget->addHeaderRowNumber(); // create form $slideForm = new CForm(); $slideForm->setName('slideForm'); // create table $slidesTable = new CTableInfo(_('No slide shows found.')); $slidesTable->setHeader(array(new CCheckBox('all_shows', null, "checkAll('" . $slideForm->getName() . "', 'all_shows', 'shows');"), $this->data['displayNodes'] ? _('Node') : null, make_sorting_header(_('Name'), 'name'), make_sorting_header(_('Delay'), 'delay'), make_sorting_header(_('Count of slides'), 'cnt'))); foreach ($this->data['slides'] as $slide) { $slidesTable->addRow(array(new CCheckBox('shows[' . $slide['slideshowid'] . ']', null, null, $slide['slideshowid']), $this->data['displayNodes'] ? $slide['nodename'] : null, new CLink($slide['name'], '?form=update&slideshowid=' . $slide['slideshowid'], 'action'), $slide['delay'], $slide['cnt'])); } // create go button $goComboBox = new CComboBox('go'); $goOption = new CComboItem('delete', _('Delete selected')); $goOption->setAttribute('confirm', _('Delete selected slide shows?')); $goComboBox->addItem($goOption); $goButton = new CSubmit('goButton', _('Go') . ' (0)'); $goButton->setAttribute('id', 'goButton'); zbx_add_post_js('chkbxRange.pageGoName = "shows";'); // append table to form $slideForm->addItem(array($this->data['paging'], $slidesTable, $this->data['paging'], get_table_header(array($goComboBox, $goButton)))); // append form to widget $slideWidget->addItem($slideForm);
// create widget header $sourceComboBox = new CComboBox('eventsource', $this->data['eventsource'], 'submit()'); $sourceComboBox->addItem(EVENT_SOURCE_TRIGGERS, _('Triggers')); $sourceComboBox->addItem(EVENT_SOURCE_DISCOVERY, _('Discovery')); $sourceComboBox->addItem(EVENT_SOURCE_AUTO_REGISTRATION, _('Auto registration')); $sourceComboBox->addItem(EVENT_SOURCE_INTERNAL, _x('Internal', 'event source')); $filterForm = new CForm('get'); $filterForm->addItem(array(_('Event source'), SPACE, $sourceComboBox)); $actionWidget->addHeader(_('Actions'), $filterForm); $actionWidget->addHeaderRowNumber(); // create form $actionForm = new CForm(); $actionForm->setName('actionForm'); // create table $actionTable = new CTableInfo(_('No actions found.')); $actionTable->setHeader(array(new CCheckBox('all_items', null, "checkAll('" . $actionForm->getName() . "', 'all_items', 'g_actionid');"), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('Conditions'), _('Operations'), make_sorting_header(_('Status'), 'status', $this->data['sort'], $this->data['sortorder']))); foreach ($this->data['actions'] as $action) { $conditions = array(); order_result($action['filter']['conditions'], 'conditiontype', ZBX_SORT_DOWN); foreach ($action['filter']['conditions'] as $condition) { $conditions[] = get_condition_desc($condition['conditiontype'], $condition['operator'], $condition['value']); $conditions[] = BR(); } sortOperations($this->data['eventsource'], $action['operations']); $operations = array(); foreach ($action['operations'] as $operation) { $operations[] = get_operation_descr(SHORT_DESCRIPTION, $operation); } if ($action['status'] == ACTION_STATUS_DISABLED) { $status = new CLink(_('Disabled'), 'actionconf.php?action=action.massenable&g_actionid[]=' . $action['actionid'] . url_param('eventsource'), 'disabled'); } else {
** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $scriptsWidget = new CWidget(); $createForm = new CForm('get'); $createForm->addItem(new CSubmit('form', _('Create script'))); $scriptsWidget->addPageHeader(_('CONFIGURATION OF SCRIPTS'), $createForm); $scriptsWidget->addHeader(_('Scripts')); $scriptsWidget->addHeaderRowNumber(); $scriptsForm = new CForm(); $scriptsForm->setName('scriptsForm'); $scriptsForm->setAttribute('id', 'scripts'); $scriptsTable = new CTableInfo(_('No scripts found.')); $scriptsTable->setHeader(array(new CCheckBox('all_scripts', null, "checkAll('" . $scriptsForm->getName() . "', 'all_scripts', 'scripts');"), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('Type'), _('Execute on'), make_sorting_header(_('Commands'), 'command', $this->data['sort'], $this->data['sortorder']), _('User group'), _('Host group'), _('Host access'))); foreach ($this->data['scripts'] as $script) { switch ($script['type']) { case ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT: $scriptType = _('Script'); break; case ZBX_SCRIPT_TYPE_IPMI: $scriptType = _('IPMI'); break; default: $scriptType = ''; break; } if ($script['type'] == ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT) { switch ($script['execute_on']) { case ZBX_SCRIPT_EXECUTE_ON_AGENT:
$createForm->addVar('templateid', $this->data['templateid']); $screenWidget->addItem(get_header_host_table('screens', $this->data['templateid'])); } else { $createForm->addItem(new CButton('form', _('Import'), 'redirect("conf.import.php?rules_preset=screen")')); } $screenWidget->addPageHeader(_('CONFIGURATION OF SCREENS'), $createForm); // header $screenWidget->addHeader(_('Screens')); $screenWidget->addHeaderRowNumber(); // create form $screenForm = new CForm(); $screenForm->setName('screenForm'); $screenForm->addVar('templateid', $this->data['templateid']); // create table $screenTable = new CTableInfo(_('No screens found.')); $screenTable->setHeader(array(new CCheckBox('all_screens', null, "checkAll('" . $screenForm->getName() . "', 'all_screens', 'screens');"), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('Dimension (cols x rows)'), _('Screen'))); foreach ($this->data['screens'] as $screen) { $screenTable->addRow(array(new CCheckBox('screens[' . $screen['screenid'] . ']', null, null, $screen['screenid']), new CLink($screen['name'], 'screenedit.php?screenid=' . $screen['screenid'] . url_param('templateid')), $screen['hsize'] . ' x ' . $screen['vsize'], new CLink(_('Edit'), '?form=update&screenid=' . $screen['screenid'] . url_param('templateid')))); } // create go button $goComboBox = new CComboBox('action'); if (empty($this->data['templateid'])) { $goComboBox->addItem('screen.export', _('Export selected')); } $goOption = new CComboItem('screen.massdelete', _('Delete selected')); $goOption->setAttribute('confirm', _('Delete selected screens?')); $goComboBox->addItem($goOption); $goButton = new CSubmit('goButton', _('Go') . ' (0)'); $goButton->setAttribute('id', 'goButton'); zbx_add_post_js('chkbxRange.pageGoName = "screens";'); // append table to form
** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $widget = (new CWidget())->setTitle(_('Maintenance periods'))->setControls((new CForm('get'))->cleanItems()->addItem((new CList())->addItem([_('Group'), SPACE, $this->data['pageFilter']->getGroupsCB()])->addItem(new CSubmit('form', _('Create maintenance period'))))); // create form $maintenanceForm = (new CForm())->setName('maintenanceForm'); // create table $maintenanceTable = (new CTableInfo())->setHeader([(new CColHeader((new CCheckBox('all_maintenances'))->onClick("checkAll('" . $maintenanceForm->getName() . "', 'all_maintenances', 'maintenanceids');")))->addClass(ZBX_STYLE_CELL_WIDTH), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Type'), 'maintenance_type', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Active since'), 'active_since', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Active till'), 'active_till', $this->data['sort'], $this->data['sortorder']), _('State'), _('Description')]); foreach ($this->data['maintenances'] as $maintenance) { $maintenanceid = $maintenance['maintenanceid']; switch ($maintenance['status']) { case MAINTENANCE_STATUS_EXPIRED: $maintenanceStatus = (new CSpan(_x('Expired', 'maintenance status')))->addClass(ZBX_STYLE_RED); break; case MAINTENANCE_STATUS_APPROACH: $maintenanceStatus = (new CSpan(_x('Approaching', 'maintenance status')))->addClass(ZBX_STYLE_ORANGE); break; case MAINTENANCE_STATUS_ACTIVE: $maintenanceStatus = (new CSpan(_x('Active', 'maintenance status')))->addClass(ZBX_STYLE_GREEN); break; } $maintenanceTable->addRow([new CCheckBox('maintenanceids[' . $maintenanceid . ']', $maintenanceid), new CLink($maintenance['name'], 'maintenance.php?form=update&maintenanceid=' . $maintenanceid), $maintenance['maintenance_type'] ? _('No data collection') : _('With data collection'), zbx_date2str(DATE_TIME_FORMAT, $maintenance['active_since']), zbx_date2str(DATE_TIME_FORMAT, $maintenance['active_till']), $maintenanceStatus, $maintenance['description']]); }
// adding javascript, so that auth fields would be hidden if they are not used in specific auth type $securityLevelVisibility = array(); zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV, 'row_snmpv3_authpassphrase'); zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'row_snmpv3_authpassphrase'); zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'row_snmpv3_privpassphrase'); zbx_add_post_js("var securityLevelSwitcher = new CViewSwitcher('new_check_snmpv3_securitylevel', 'change', " . zbx_jsvalue($securityLevelVisibility, true) . ");"); } else { $numrows = new CDiv(); $numrows->setAttribute('name', 'numrows'); $dscry_wdgt->addHeader(S_DISCOVERY_BIG); $dscry_wdgt->addHeader($numrows); /* table */ $form = new CForm(); $form->setName('frmdrules'); $tblDiscovery = new CTableInfo(S_NO_DISCOVERY_RULES_DEFINED); $tblDiscovery->setHeader(array(new CCheckBox('all_drules', null, "checkAll('" . $form->GetName() . "','all_drules','g_druleid');"), make_sorting_header(S_NAME, 'd.name'), make_sorting_header(S_IP_RANGE, 'd.iprange'), make_sorting_header(S_DELAY, 'd.delay'), S_CHECKS, S_STATUS)); $sql = 'SELECT d.* ' . ' FROM drules d' . ' WHERE ' . DBin_node('druleid') . order_by('d.name,d.iprange,d.delay', 'd.druleid'); $db_rules = DBselect($sql); // Discovery rules will be gathered here, so we can feed this array to pagination function $rules_arr = array(); while ($rule_data = DBfetch($db_rules)) { $rules_arr[] = $rule_data; } // getting paging element $paging = getPagingLine($rules_arr); foreach ($rules_arr as $rule_data) { $checks = array(); $sql = 'SELECT type FROM dchecks WHERE druleid=' . $rule_data['druleid'] . ' ORDER BY type, ports'; $db_checks = DBselect($sql); while ($check_data = DBfetch($db_checks)) { if (!isset($checks[$check_data['type']])) {
$sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP)); CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR); $frmForm = new CForm(); $frmForm->cleanItems(); $frmForm->addItem(new CDiv(array(new CSubmit('form', _('Create template')), new CButton('form', _('Import'), 'redirect("conf.import.php?rules_preset=template")')))); $frmForm->addItem(new CVar('groupid', $_REQUEST['groupid'], 'filter_groupid_id')); $templateWidget->addPageHeader(_('CONFIGURATION OF TEMPLATES'), $frmForm); $frmGroup = new CForm('get'); $frmGroup->addItem(array(_('Group') . SPACE, $pageFilter->getGroupsCB())); $templateWidget->addHeader(_('Templates'), $frmGroup); $templateWidget->addHeaderRowNumber(); $form = new CForm(); $form->setName('templates'); $table = new CTableInfo(_('No templates found.')); $table->setHeader(array(new CCheckBox('all_templates', null, "checkAll('" . $form->getName() . "', 'all_templates', 'templates');"), make_sorting_header(_('Templates'), 'name', $sortField, $sortOrder), _('Applications'), _('Items'), _('Triggers'), _('Graphs'), _('Screens'), _('Discovery'), _('Web'), _('Linked templates'), _('Linked to'))); // get templates $templates = array(); if ($pageFilter->groupsSelected) { $templates = API::Template()->get(array('output' => array('templateid', 'name'), 'groupids' => $pageFilter->groupid > 0 ? $pageFilter->groupid : null, 'editable' => true, 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1)); } // sorting && paging order_result($templates, $sortField, $sortOrder); $paging = getPagingLine($templates); $templates = API::Template()->get(array('templateids' => zbx_objectValues($templates, 'templateid'), 'editable' => true, 'output' => array('name', 'proxy_hostid'), 'selectHosts' => array('hostid', 'name', 'status'), 'selectTemplates' => array('hostid', 'name', 'status'), 'selectParentTemplates' => array('hostid', 'name', 'status'), 'selectItems' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT, 'selectApplications' => API_OUTPUT_COUNT, 'selectDiscoveries' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'selectHttpTests' => API_OUTPUT_COUNT, 'nopermissions' => true)); order_result($templates, $sortField, $sortOrder); foreach ($templates as $template) { $templatesOutput = array(); if ($template['proxy_hostid']) { $proxy = get_host_by_hostid($template['proxy_hostid']); $templatesOutput[] = $proxy['host'] . NAME_DELIMITER;
$groupFieldTitle = ''; $hostinvent_wdgt = (new CWidget())->setTitle(_('Host inventory overview')); // getting inventory fields to make a drop down $inventoryFields = getHostInventories(true); // 'true' means list should be ordered by title $inventoryFieldsComboBox = new CComboBox('groupby', $_REQUEST['groupby'], 'submit()'); $inventoryFieldsComboBox->addItem('', _('not selected')); foreach ($inventoryFields as $inventoryField) { $inventoryFieldsComboBox->addItem($inventoryField['db_field'], $inventoryField['title'], $_REQUEST['groupby'] === $inventoryField['db_field'] ? 'yes' : null); if ($_REQUEST['groupby'] === $inventoryField['db_field']) { $groupFieldTitle = $inventoryField['title']; } } $controls = (new CList())->addItem([_('Group') . SPACE, $pageFilter->getGroupsCB()])->addItem([_('Grouping by') . SPACE, $inventoryFieldsComboBox]); $hostinvent_wdgt->setControls((new CForm('get'))->addItem($controls)); $table = (new CTableInfo())->setHeader([make_sorting_header($groupFieldTitle === '' ? _('Field') : $groupFieldTitle, 'inventory_field', $sortField, $sortOrder), make_sorting_header(_('Host count'), 'host_count', $sortField, $sortOrder)]); // to show a report, we will need a host group and a field to aggregate if ($pageFilter->groupsSelected && $groupFieldTitle !== '') { $options = ['output' => ['hostid', 'name'], 'selectInventory' => [$_REQUEST['groupby']], 'withInventory' => true]; if ($pageFilter->groupid > 0) { $options['groupids'] = $pageFilter->groupid; } $hosts = API::Host()->get($options); // aggregating data by chosen field value $report = []; foreach ($hosts as $host) { if ($host['inventory'][$_REQUEST['groupby']] !== '') { // same names with different letter casing are considered the same $lowerValue = mb_strtolower($host['inventory'][$_REQUEST['groupby']]); if (!isset($report[$lowerValue])) { $report[$lowerValue] = ['inventory_field' => $host['inventory'][$_REQUEST['groupby']], 'host_count' => 1];
$filter->useJQueryStyle('main'); $reset = new CButton('reset', _('Reset'), "javascript: clearAllForm('zbx_filter');"); $reset->useJQueryStyle(); $divButtons = new CDiv(array($filter, SPACE, $reset)); $divButtons->setAttribute('style', 'padding: 4px 0;'); $filterTable->addRow(new CCol($divButtons, 'center', 4)); $filterForm = new CForm('get'); $filterForm->setAttribute('name', 'zbx_filter'); $filterForm->setAttribute('id', 'zbx_filter'); $filterForm->addItem($filterTable); $hostsWidget->addFlicker($filterForm, CProfile::get('web.hosts.filter.state', 0)); // table hosts $form = new CForm(); $form->setName('hosts'); $table = new CTableInfo(_('No hosts found.')); $table->setHeader(array(new CCheckBox('all_hosts', null, "checkAll('" . $form->getName() . "', 'all_hosts', 'hosts');"), $displayNodes ? _('Node') : null, make_sorting_header(_('Name'), 'name'), _('Applications'), _('Items'), _('Triggers'), _('Graphs'), _('Discovery'), _('Web'), _('Interface'), _('Templates'), make_sorting_header(_('Status'), 'status'), _('Availability'))); // get Hosts $hosts = array(); $sortfield = getPageSortField('name'); $sortorder = getPageSortOrder(); if ($pageFilter->groupsSelected) { $hosts = API::Host()->get(array('groupids' => $pageFilter->groupid > 0 ? $pageFilter->groupid : null, 'editable' => true, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'limit' => $config['search_limit'] + 1, 'search' => array('name' => empty($_REQUEST['filter_host']) ? null : $_REQUEST['filter_host'], 'ip' => empty($_REQUEST['filter_ip']) ? null : $_REQUEST['filter_ip'], 'dns' => empty($_REQUEST['filter_dns']) ? null : $_REQUEST['filter_dns']), 'filter' => array('port' => empty($_REQUEST['filter_port']) ? null : $_REQUEST['filter_port']))); } else { $hosts = array(); } // sorting && paging order_result($hosts, $sortfield, $sortorder); $paging = getPagingLine($hosts, array('hostid')); $hosts = API::Host()->get(array('hostids' => zbx_objectValues($hosts, 'hostid'), 'output' => API_OUTPUT_EXTEND, 'selectParentTemplates' => array('hostid', 'name'), 'selectInterfaces' => API_OUTPUT_EXTEND, 'selectItems' => API_OUTPUT_COUNT, 'selectDiscoveries' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT, 'selectApplications' => API_OUTPUT_COUNT, 'selectHttpTests' => API_OUTPUT_COUNT, 'selectDiscoveryRule' => array('itemid', 'name'), 'selectHostDiscovery' => array('ts_delete'))); order_result($hosts, $sortfield, $sortorder); // selecting linked templates to templates linked to hosts
** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $widget = (new CWidget())->setTitle(_('Actions'))->setControls((new CForm('get'))->cleanItems()->addItem((new CList())->addItem([_('Event source'), SPACE, new CComboBox('eventsource', $data['eventsource'], 'submit()', [EVENT_SOURCE_TRIGGERS => _('Triggers'), EVENT_SOURCE_DISCOVERY => _('Discovery'), EVENT_SOURCE_AUTO_REGISTRATION => _('Auto registration'), EVENT_SOURCE_INTERNAL => _x('Internal', 'event source')])])->addItem(new CSubmit('form', _('Create action'))))); // create form $actionForm = (new CForm())->setName('actionForm'); // create table $actionTable = (new CTableInfo())->setHeader([(new CColHeader((new CCheckBox('all_items'))->onClick("checkAll('" . $actionForm->getName() . "', 'all_items', 'g_actionid');")))->addClass(ZBX_STYLE_CELL_WIDTH), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('Conditions'), _('Operations'), make_sorting_header(_('Status'), 'status', $this->data['sort'], $this->data['sortorder'])]); if ($this->data['actions']) { $actionConditionStringValues = actionConditionValueToString($this->data['actions'], $this->data['config']); $actionOperationDescriptions = getActionOperationDescriptions($this->data['actions']); foreach ($this->data['actions'] as $aIdx => $action) { $conditions = []; $operations = []; order_result($action['filter']['conditions'], 'conditiontype', ZBX_SORT_DOWN); foreach ($action['filter']['conditions'] as $cIdx => $condition) { $conditions[] = getConditionDescription($condition['conditiontype'], $condition['operator'], $actionConditionStringValues[$aIdx][$cIdx]); $conditions[] = BR(); } sortOperations($data['eventsource'], $action['operations']); foreach ($action['operations'] as $oIdx => $operation) { $operations[] = $actionOperationDescriptions[$aIdx][$oIdx]; }
$graphWidget->addHeader(_('Graphs'), $filterForm); if (!empty($this->data['hostid'])) { $graphWidget->addItem(get_header_host_table('graphs', $this->data['hostid'])); } } $graphWidget->addHeaderRowNumber(); // create form $graphForm = new CForm(); $graphForm->setName('graphForm'); $graphForm->addVar('hostid', $this->data['hostid']); if (!empty($this->data['parent_discoveryid'])) { $graphForm->addVar('parent_discoveryid', $this->data['parent_discoveryid']); } // create table $graphTable = new CTableInfo(!empty($this->data['parent_discoveryid']) ? _('No graph prototypes found.') : _('No graphs found.')); $graphTable->setHeader(array(new CCheckBox('all_graphs', null, "checkAll('" . $graphForm->getName() . "', 'all_graphs', 'group_graphid');"), $this->data['displayNodes'] ? _('Node') : null, !empty($this->data['hostid']) ? null : _('Hosts'), make_sorting_header(_('Name'), 'name'), _('Width'), _('Height'), make_sorting_header(_('Graph type'), 'graphtype'))); foreach ($this->data['graphs'] as $graph) { $graphid = $graph['graphid']; $hostList = null; if (empty($this->data['hostid'])) { $hostList = array(); foreach ($graph['hosts'] as $host) { $hostList[$host['name']] = $host['name']; } foreach ($graph['templates'] as $template) { $hostList[$template['name']] = $template['name']; } $hostList = implode(', ', $hostList); } $isCheckboxEnabled = true; $name = array();
** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $widget = (new CWidget())->setTitle(_('Item prototypes'))->setControls((new CForm('get'))->cleanItems()->addVar('parent_discoveryid', $this->data['parent_discoveryid'])->addItem((new CList())->addItem(new CSubmit('form', _('Create item prototype')))))->addItem(get_header_host_table('items', $this->data['hostid'], $this->data['parent_discoveryid'])); // create form $itemForm = (new CForm())->setName('items')->addVar('hostid', $this->data['hostid'])->addVar('parent_discoveryid', $this->data['parent_discoveryid']); // create table $itemTable = (new CTableInfo())->setHeader([(new CColHeader((new CCheckBox('all_items'))->onClick("checkAll('" . $itemForm->getName() . "', 'all_items', 'group_itemid');")))->addClass(ZBX_STYLE_CELL_WIDTH), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Key'), 'key_', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Interval'), 'delay', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('History'), 'history', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Trends'), 'trends', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Type'), 'type', $this->data['sort'], $this->data['sortorder']), _('Applications'), make_sorting_header(_('Status'), 'status', $this->data['sort'], $this->data['sortorder'])]); foreach ($this->data['items'] as $item) { $description = []; if (!empty($item['templateid'])) { $template_host = get_realhost_by_itemid($item['templateid']); $templateDiscoveryRuleId = get_realrule_by_itemid_and_hostid($this->data['parent_discoveryid'], $template_host['hostid']); $description[] = (new CLink($template_host['name'], '?parent_discoveryid=' . $templateDiscoveryRuleId))->addClass(ZBX_STYLE_LINK_ALT)->addClass(ZBX_STYLE_GREY); $description[] = NAME_DELIMITER; } $description[] = new CLink($item['name_expanded'], '?form=update&itemid=' . $item['itemid'] . '&parent_discoveryid=' . $this->data['parent_discoveryid']); $status = (new CLink(itemIndicator($item['status']), '?group_itemid=' . $item['itemid'] . '&parent_discoveryid=' . $this->data['parent_discoveryid'] . '&action=' . ($item['status'] == ITEM_STATUS_DISABLED ? 'itemprototype.massenable' : 'itemprototype.massdisable')))->addClass(ZBX_STYLE_LINK_ACTION)->addClass(itemIndicatorStyle($item['status']))->addSID(); if (!empty($item['applications'])) { order_result($item['applications'], 'name'); $applications = zbx_objectValues($item['applications'], 'name'); $applications = implode(', ', $applications); if (empty($applications)) {
**/ $sysmapWidget = new CWidget(); // create header buttons $createForm = new CForm('get'); $createForm->cleanItems(); $createForm->addItem(new CSubmit('form', _('Create map'))); $createForm->addItem(new CButton('form', _('Import'), 'redirect("conf.import.php?rules_preset=map")')); $sysmapWidget->addPageHeader(_('CONFIGURATION OF NETWORK MAPS'), $createForm); // create form $sysmapForm = new CForm(); $sysmapForm->setName('frm_maps'); $sysmapWidget->addHeader(_('Maps')); $sysmapWidget->addHeaderRowNumber(); // create table $sysmapTable = new CTableInfo(_('No maps found.')); $sysmapTable->setHeader(array(new CCheckBox('all_maps', null, "checkAll('" . $sysmapForm->getName() . "', 'all_maps', 'maps');"), $this->data['displayNodes'] ? _('Node') : null, make_sorting_header(_('Name'), 'name'), make_sorting_header(_('Width'), 'width'), make_sorting_header(_('Height'), 'height'), _('Edit'))); foreach ($this->data['maps'] as $map) { $sysmapTable->addRow(array(new CCheckBox('maps[' . $map['sysmapid'] . ']', null, null, $map['sysmapid']), $this->data['displayNodes'] ? $map['nodename'] : null, new CLink($map['name'], 'sysmap.php?sysmapid=' . $map['sysmapid']), $map['width'], $map['height'], new CLink(_('Edit'), 'sysmaps.php?form=update&sysmapid=' . $map['sysmapid'] . '#form'))); } // create go button $goComboBox = new CComboBox('go'); $goComboBox->addItem('export', _('Export selected')); $goOption = new CComboItem('delete', _('Delete selected')); $goOption->setAttribute('confirm', _('Delete selected maps?')); $goComboBox->addItem($goOption); $goButton = new CSubmit('goButton', _('Go') . ' (0)'); $goButton->setAttribute('id', 'goButton'); zbx_add_post_js('chkbxRange.pageGoName = "maps";'); // append table to form $sysmapForm->addItem(array($this->data['paging'], $sysmapTable, $this->data['paging'], get_table_header(array($goComboBox, $goButton)))); // append form to widget
} $m_form = new CForm('acknow.php'); $m_form->setName('tr_status'); $m_form->addVar('backurl', $page['file']); $admin_links = $USER_DETAILS['type'] == USER_TYPE_ZABBIX_ADMIN || $USER_DETAILS['type'] == USER_TYPE_SUPER_ADMIN; $show_event_col = $config['event_ack_enable'] && $_REQUEST['show_events'] != EVENTS_OPTION_NOEVENT; $table = new CTableInfo(); $switcherName = 'trigger_switchers'; $header_cb = $show_event_col ? new CCheckBox('all_events', false, "checkAll('" . $m_form->GetName() . "','all_events','events');") : new CCheckBox('all_triggers', false, "checkAll('" . $m_form->GetName() . "','all_triggers', 'triggers');"); if ($show_events != EVENTS_OPTION_NOEVENT) { $whow_hide_all = new CDiv(SPACE, 'filterclosed'); $whow_hide_all->setAttribute('id', $switcherName); } else { $whow_hide_all = NULL; } $table->setHeader(array($whow_hide_all, $config['event_ack_enable'] ? $header_cb : null, make_sorting_header(S_SEVERITY, 'priority'), S_STATUS, make_sorting_header(S_LAST_CHANGE, 'lastchange'), S_AGE, $show_event_col ? S_DURATION : NULL, $config['event_ack_enable'] ? S_ACKNOWLEDGED : NULL, is_show_all_nodes() ? S_NODE : null, S_HOST, make_sorting_header(S_NAME, 'description'), S_COMMENTS)); $sortfield = getPageSortField('description'); $sortorder = getPageSortOrder(); $options = array('nodeids' => get_current_nodeid(), 'filter' => array(), 'monitored' => 1, 'output' => API_OUTPUT_EXTEND, 'skipDependent' => 1, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'limit' => $config['search_limit'] + 1); // Filtering if ($pageFilter->hostsSelected) { if ($pageFilter->hostid > 0) { $options['hostids'] = $pageFilter->hostid; } else { if ($pageFilter->groupid > 0) { $options['groupids'] = $pageFilter->groupid; } } } else { $options['hostids'] = array(); }
if (count($apps) > 35) { $apps = array_slice($apps, -35); } // js templates require_once dirname(__FILE__) . '/include/views/js/general.script.confirm.js.php'; if (isset($showAll)) { $url = '?close=1' . url_param('groupid') . url_param('hostid') . url_param('select'); $link = new CLink(new CImg('images/general/minus.png'), $url); // $link = new CLink(new CImg('images/general/minus.png'),$url,null,"javascript: return updater.onetime_update('".ZBX_PAGE_MAIN_HAT."','".$url."');"); } else { $url = '?open=1' . url_param('groupid') . url_param('hostid') . url_param('select'); $link = new CLink(new CImg('images/general/plus.png'), $url); // $link = new CLink(new CImg('images/general/plus.png'),$url,null,"javascript: return updater.onetime_update('".ZBX_PAGE_MAIN_HAT."','".$url."');"); } $table = new CTableInfo(_('No values found.')); $table->setHeader(array($link, is_show_all_nodes() ? make_sorting_header(_('Node'), 'h.hostid') : null, $_REQUEST['hostid'] == 0 ? make_sorting_header(_('Host'), 'h.name') : NULL, make_sorting_header(_('Name'), 'i.name'), make_sorting_header(_('Last check'), 'i.lastclock'), _('Last value'), _x('Change', 'noun in latest data'), _('History'))); // $table->ShowStart(); /** * Display APPLICATION ITEMS */ $db_apps = array(); $db_appids = array(); $options = array('output' => array('name', 'hostid'), 'hostids' => $available_hosts, 'selectScreens' => API_OUTPUT_COUNT, 'selectInventory' => array('hostid'), 'preservekeys' => true); $sql_from = ''; $sql_where = ''; if ($_REQUEST['groupid'] > 0) { $sql_from .= ',hosts_groups hg '; $sql_where .= ' AND hg.hostid=h.hostid AND hg.groupid=' . $_REQUEST['groupid']; $options['groupid'] = $_REQUEST['groupid']; } if ($_REQUEST['hostid'] > 0) {
$exactComboBox->addItem('1', _('exactly')); $filterTable->addRow(array(array(array(bold(_('Field')), SPACE, $inventoryFieldsComboBox), array($exactComboBox, new CTextBox('filter_field_value', $this->data['filterFieldValue'], 20)))), 'host-inventories'); $filter = new CSubmit('filter_set', _('Filter')); $filter->useJQueryStyle('main'); $reset = new CSubmit('filter_rst', _('Reset')); $reset->useJQueryStyle(); $divButtons = new CDiv(array($filter, SPACE, $reset)); $divButtons->setAttribute('style', 'padding: 4px 0px;'); $footerCol = new CCol($divButtons, 'controls'); $filterTable->addRow($footerCol); $filterForm = new CForm('get'); $filterForm->setAttribute('name', 'zbx_filter'); $filterForm->setAttribute('id', 'zbx_filter'); $filterForm->addItem($filterTable); $hostInventoryWidget->addFlicker($filterForm, CProfile::get('web.hostinventories.filter.state', 0)); $hostInventoryWidget->addHeaderRowNumber(); $table = new CTableInfo(_('No hosts found.')); $table->setHeader(array(make_sorting_header(_('Host'), 'name', $this->data['sort'], $this->data['sortorder']), _('Group'), make_sorting_header(_('Name'), 'pr_name', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Type'), 'pr_type', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('OS'), 'pr_os', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Serial number A'), 'pr_serialno_a', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Tag'), 'pr_tag', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('MAC address A'), 'pr_macaddress_a', $this->data['sort'], $this->data['sortorder']))); foreach ($this->data['hosts'] as $host) { $hostGroups = array(); foreach ($host['groups'] as $group) { $hostGroups[] = $group['name']; } natsort($hostGroups); $hostGroups = implode(', ', $hostGroups); $row = array(new CLink($host['name'], '?hostid=' . $host['hostid'] . url_param('groupid'), $host['status'] == HOST_STATUS_NOT_MONITORED ? 'not-monitored' : ''), $hostGroups, zbx_str2links($host['inventory']['name']), zbx_str2links($host['inventory']['type']), zbx_str2links($host['inventory']['os']), zbx_str2links($host['inventory']['serialno_a']), zbx_str2links($host['inventory']['tag']), zbx_str2links($host['inventory']['macaddress_a'])); $table->addRow($row); } $table = array($this->data['paging'], $table, $this->data['paging']); $hostInventoryWidget->addItem($table); return $hostInventoryWidget;
** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $discoveryWidget = new CWidget('hat_discovery'); // create header form $discoveryHeaderForm = new CForm('get'); $discoveryHeaderForm->setName('slideHeaderForm'); $discoveryHeaderForm->addVar('fullscreen', $this->data['fullscreen']); $discoveryWidget->addPageHeader(_('STATUS OF DISCOVERY'), get_icon('fullscreen', array('fullscreen' => $this->data['fullscreen']))); $discoveryRulesComboBox = $this->data['pageFilter']->getDiscoveryCB(); $discoveryHeaderForm->addItem(array(_('Discovery rule') . SPACE, $discoveryRulesComboBox)); $discoveryWidget->addHeader(_('Discovery rules'), $discoveryHeaderForm); // create table $discoveryTable = new CTableInfo(_('No discovered devices found.')); $discoveryTable->makeVerticalRotation(); $discoveredDeviceCol = make_sorting_header(_('Discovered device'), 'ip', $this->data['sort'], $this->data['sortorder']); $discoveredDeviceCol->addClass('left'); $header = array($discoveredDeviceCol, new CCol(_('Monitored host'), 'left'), new CCol(array(_('Uptime') . '/', _('Downtime')), 'left')); foreach ($this->data['services'] as $name => $foo) { $header[] = new CCol($name, 'vertical_rotation'); } $discoveryTable->setHeader($header, 'vertical_header'); foreach ($this->data['drules'] as $drule) { $discovery_info = array(); $dhosts = $drule['dhosts']; foreach ($dhosts as $dhost) { if ($dhost['status'] == DHOST_STATUS_DISABLED) { $hclass = 'disabled'; $htime = $dhost['lastdown']; } else { $hclass = 'enabled';
$itemsWidget->addPageHeader(_('CONFIGURATION OF ITEM PROTOTYPES'), $createForm); // header $itemsWidget->addHeader(array(_('Item prototypes of') . SPACE, new CSpan($this->data['discovery_rule']['name'], 'parent-discovery'))); $itemsWidget->addHeaderRowNumber(); $itemsWidget->addItem(get_header_host_table('items', $this->data['hostid'], $this->data['parent_discoveryid'])); // create form $itemForm = new CForm(); $itemForm->setName('items'); $itemForm->addVar('hostid', $this->data['hostid']); $itemForm->addVar('parent_discoveryid', $this->data['parent_discoveryid']); // create table $itemTable = new CTableInfo(_('No item prototypes found.')); $sortLink = new CUrl(); $sortLink->setArgument('parent_discoveryid', $this->data['parent_discoveryid']); $sortLink = $sortLink->getUrl(); $itemTable->setHeader(array(new CCheckBox('all_items', null, "checkAll('" . $itemForm->getName() . "', 'all_items', 'group_itemid');"), make_sorting_header(_('Name'), 'name', $sortLink), make_sorting_header(_('Key'), 'key_', $sortLink), make_sorting_header(_('Interval'), 'delay', $sortLink), make_sorting_header(_('History'), 'history', $sortLink), make_sorting_header(_('Trends'), 'trends', $sortLink), make_sorting_header(_('Type'), 'type', $sortLink), _('Applications'), make_sorting_header(_('Status'), 'status', $sortLink))); foreach ($this->data['items'] as $item) { $description = array(); if (!empty($item['templateid'])) { $template_host = get_realhost_by_itemid($item['templateid']); $templateDiscoveryRuleId = get_realrule_by_itemid_and_hostid($this->data['parent_discoveryid'], $template_host['hostid']); $description[] = new CLink($template_host['name'], '?parent_discoveryid=' . $templateDiscoveryRuleId, 'unknown'); $description[] = NAME_DELIMITER; } $description[] = new CLink($item['name_expanded'], '?form=update&itemid=' . $item['itemid'] . '&parent_discoveryid=' . $this->data['parent_discoveryid']); $status = new CLink(itemIndicator($item['status']), '?group_itemid=' . $item['itemid'] . '&parent_discoveryid=' . $this->data['parent_discoveryid'] . '&go=' . ($item['status'] ? 'activate' : 'disable'), itemIndicatorStyle($item['status'])); if (!empty($item['applications'])) { order_result($item['applications'], 'name'); $applications = zbx_objectValues($item['applications'], 'name'); $applications = implode(', ', $applications); if (empty($applications)) {
$filter = new CButton('filter', _('Filter'), "javascript: create_var('zbx_filter', 'filter_set', '1', true);"); $filter->useJQueryStyle('main'); $reset = new CButton('reset', _('Reset'), "javascript: clearAllForm('zbx_filter');"); $reset->useJQueryStyle(); $div_buttons = new CDiv(array($filter, SPACE, $reset)); $div_buttons->setAttribute('style', 'padding: 4px 0px;'); $footer_col = new CCol($div_buttons, 'controls'); $filter_table->addRow($footer_col); $filter_form = new CForm('get'); $filter_form->setAttribute('name', 'zbx_filter'); $filter_form->setAttribute('id', 'zbx_filter'); $filter_form->addItem($filter_table); $hostinvent_wdgt->addFlicker($filter_form, CProfile::get('web.hostinventories.filter.state', 0)); $hostinvent_wdgt->addHeaderRowNumber(); $table = new CTableInfo(_('No hosts defined.')); $table->setHeader(array(is_show_all_nodes() ? make_sorting_header(_('Node'), 'hostid') : null, make_sorting_header(_('Host'), 'name'), _('Group'), make_sorting_header(_('Name'), 'pr_name'), make_sorting_header(_('Type'), 'pr_type'), make_sorting_header(_('OS'), 'pr_os'), make_sorting_header(_('Serial number A'), 'pr_serialno_a'), make_sorting_header(_('Tag'), 'pr_tag'), make_sorting_header(_('MAC address A'), 'pr_macaddress_a'))); $hosts = array(); $paging = getPagingLine($hosts); if ($pageFilter->groupsSelected) { // which inventory fields we will need for displaying $requiredInventoryFields = array('name', 'type', 'os', 'serialno_a', 'tag', 'macaddress_a'); // checking if correct inventory field is specified for filter $possibleInventoryFields = getHostInventories(); $possibleInventoryFields = zbx_toHash($possibleInventoryFields, 'db_field'); if (!empty($_REQUEST['filter_field']) && !empty($_REQUEST['filter_field_value']) && !isset($possibleInventoryFields[$_REQUEST['filter_field']])) { error(_s('Impossible to filter by inventory field "%s", which does not exist.', $_REQUEST['filter_field'])); } else { // if we are filtering by field, this field is also required if (!empty($_REQUEST['filter_field']) && !empty($_REQUEST['filter_field_value'])) { $requiredInventoryFields[] = $_REQUEST['filter_field']; }
** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $mediaTypeWidget = new CWidget(); // create new media type button $createForm = new CForm('get'); $createForm->addItem(new CSubmit('form', _('Create media type'))); $mediaTypeWidget->addPageHeader(_('CONFIGURATION OF MEDIA TYPES'), $createForm); $mediaTypeWidget->addHeader(_('Media types')); $mediaTypeWidget->addHeaderRowNumber(); // create form $mediaTypeForm = new CForm(); $mediaTypeForm->setName('mediaTypesForm'); // create table $mediaTypeTable = new CTableInfo(_('No media types found.')); $mediaTypeTable->setHeader(array(new CCheckBox('all_media_types', null, "checkAll('" . $mediaTypeForm->getName() . "', 'all_media_types', 'mediatypeids');"), $this->data['displayNodes'] ? _('Node') : null, make_sorting_header(_('Name'), 'description'), make_sorting_header(_('Type'), 'type'), _('Status'), _('Used in actions'), _('Details'))); foreach ($this->data['mediatypes'] as $mediaType) { switch ($mediaType['typeid']) { case MEDIA_TYPE_EMAIL: $details = _('SMTP server') . NAME_DELIMITER . '"' . $mediaType['smtp_server'] . '", ' . _('SMTP helo') . NAME_DELIMITER . '"' . $mediaType['smtp_helo'] . '", ' . _('SMTP email') . NAME_DELIMITER . '"' . $mediaType['smtp_email'] . '"'; break; case MEDIA_TYPE_EXEC: $details = _('Script name') . NAME_DELIMITER . '"' . $mediaType['exec_path'] . '"'; break; case MEDIA_TYPE_SMS: $details = _('GSM modem') . NAME_DELIMITER . '"' . $mediaType['gsm_modem'] . '"'; break; case MEDIA_TYPE_JABBER: $details = _('Jabber identifier') . NAME_DELIMITER . '"' . $mediaType['username'] . '"'; break; case MEDIA_TYPE_EZ_TEXTING:
// create new maintenance button $createForm = new CForm('get'); $createForm->cleanItems(); $createForm->addItem(new CSubmit('form', _('Create maintenance period'))); $maintenanceWidget->addPageHeader(_('CONFIGURATION OF MAINTENANCE PERIODS'), $createForm); // header $filterForm = new CForm('get'); $filterForm->addItem(array(_('Group') . SPACE, $this->data['pageFilter']->getGroupsCB(true))); $maintenanceWidget->addHeader(_('Maintenance periods'), $filterForm); $maintenanceWidget->addHeaderRowNumber(); // create form $maintenanceForm = new CForm(); $maintenanceForm->setName('maintenanceForm'); // create table $maintenanceTable = new CTableInfo(_('No maintenance periods found.')); $maintenanceTable->setHeader(array(new CCheckBox('all_maintenances', null, "checkAll('" . $maintenanceForm->getName() . "', 'all_maintenances', 'maintenanceids');"), $this->data['displayNodes'] ? _('Node') : null, make_sorting_header(_('Name'), 'name'), make_sorting_header(_('Type'), 'maintenance_type'), _('State'), _('Description'))); foreach ($this->data['maintenances'] as $maintenance) { $maintenanceid = $maintenance['maintenanceid']; switch ($maintenance['status']) { case MAINTENANCE_STATUS_EXPIRED: $maintenanceStatus = new CSpan(_x('Expired', 'maintenance status'), 'red'); break; case MAINTENANCE_STATUS_APPROACH: $maintenanceStatus = new CSpan(_x('Approaching', 'maintenance status'), 'blue'); break; case MAINTENANCE_STATUS_ACTIVE: $maintenanceStatus = new CSpan(_x('Active', 'maintenance status'), 'green'); break; } $maintenanceTable->addRow(array(new CCheckBox('maintenanceids[' . $maintenanceid . ']', null, null, $maintenanceid), $this->data['displayNodes'] ? $maintenance['nodename'] : null, new CLink($maintenance['name'], 'maintenance.php?form=update&maintenanceid=' . $maintenanceid), $maintenance['maintenance_type'] ? _('No data collection') : _('With data collection'), $maintenanceStatus, $maintenance['description'])); }
$options = array('groups' => array('real_hosts' => true, 'with_httptests' => true), 'hosts' => array('with_monitored_items' => true, 'with_httptests' => true), 'hostid' => get_request('hostid', null), 'groupid' => get_request('groupid', null)); $pageFilter = new CPageFilter($options); $_REQUEST['groupid'] = $pageFilter->groupid; $_REQUEST['hostid'] = $pageFilter->hostid; $displayNodes = is_array(get_current_nodeid()) && $pageFilter->groupid == 0 && $pageFilter->hostid == 0; $r_form = new CForm('get'); $r_form->addVar('fullscreen', $_REQUEST['fullscreen']); $r_form->addItem(array(_('Group') . SPACE, $pageFilter->getGroupsCB(true))); $r_form->addItem(array(SPACE . _('Host') . SPACE, $pageFilter->getHostsCB(true))); $httpmon_wdgt = new CWidget(); $httpmon_wdgt->addPageHeader(_('STATUS OF WEB MONITORING'), get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen']))); $httpmon_wdgt->addHeader(_('Web scenarios'), $r_form); $httpmon_wdgt->addHeaderRowNumber(); // TABLE $table = new CTableInfo(_('No web scenarios found.')); $table->SetHeader(array($displayNodes ? _('Node') : null, $_REQUEST['hostid'] == 0 ? make_sorting_header(_('Host'), 'hostname') : null, make_sorting_header(_('Name'), 'name'), _('Number of steps'), _('Last check'), _('Status'))); $paging = null; if ($pageFilter->hostsSelected) { $options = array('output' => array('httptestid'), 'templated' => false, 'filter' => array('status' => HTTPTEST_STATUS_ACTIVE), 'limit' => $config['search_limit'] + 1); if ($pageFilter->hostid > 0) { $options['hostids'] = $pageFilter->hostid; } elseif ($pageFilter->groupid > 0) { $options['groupids'] = $pageFilter->groupid; } $httpTests = API::HttpTest()->get($options); $paging = getPagingLine($httpTests); $httpTests = API::HttpTest()->get(array('httptestids' => zbx_objectValues($httpTests, 'httptestid'), 'preservekeys' => true, 'output' => API_OUTPUT_EXTEND, 'selectHosts' => array('name', 'status'), 'selectSteps' => API_OUTPUT_COUNT)); foreach ($httpTests as &$httpTest) { $httpTest['host'] = reset($httpTest['hosts']); $httpTest['hostname'] = $httpTest['host']['name']; unset($httpTest['hosts']);
// header $itemsWidget->addHeader(_('Items')); $itemsWidget->addHeaderRowNumber(); if (!empty($this->data['hostid'])) { $itemsWidget->addItem(get_header_host_table('items', $this->data['hostid'])); } $itemsWidget->addFlicker($this->data['flicker'], CProfile::get('web.items.filter.state', 0)); // create form $itemForm = new CForm(); $itemForm->setName('items'); if (!empty($this->data['hostid'])) { $itemForm->addVar('hostid', $this->data['hostid']); } // create table $itemTable = new CTableInfo($this->data['filterSet'] ? _('No items found.') : _('Specify some filter condition to see the items.')); $itemTable->setHeader(array(new CCheckBox('all_items', null, "checkAll('" . $itemForm->getName() . "', 'all_items', 'group_itemid');"), _('Wizard'), empty($this->data['filter_hostid']) ? _('Host') : null, make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('Triggers'), make_sorting_header(_('Key'), 'key_', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Interval'), 'delay', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('History'), 'history', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Trends'), 'trends', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Type'), 'type', $this->data['sort'], $this->data['sortorder']), _('Applications'), make_sorting_header(_('Status'), 'status', $this->data['sort'], $this->data['sortorder']), $data['showInfoColumn'] ? _('Info') : null)); $currentTime = time(); foreach ($this->data['items'] as $item) { // description $description = array(); if (!empty($item['template_host'])) { $description[] = new CLink(CHtml::encode($item['template_host']['name']), '?hostid=' . $item['template_host']['hostid'] . '&filter_set=1', 'unknown'); $description[] = NAME_DELIMITER; } if (!empty($item['discoveryRule'])) { $description[] = new CLink(CHtml::encode($item['discoveryRule']['name']), 'disc_prototypes.php?parent_discoveryid=' . $item['discoveryRule']['itemid'], 'parent-discovery'); $description[] = NAME_DELIMITER . $item['name_expanded']; } else { $description[] = new CLink(CHtml::encode($item['name_expanded']), '?form=update&hostid=' . $item['hostid'] . '&itemid=' . $item['itemid']); } // status