SELECT
h. NAME AS '主机',
t.description AS '监控项',
t.priority AS '告警级别',
count(DISTINCT e.eventid) AS '告警次数'
FROM
`triggers` t,
`events` e,
functions f,
items i,
`hosts` h,
hosts_groups hg
WHERE
t.triggerid = e.objectid
AND e.source = 0
AND e.object = 0
AND e.clock > UNIX_TIMESTAMP(
DATE_SUB(NOW(), INTERVAL 1 DAY)
)
AND t.flags IN ('0', '4')
AND f.triggerid = t.triggerid
AND i.itemid = f.itemid
AND i.hostid = h.hostid
AND h.hostid = hg.hostid
AND t.description NOT LIKE '基础服务%'
AND t.description NOT LIKE '数据库%'
GROUP BY
e.objectid
ORDER BY
4 desc
LIMIT 10 OFFSET 0;