zabbix数据库获取监控数据
登录数据库
获取hostid
select host,hostid from hosts where host="test";
输出结果:
+---------------------+--------+
| host | hostid |
+---------------------+--------+
| test | 10218 |
+---------------------+--------+
获取itemid
select itemid,name,key_ from items where hostid=10218 and key_="net.if.out[eth0]";
输出结果:
+--------+--------------------------------+-----------------+
| itemid | name | key_ |
+--------+--------------------------------+-----------------+
| 32590 | Outgoing network traffic on $1 | net.if.out[eth0] |
+--------+--------------------------------+-----------------+
获取监控数据
select from_unixtime(clock) as DateTime,round(value/1024/1024,2) as Traffic_out from history_uint where itemid="32590" and from_unixtime(clock)>='2014-12-21' and from_unixtime(clock)='2014-12-21' and from_unixtime(clock)='2014-12-21' and from_unixtime(clock)