Skip to content
ilcca edited this page Nov 6, 2014 · 3 revisions

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;

ESIM name | id | name | itemid | max_past_7_days | max_next24h | max_next24h -------+----+-----------------------------------------+--------+-----------------+-------------+------------- ohtu1 | 6 | Free swap space in % | 23685 | 95.5 | 104.8 | 106.8 ohtu1 | 5 | Free inodes on $1 (percentage) | 23710 | 99.8 | 99.8 | 99.8 ohtu1 | 2 | CPU $2 time | 23690 | 10.0 | 0.3 | 0.5 ohtu1 | 1 | Processor load (1 min average per core) | 23672 | 1.0 | 0.0 | 0.0 ohtu1 | 4 | Free disk space on $1 (percentage) | 23715 | 31.8 | 31.3 | 31.3 (5 rows)

Clone this wiki locally