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(); }
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(); }
$page['file'] = 'nodes.php'; $page['hist_arg'] = array(); require_once dirname(__FILE__) . '/include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('nodeid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, '(isset({form})&&({form}=="update"))'), 'new_nodeid' => array(T_ZBX_INT, O_OPT, null, DB_ID . NOT_ZERO, 'isset({save})', _('ID')), 'name' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})'), 'ip' => array(T_ZBX_IP, O_OPT, null, null, 'isset({save})'), 'nodetype' => array(T_ZBX_INT, O_OPT, null, IN(ZBX_NODE_CHILD . ',' . ZBX_NODE_MASTER . ',' . ZBX_NODE_LOCAL), 'isset({save})&&!isset({nodeid})'), 'masterid' => array(T_ZBX_INT, O_OPT, null, DB_ID, null), 'port' => array(T_ZBX_INT, O_OPT, null, BETWEEN(1, 65535), 'isset({save})', _('Port')), 'save' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'delete' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'cancel' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form_refresh' => array(T_ZBX_INT, O_OPT, null, null, null)); check_fields($fields); /* * Permissions */ $available_nodes = get_accessible_nodes_by_user(CWebUser::$data, PERM_READ); if (count($available_nodes) == 0) { access_deny(); } $node = null; if (get_request('nodeid')) { $node = get_node_by_nodeid($_REQUEST['nodeid']); if (!$node) { access_deny(); } } /* * Actions */ if (isset($_REQUEST['save'])) { if (get_request('nodeid')) { $nodeid = get_request('nodeid'); DBstart(); $result = update_node($nodeid, get_request('name'), get_request('ip'), get_request('port')); $result = DBend($result); show_messages($result, _('Node updated'), _('Cannot update node')); $audit_action = AUDIT_ACTION_UPDATE;
function condition_value2str($conditiontype, $value) { switch ($conditiontype) { case CONDITION_TYPE_HOST_GROUP: $groups = API::HostGroup()->get(array('groupids' => $value, 'output' => array('name'), 'nodeids' => get_current_nodeid(true), 'limit' => 1)); if ($groups) { $group = reset($groups); $str_val = ''; if (id2nodeid($value) != get_current_nodeid()) { $str_val = get_node_name_by_elid($value, true, NAME_DELIMITER); } $str_val .= $group['name']; } else { return _('Unknown'); } break; case CONDITION_TYPE_TRIGGER: $trigs = API::Trigger()->get(array('triggerids' => $value, 'expandDescription' => true, 'output' => array('description'), 'selectHosts' => array('name'), 'nodeids' => get_current_nodeid(true), 'limit' => 1)); if ($trigs) { $trig = reset($trigs); $host = reset($trig['hosts']); $str_val = ''; if (id2nodeid($value) != get_current_nodeid()) { $str_val = get_node_name_by_elid($value, true, NAME_DELIMITER); } $str_val .= $host['name'] . NAME_DELIMITER . $trig['description']; } else { return _('Unknown'); } break; case CONDITION_TYPE_HOST: case CONDITION_TYPE_TEMPLATE: if ($host = get_host_by_hostid($value)) { $str_val = ''; if (id2nodeid($value) != get_current_nodeid()) { $str_val = get_node_name_by_elid($value, true, NAME_DELIMITER); } $str_val .= $host['name']; } else { return _('Unknown'); } break; case CONDITION_TYPE_TRIGGER_NAME: case CONDITION_TYPE_HOST_METADATA: case CONDITION_TYPE_HOST_NAME: $str_val = $value; break; case CONDITION_TYPE_TRIGGER_VALUE: $str_val = trigger_value2str($value); break; case CONDITION_TYPE_TRIGGER_SEVERITY: $str_val = getSeverityCaption($value); break; case CONDITION_TYPE_TIME_PERIOD: $str_val = $value; break; case CONDITION_TYPE_MAINTENANCE: $str_val = _('maintenance'); break; case CONDITION_TYPE_NODE: if ($node = get_node_by_nodeid($value)) { $str_val = $node['name']; } else { return _('Unknown'); } break; case CONDITION_TYPE_DRULE: if ($drule = get_discovery_rule_by_druleid($value)) { $str_val = $drule['name']; } else { return _('Unknown'); } break; case CONDITION_TYPE_DCHECK: $row = DBfetch(DBselect('SELECT dr.name,c.dcheckid,c.type,c.key_,c.ports' . ' FROM drules dr,dchecks c' . ' WHERE dr.druleid=c.druleid' . ' AND c.dcheckid=' . zbx_dbstr($value))); if ($row) { $str_val = $row['name'] . NAME_DELIMITER . discovery_check2str($row['type'], $row['key_'], $row['ports']); } else { return _('Unknown'); } break; case CONDITION_TYPE_DOBJECT: $str_val = discovery_object2str($value); break; case CONDITION_TYPE_PROXY: if ($host = get_host_by_hostid($value)) { $str_val = $host['host']; } else { return _('Unknown'); } break; case CONDITION_TYPE_DHOST_IP: $str_val = $value; break; case CONDITION_TYPE_DSERVICE_TYPE: $str_val = discovery_check_type2str($value); break; case CONDITION_TYPE_DSERVICE_PORT: $str_val = $value; break; case CONDITION_TYPE_DSTATUS: $str_val = discovery_object_status2str($value); break; case CONDITION_TYPE_DUPTIME: $str_val = $value; break; case CONDITION_TYPE_DVALUE: $str_val = $value; break; case CONDITION_TYPE_EVENT_ACKNOWLEDGED: $str_val = $value ? _('Ack') : _('Not Ack'); break; case CONDITION_TYPE_APPLICATION: $str_val = $value; break; case CONDITION_TYPE_EVENT_TYPE: $str_val = eventType($value); break; default: return _('Unknown'); } return $str_val; }
function insert_node_form() { global $ZBX_CURMASTERID; $frm_title = S_NODE; if (isset($_REQUEST['nodeid'])) { $node_data = get_node_by_nodeid($_REQUEST['nodeid']); $node_type = detect_node_type($node_data); $masterid = $node_data['masterid']; $frm_title = S_NODE . ' "' . $node_data['name'] . '"'; } $frmNode = new CFormTable($frm_title); $frmNode->SetHelp("node.php"); if (isset($_REQUEST['nodeid'])) { $frmNode->addVar('nodeid', $_REQUEST['nodeid']); } if (isset($_REQUEST['nodeid']) && (!isset($_REQUEST["form_refresh"]) || isset($_REQUEST["register"]))) { $new_nodeid = $node_data['nodeid']; $name = $node_data['name']; $timezone = $node_data['timezone']; $ip = $node_data['ip']; $port = $node_data['port']; $slave_history = $node_data['slave_history']; $slave_trends = $node_data['slave_trends']; } else { $new_nodeid = get_request('new_nodeid', 0); $name = get_request('name', ''); $timezone = get_request('timezone', 0); $ip = get_request('ip', '127.0.0.1'); $port = get_request('port', 10051); $slave_history = get_request('slave_history', 90); $slave_trends = get_request('slave_trends', 365); $node_type = get_request('node_type', ZBX_NODE_REMOTE); $masterid = get_request('masterid', get_current_nodeid(false)); } $master_node = DBfetch(DBselect('SELECT name FROM nodes WHERE nodeid=' . $masterid)); $frmNode->addRow(S_NAME, new CTextBox('name', $name, 40)); $frmNode->addRow(S_ID, new CNumericBox('new_nodeid', $new_nodeid, 10)); if (!isset($_REQUEST['nodeid'])) { $cmbNodeType = new CComboBox('node_type', $node_type, 'submit()'); $cmbNodeType->addItem(ZBX_NODE_REMOTE, S_REMOTE); if ($ZBX_CURMASTERID == 0) { $cmbNodeType->addItem(ZBX_NODE_MASTER, S_MASTER); } } else { $cmbNodeType = new CTextBox('node_type_name', node_type2str($node_type), null, 'yes'); } $frmNode->addRow(S_TYPE, $cmbNodeType); if ($node_type == ZBX_NODE_REMOTE) { $frmNode->addRow(S_MASTER_NODE, new CTextBox('master_name', $master_node['name'], 40, 'yes')); } $cmbTimeZone = new CComboBox('timezone', $timezone); for ($i = -12; $i <= 13; $i++) { $cmbTimeZone->addItem($i, "GMT" . sprintf("%+03d:00", $i)); } $frmNode->addRow(S_TIME_ZONE, $cmbTimeZone); $frmNode->addRow(S_IP, new CTextBox('ip', $ip, 15)); $frmNode->addRow(S_PORT, new CNumericBox('port', $port, 5)); $frmNode->addRow(S_DO_NOT_KEEP_HISTORY_OLDER_THAN, new CNumericBox('slave_history', $slave_history, 6)); $frmNode->addRow(S_DO_NOT_KEEP_TRENDS_OLDER_THAN, new CNumericBox('slave_trends', $slave_trends, 6)); $frmNode->addItemToBottomRow(new CButton('save', S_SAVE)); if (isset($_REQUEST['nodeid']) && $node_type != ZBX_NODE_LOCAL) { $frmNode->addItemToBottomRow(SPACE); $frmNode->addItemToBottomRow(new CButtonDelete("Delete selected node?", url_param("form") . url_param("nodeid"))); } $frmNode->addItemToBottomRow(SPACE); $frmNode->addItemToBottomRow(new CButtonCancel(url_param("config"))); $frmNode->Show(); }
function get_node_path($nodeid, $result = '/') { if ($node_data = get_node_by_nodeid($nodeid)) { if ($node_data['masterid']) { $result = get_node_path($node_data['masterid'], $result); } $result .= $node_data['name'] . '/'; } return $result; }
public function bodyToString() { $this->cleanItems(); $ok = $uncn = $uncl = $info = $warn = $avg = $high = $dis = 0; $options = array('monitored' => 1, 'skipDependent' => 1, 'output' => API_OUTPUT_SHORTEN); if ($this->hostid > 0) { $options['hostids'] = $this->hostid; } else { if ($this->groupid > 0) { $options['groupids'] = $this->groupid; } } $triggers = CTrigger::get($options); $triggers = zbx_objectValues($triggers, 'triggerid'); $sql = 'SELECT t.priority,t.value,count(DISTINCT t.triggerid) as cnt ' . ' FROM triggers t ' . ' WHERE ' . DBcondition('t.triggerid', $triggers) . ' GROUP BY t.priority,t.value'; $db_priority = DBselect($sql); while ($row = DBfetch($db_priority)) { switch ($row['value']) { case TRIGGER_VALUE_TRUE: switch ($row['priority']) { case TRIGGER_SEVERITY_NOT_CLASSIFIED: $uncl += $row['cnt']; break; case TRIGGER_SEVERITY_INFORMATION: $info += $row['cnt']; break; case TRIGGER_SEVERITY_WARNING: $warn += $row['cnt']; break; case TRIGGER_SEVERITY_AVERAGE: $avg += $row['cnt']; break; case TRIGGER_SEVERITY_HIGH: $high += $row['cnt']; break; case TRIGGER_SEVERITY_DISASTER: $dis += $row['cnt']; break; } break; case TRIGGER_VALUE_FALSE: $ok += $row['cnt']; break; default: $uncn += $row['cnt']; break; } } if ($this->show_header) { $header_str = S_TRIGGERS_INFO . SPACE; if (!is_null($this->nodeid)) { $node = get_node_by_nodeid($this->nodeid); 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 .= S_GROUP . SPACE . '"' . $group['name'] . '"'; } else { $header_str .= S_ALL_GROUPS; } $header = new CCol($header_str, 'header'); if ($this->style == STYLE_HORISONTAL) { $header->SetColspan(8); } $this->addRow($header); } $trok = new CCol($ok . SPACE . S_OK, get_severity_style('ok', false)); $uncn = new CCol($uncn . SPACE . S_UNKNOWN, 'unknown'); $uncl = new CCol($uncl . SPACE . S_NOT_CLASSIFIED, get_severity_style(TRIGGER_SEVERITY_NOT_CLASSIFIED, $uncl)); $info = new CCol($info . SPACE . S_INFORMATION, get_severity_style(TRIGGER_SEVERITY_INFORMATION, $info)); $warn = new CCol($warn . SPACE . S_WARNING, get_severity_style(TRIGGER_SEVERITY_WARNING, $warn)); $avg = new CCol($avg . SPACE . S_AVERAGE, get_severity_style(TRIGGER_SEVERITY_AVERAGE, $avg)); $high = new CCol($high . SPACE . S_HIGH, get_severity_style(TRIGGER_SEVERITY_HIGH, $high)); $dis = new CCol($dis . SPACE . S_DISASTER, get_severity_style(TRIGGER_SEVERITY_DISASTER, $dis)); if (STYLE_HORISONTAL == $this->style) { $this->addRow(array($trok, $uncn, $uncl, $info, $warn, $avg, $high, $dis)); } else { $this->addRow($trok); $this->addRow($uncn); $this->addRow($uncl); $this->addRow($info); $this->addRow($warn); $this->addRow($avg); $this->addRow($high); $this->addRow($dis); } return parent::BodyToString(); }
function condition_value2str($conditiontype, $value) { switch ($conditiontype) { case CONDITION_TYPE_HOST_GROUP: $group = get_hostgroup_by_groupid($value); $str_val = ''; if (id2nodeid($value) != get_current_nodeid()) { $str_val = get_node_name_by_elid($value, true, ': '); } $str_val .= $group['name']; break; case CONDITION_TYPE_TRIGGER: $trig = CTrigger::get(array('triggerids' => $value, 'expandTriggerDescriptions' => true, 'output' => API_OUTPUT_EXTEND, 'select_hosts' => API_OUTPUT_EXTEND, 'nodeids' => get_current_nodeid(true))); $trig = reset($trig); $host = reset($trig['hosts']); $str_val = ''; if (id2nodeid($value) != get_current_nodeid()) { $str_val = get_node_name_by_elid($value, true, ': '); } $str_val .= $host['host'] . ':' . $trig['description']; break; case CONDITION_TYPE_HOST: case CONDITION_TYPE_HOST_TEMPLATE: $host = get_host_by_hostid($value); $str_val = ''; if (id2nodeid($value) != get_current_nodeid()) { $str_val = get_node_name_by_elid($value, true, ': '); } $str_val .= $host['host']; break; case CONDITION_TYPE_TRIGGER_NAME: case CONDITION_TYPE_HOST_NAME: $str_val = $value; break; case CONDITION_TYPE_TRIGGER_VALUE: $str_val = trigger_value2str($value); break; case CONDITION_TYPE_TRIGGER_SEVERITY: $str_val = get_severity_description($value); break; case CONDITION_TYPE_TIME_PERIOD: $str_val = $value; break; case CONDITION_TYPE_MAINTENANCE: $str_val = S_MAINTENANCE_SMALL; break; case CONDITION_TYPE_NODE: $node = get_node_by_nodeid($value); $str_val = $node['name']; break; case CONDITION_TYPE_DRULE: $drule = get_discovery_rule_by_druleid($value); $str_val = $drule['name']; break; case CONDITION_TYPE_DCHECK: $row = DBfetch(DBselect('SELECT DISTINCT r.name,c.dcheckid,c.type,c.key_,c.snmp_community,c.ports' . ' FROM drules r,dchecks c WHERE r.druleid=c.druleid AND c.dcheckid=' . $value)); $str_val = $row['name'] . ':' . discovery_check2str($row['type'], $row['snmp_community'], $row['key_'], $row['ports']); break; case CONDITION_TYPE_DOBJECT: $str_val = discovery_object2str($value); break; case CONDITION_TYPE_PROXY: $host = get_host_by_hostid($value); $str_val = $host['host']; break; case CONDITION_TYPE_DHOST_IP: $str_val = $value; break; case CONDITION_TYPE_DSERVICE_TYPE: $str_val = discovery_check_type2str($value); break; case CONDITION_TYPE_DSERVICE_PORT: $str_val = $value; break; case CONDITION_TYPE_DSTATUS: $str_val = discovery_object_status2str($value); break; case CONDITION_TYPE_DUPTIME: $str_val = $value; break; case CONDITION_TYPE_DVALUE: $str_val = $value; break; case CONDITION_TYPE_EVENT_ACKNOWLEDGED: $str_val = $value ? S_ACK : S_NOT_ACK; break; case CONDITION_TYPE_APPLICATION: $str_val = $value; break; default: return S_UNKNOWN; break; } return '"' . $str_val . '"'; }
public function bodyToString() { $this->cleanItems(); $ok = $uncl = $info = $warn = $avg = $high = $dis = 0; $options = array('monitored' => true, 'skipDependent' => true, 'output' => API_OUTPUT_SHORTEN); if ($this->hostid > 0) { $options['hostids'] = $this->hostid; } elseif ($this->groupid > 0) { $options['groupids'] = $this->groupid; } $triggers = API::Trigger()->get($options); $triggers = zbx_objectValues($triggers, 'triggerid'); $db_priority = DBselect('SELECT t.priority,t.value,count(DISTINCT t.triggerid) AS cnt' . ' FROM triggers t' . ' WHERE ' . dbConditionInt('t.triggerid', $triggers) . ' GROUP BY t.priority,t.value'); while ($row = DBfetch($db_priority)) { switch ($row['value']) { case TRIGGER_VALUE_TRUE: switch ($row['priority']) { case TRIGGER_SEVERITY_NOT_CLASSIFIED: $uncl += $row['cnt']; break; case TRIGGER_SEVERITY_INFORMATION: $info += $row['cnt']; break; case TRIGGER_SEVERITY_WARNING: $warn += $row['cnt']; break; case TRIGGER_SEVERITY_AVERAGE: $avg += $row['cnt']; break; case TRIGGER_SEVERITY_HIGH: $high += $row['cnt']; break; case TRIGGER_SEVERITY_DISASTER: $dis += $row['cnt']; break; } break; case TRIGGER_VALUE_FALSE: $ok += $row['cnt']; break; } } if ($this->show_header) { $header_str = _('Triggers info') . SPACE; if (!is_null($this->nodeid)) { $node = get_node_by_nodeid($this->nodeid); 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(8); } $this->addRow($header); } $trok = getSeverityCell(null, $ok . SPACE . _('Ok'), true); $uncl = getSeverityCell(TRIGGER_SEVERITY_NOT_CLASSIFIED, $uncl . SPACE . getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), !$uncl); $info = getSeverityCell(TRIGGER_SEVERITY_INFORMATION, $info . SPACE . getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), !$info); $warn = getSeverityCell(TRIGGER_SEVERITY_WARNING, $warn . SPACE . getSeverityCaption(TRIGGER_SEVERITY_WARNING), !$warn); $avg = getSeverityCell(TRIGGER_SEVERITY_AVERAGE, $avg . SPACE . getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), !$avg); $high = getSeverityCell(TRIGGER_SEVERITY_HIGH, $high . SPACE . getSeverityCaption(TRIGGER_SEVERITY_HIGH), !$high); $dis = getSeverityCell(TRIGGER_SEVERITY_DISASTER, $dis . SPACE . getSeverityCaption(TRIGGER_SEVERITY_DISASTER), !$dis); if (STYLE_HORISONTAL == $this->style) { $this->addRow(array($trok, $uncl, $info, $warn, $avg, $high, $dis)); } else { $this->addRow($trok); $this->addRow($uncl); $this->addRow($info); $this->addRow($warn); $this->addRow($avg); $this->addRow($high); $this->addRow($dis); } return parent::bodyToString(); }
public function bodyToString() { $this->cleanItems(); $okCount = 0; $notClassifiedCount = 0; $informationCount = 0; $warningCount = 0; $averageCount = 0; $highCount = 0; $disasterCount = 0; $options = array('output' => array('triggerid', 'priority', 'value'), 'monitored' => true, 'skipDependent' => true); if ($this->hostid > 0) { $options['hostids'] = $this->hostid; } elseif ($this->groupid > 0) { $options['groupids'] = $this->groupid; } $triggers = API::Trigger()->get($options); foreach ($triggers as $trigger) { if ($trigger['value'] == TRIGGER_VALUE_TRUE) { switch ($trigger['priority']) { case TRIGGER_SEVERITY_NOT_CLASSIFIED: $notClassifiedCount++; break; case TRIGGER_SEVERITY_INFORMATION: $informationCount++; break; case TRIGGER_SEVERITY_WARNING: $warningCount++; break; case TRIGGER_SEVERITY_AVERAGE: $averageCount++; break; case TRIGGER_SEVERITY_HIGH: $highCount++; break; case TRIGGER_SEVERITY_DISASTER: $disasterCount++; break; } } elseif ($trigger['value'] == TRIGGER_VALUE_FALSE) { $okCount++; } } if ($this->show_header) { $headerString = _('Triggers info') . SPACE; if (!is_null($this->nodeid)) { $node = get_node_by_nodeid($this->nodeid); if ($node > 0) { $headerString .= '(' . $node['name'] . ')' . SPACE; } } if ($this->groupid != 0) { $group = get_hostgroup_by_groupid($this->groupid); $headerString .= _('Group') . SPACE . '"' . $group['name'] . '"'; } else { $headerString .= _('All groups'); } $header = new CCol($headerString, 'header'); if ($this->style == STYLE_HORIZONTAL) { $header->setColspan(8); } $this->addRow($header); } $okCount = getSeverityCell(null, $okCount . SPACE . _('Ok'), true); $notClassifiedCount = getSeverityCell(TRIGGER_SEVERITY_NOT_CLASSIFIED, $notClassifiedCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), !$notClassifiedCount); $informationCount = getSeverityCell(TRIGGER_SEVERITY_INFORMATION, $informationCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), !$informationCount); $warningCount = getSeverityCell(TRIGGER_SEVERITY_WARNING, $warningCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_WARNING), !$warningCount); $averageCount = getSeverityCell(TRIGGER_SEVERITY_AVERAGE, $averageCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), !$averageCount); $highCount = getSeverityCell(TRIGGER_SEVERITY_HIGH, $highCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_HIGH), !$highCount); $disasterCount = getSeverityCell(TRIGGER_SEVERITY_DISASTER, $disasterCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_DISASTER), !$disasterCount); if (STYLE_HORIZONTAL == $this->style) { $this->addRow(array($okCount, $notClassifiedCount, $informationCount, $warningCount, $averageCount, $highCount, $disasterCount)); } else { $this->addRow($okCount); $this->addRow($notClassifiedCount); $this->addRow($informationCount); $this->addRow($warningCount); $this->addRow($averageCount); $this->addRow($highCount); $this->addRow($disasterCount); } return parent::bodyToString(); }
DBstart(); $result = delete_node($_REQUEST['nodeid']); $result = DBend($result); show_messages($result, _('Node deleted'), _('Cannot delete node')); if ($result) { add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_NODE, 'Node [' . $node['name'] . '] id [' . $node['nodeid'] . ']'); unset($_REQUEST['form'], $node); } } /* * Display */ if (isset($_REQUEST['form'])) { $data = array('nodeid' => get_request('nodeid'), 'masterNode' => DBfetch(DBselect('SELECT n.name FROM nodes n WHERE n.masterid IS NULL AND n.nodetype=' . ZBX_NODE_MASTER))); if (isset($_REQUEST['nodeid']) && !isset($_REQUEST['form_refresh'])) { $node = get_node_by_nodeid($data['nodeid']); $data['new_nodeid'] = $node['nodeid']; $data['name'] = $node['name']; $data['ip'] = $node['ip']; $data['port'] = $node['port']; $data['masterid'] = $node['masterid']; $data['nodetype'] = $node['nodetype']; } else { $data['new_nodeid'] = get_request('new_nodeid'); $data['name'] = get_request('name', ''); $data['ip'] = get_request('ip', '127.0.0.1'); $data['port'] = get_request('port', 10051); $data['nodetype'] = get_request('nodetype', ZBX_NODE_CHILD); $data['masterid'] = get_request('masterid', get_current_nodeid(false)); } $nodeView = new CView('administration.node.edit', $data);