Ad Widget

Collapse

Query for total duration of problem status of an item

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • addyrocker
    Junior Member
    • Sep 2009
    • 11

    #1

    Query for total duration of problem status of an item

    Hello guys,

    I need help with generating certain outage reports. What I'm trying to do is get the total status problem duration of a particular item of a host for a week or a day kind of like in webfront end of zabbix events.
    What I'm looking at is the events table in the database

    Code:
    +---------------+---------------------+------+-----+---------+-------+
    | Field         | Type                | Null | Key | Default | Extra |
    +---------------+---------------------+------+-----+---------+-------+
    | eventid       | bigint(20) unsigned | NO   | PRI | NULL    |       |
    | source        | int(11)             | NO   |     | 0       |       |
    | object        | int(11)             | NO   | MUL | 0       |       |
    | objectid      | bigint(20) unsigned | NO   |     | 0       |       |
    | clock         | int(11)             | NO   | MUL | 0       |       |
    | value         | int(11)             | NO   |     | 0       |       |
    | acknowledged  | int(11)             | NO   |     | 0       |       |
    | ns            | int(11)             | NO   |     | 0       |       |
    | value_changed | int(11)             | NO   |     | 0       |       |
    +---------------+---------------------+------+-----+---------+-------+
    I'm having trouble understanding what the ns field is, I know its nanoseconds something, is it the field of the duration of the problem like in the frontend events?, If I run the below query which is of a particular item which had problem status

    Code:
    select eventid, objectid, FROM_UNIXTIME(clock), ns  from events where objectid=16801 and value=1;
    +---------+----------+----------------------+-----------+
    | eventid | objectid | FROM_UNIXTIME(clock) | ns        |
    +---------+----------+----------------------+-----------+
    |   17027 |    16801 | 2012-11-08 01:08:08  | 475741590 |
    |   17046 |    16801 | 2012-11-08 01:12:26  | 526949770 |
    |   17048 |    16801 | 2012-11-08 01:26:00  | 411519269 |
    |   17066 |    16801 | 2012-11-08 01:31:49  | 428655906 |
    +---------+----------+----------------------+-----------+
    What I would like to get is the total problem duration, summed, of a particular objectid in this case 16801, I hope I'm making sense; value=1 indicates its a Status=Problem
    I hope someone can point me out in the right direction and if this can be accomplished through some other way?
    Help would be greatly appreciated!
Working...