linux-基础服务监控

zabbix 从数据库查询数据的月度平均值指标

2021-02-03  本文已影响0人  宇晨棒棒的

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

上一篇 下一篇

猜你喜欢

热点阅读