本文整理匯總了PHP中CTable::BodyToString方法的典型用法代碼示例。如果您正苦於以下問題:PHP CTable::BodyToString方法的具體用法?PHP CTable::BodyToString怎麽用?PHP CTable::BodyToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CTable
的用法示例。
在下文中一共展示了CTable::BodyToString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: bodyToString
public function bodyToString()
{
$available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY, get_current_nodeid(true));
foreach ($available_triggers as $id => $triggerid) {
if (trigger_dependent($triggerid)) {
unset($available_triggers[$id]);
}
}
$this->cleanItems();
$ok = $uncn = $info = $warn = $avg = $high = $dis = 0;
$sql_from = '';
$sql_where = '';
if ($this->groupid > 0) {
$sql_from = ', hosts_groups hg ';
$sql_where = ' AND hg.groupid=' . $this->groupid . ' AND h.hostid=hg.hostid ';
}
$db_priority = DBselect('SELECT t.priority,t.value,count(DISTINCT t.triggerid) as cnt ' . ' FROM triggers t,hosts h,items i,functions f ' . $sql_from . ' WHERE t.status=' . TRIGGER_STATUS_ENABLED . ' AND f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND t.triggerid=f.triggerid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('t.triggerid', $available_triggers) . $sql_where . ' GROUP BY t.priority,t.value');
while ($row = DBfetch($db_priority)) {
switch ($row["value"]) {
case TRIGGER_VALUE_TRUE:
switch ($row["priority"]) {
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;
default:
$uncn += $row["cnt"];
break;
}
break;
case TRIGGER_VALUE_FALSE:
$ok += $row["cnt"];
break;
default:
$uncn += $row["cnt"];
break;
}
}
if ($this->show_header) {
$header = new CCol(S_TRIGGERS_INFO, "header");
if ($this->style == STYLE_HORISONTAL) {
$header->SetColspan(7);
}
$this->addRow($header);
}
$trok = new CCol($ok . SPACE . S_OK, get_severity_style('ok', false));
$uncn = new CCol($uncn . SPACE . S_NOT_CLASSIFIED, get_severity_style(TRIGGER_SEVERITY_NOT_CLASSIFIED, $uncn));
$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, $info, $warn, $avg, $high, $dis));
} else {
$this->addRow($trok);
$this->addRow($uncn);
$this->addRow($info);
$this->addRow($warn);
$this->addRow($avg);
$this->addRow($high);
$this->addRow($dis);
}
return parent::BodyToString();
}
示例2: bodyToString
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();
}