Hi Guys,
Can someone please provide me with a query to calculate the total time a trigger has spend in a 'problem' state for, say, a week?
I have this so far:
select h.hostid, h.name, i.itemid, i.name, f.triggerid, FROM_UNIXTIME(e.clock), e.eventid, e.value, value_changed from hosts h join items i on i.hostid = h.hostid join functions f on f.itemid = i.itemid join events e on e.objectid = f.triggerid where h.name = 'pefw01' and i.name like '%ping state%' and e.value in ('0','1');
It returns this:
+--------+--------+--------+------------+-----------+------------------------+---------+-------+---------------+
| hostid | name | itemid | name | triggerid | FROM_UNIXTIME(e.clock) | eventid | value | value_changed |
+--------+--------+--------+------------+-----------+------------------------+---------+-------+---------------+
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-04-06 05:16:05 | 1184442 | 1 | 1 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-04-06 09:21:05 | 1185581 | 0 | 1 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-04-06 09:28:05 | 1192701 | 0 | 0 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-04-06 17:14:05 | 1201841 | 0 | 0 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-04-23 13:50:05 | 1244284 | 0 | 0 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-07-24 12:28:05 | 1474883 | 0 | 0 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-09-17 15:23:05 | 1638433 | 0 | 0 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-09-19 00:58:05 | 1644037 | 1 | 1 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-09-19 18:04:05 | 1647148 | 0 | 1 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-09-19 18:20:05 | 1650414 | 1 | 1 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-09-19 18:29:05 | 1652073 | 0 | 1 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-09-20 08:22:05 | 1663467 | 0 | 0 |
+--------+--------+--------+------------+-----------+------------------------+---------+-------+---------------+
I'm not sure how to calculate the amount of time a trigger spends in the 'problem' state.
Thanks.
Can someone please provide me with a query to calculate the total time a trigger has spend in a 'problem' state for, say, a week?
I have this so far:
select h.hostid, h.name, i.itemid, i.name, f.triggerid, FROM_UNIXTIME(e.clock), e.eventid, e.value, value_changed from hosts h join items i on i.hostid = h.hostid join functions f on f.itemid = i.itemid join events e on e.objectid = f.triggerid where h.name = 'pefw01' and i.name like '%ping state%' and e.value in ('0','1');
It returns this:
+--------+--------+--------+------------+-----------+------------------------+---------+-------+---------------+
| hostid | name | itemid | name | triggerid | FROM_UNIXTIME(e.clock) | eventid | value | value_changed |
+--------+--------+--------+------------+-----------+------------------------+---------+-------+---------------+
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-04-06 05:16:05 | 1184442 | 1 | 1 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-04-06 09:21:05 | 1185581 | 0 | 1 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-04-06 09:28:05 | 1192701 | 0 | 0 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-04-06 17:14:05 | 1201841 | 0 | 0 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-04-23 13:50:05 | 1244284 | 0 | 0 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-07-24 12:28:05 | 1474883 | 0 | 0 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-09-17 15:23:05 | 1638433 | 0 | 0 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-09-19 00:58:05 | 1644037 | 1 | 1 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-09-19 18:04:05 | 1647148 | 0 | 1 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-09-19 18:20:05 | 1650414 | 1 | 1 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-09-19 18:29:05 | 1652073 | 0 | 1 |
| 10146 | PEFW01 | 23405 | Ping State | 13597 | 2015-09-20 08:22:05 | 1663467 | 0 | 0 |
+--------+--------+--------+------------+-----------+------------------------+---------+-------+---------------+
I'm not sure how to calculate the amount of time a trigger spends in the 'problem' state.
Thanks.
Comment