查询1天内的Top
点击(此处)折叠或打开
-
SELECT h.`name`, t.`description`, COUNT(*) num
- FROM `events` e
- JOIN `triggers` t ON e.`objectid`=t.`triggerid` AND t.`priority`>=2
- JOIN functions f ON f.`triggerid`=t.`triggerid`
- JOIN items i ON f.`itemid`=i.`itemid`
- JOIN `hosts` h ON i.`hostid`=h.`hostid`
- WHERE e.object=0 AND e.source=0 and e.`clock`>=UNIX_TIMESTAMP(DATE_SUB(NOW(),INTERVAL 1 DAY))
- GROUP BY h.`name`, t.`description`
- ORDER BY num DESC,t.`priority` DESC
- limit 100