Zabbix DB notes - Multi-Axis/multi-axis-graphs GitHub Wiki
Get item history
items.value_type | relevant history table |
---|---|
0 | history (.0000) |
1 | history_str (string) |
2 | ? |
3 | history_uint (20) |
4 | ? |
select distinct i.itemid, i.name, i.units, i.value_type, hi.itemid as
history_iid, hu.itemid as history_uint_iid, ht.itemid as history_str_iid from
items as i left join history as hi on i.itemid = hi.itemid left join
history_uint as hu on hu.itemid = i.itemid left join history_str as ht on
ht.itemid = i.itemid
where i.hostid = 10105;
Dashboardin SQL-lause -hakee serverikohtaisesti itemit, nimet, sarakkeille 7 päivän maksimi, 24 tunnin ennuste maksimille, 7 päivän ennuste maksimille
select ho.name, if.id, i.name, i.itemid, max(h.value) as max_past_7d, max(f1.value) as max_next_24h, max(f2.value) as max_next_7d FROM hosts ho, item_future if, items i, history h, future f1, future f2 where ho.hostid=i.hostid and if.itemid = i.itemid and i.itemid = h.itemid and h.clock > EXTRACT(EPOCH FROM current_timestamp) - 786400 and if.id = f1.itemid and f1.clock > EXTRACT(EPOCH FROM current_timestamp) and f1.clock < EXTRACT(EPOCH FROM current_timestamp) + 86400 and if.id = f2.itemid and f2.clock > EXTRACT(EPOCH FROM current_timestamp) and f2.clock < EXTRACT(EPOCH FROM current_timestamp) + 786400 group by ho.name, if.id, i.name, i.itemid;