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(); }
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(); }
} redirect($last_page['url']); exit; } } } $msg = $bulk ? ' BULK ACKNOWLEDGE ' : array('"' . expand_trigger_description_by_data($db_data) . '"', BR(), explode_exp($db_data["expression"], 1)); show_table_header(array(S_ALARM_ACKNOWLEDGES_BIG, ' : ', $msg)); echo SBR; if (!$bulk) { $table = new CTable(NULL, "ack_msgs"); $table->SetAlign("center"); $db_acks = get_acknowledges_by_eventid($db_data["eventid"]); while ($db_ack = DBfetch($db_acks)) { $db_user = get_user_by_userid($db_ack["userid"]); $table->AddRow(array(new CCol($db_user["alias"], "user"), new CCol(date("d-m-Y h:i:s A", $db_ack["clock"]), "time")), "title"); $msgCol = new CCol(zbx_nl2br($db_ack['message'])); $msgCol->SetColspan(2); $table->AddRow($msgCol, "msg"); } /**/ if ($table->GetNumRows() > 0) { $table->Show(); echo SBR; } } insert_new_message_form($events, $bulk); ?> <?php include_once "include/page_footer.php";
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(); }