1.通过hosts表查找host的ID
select host,hostid from hosts where host='Zabbix server';
+---------------+--------+
| host | hostid |
+---------------+--------+
| Zabbix server | 10084 |
+---------------+--------+
2.通过items表查找主的监控项和key以及itemid
select itemid,name,key_ from items where hostid=10084 and key_='web_time';
+--------+----------+----------+
| itemid | name | key_ |
+--------+----------+----------+
| 66786 | web_time | web_time |
+--------+----------+----------+
3.通过itemid查询主机的监控项目
select avg(value) from trends where itemid=66786 and from_unixtime(clock)>= '2020-12-01' and from_unixtime(clock)< '2021-01-01' \G
或者存在于
select avg(value_avg) from zabbix.trends_uint where itemid=66720 and from_unixtime(clock)>= '2020-12-01' and from_unixtime(clock)< '2021-01-01' \G
网友评论