Ad Widget

Collapse

Zabbix MySQL - Query the history

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xFlux
    Junior Member
    • Mar 2007
    • 2

    #1

    Zabbix MySQL - Query the history

    Hello,

    I have an INT item that I am trying to query on the MySQL backend, but ordering this sucker for the last 30 records seems impossible.

    SELECT * FROM history_uint WHERE itemid=22480 ORDER BY clock DESC;

    Can anyone suggest the correct procedure for returning the latest values for an itemid in the Zabbix database?



    Im guessing at this point the values are stored elsewhere for historical hourly graphs?
    Last edited by xFlux; 14-04-2009, 04:18.
  • t2y
    Member
    • Feb 2009
    • 60

    #2
    Hi xFlux,

    I have a suggestion(on zabbix-1.6.4). Do you want this?
    mysql> select itemid, type, key_, value_type, lastvalue, units, description, valuemapid from items where itemid=22480;
    It might be found in "overview.php" if you don't want above. I just found as follows.
    overview.php:
    Code:
    1007     $result = DBselect('SELECT DISTINCT h.hostid, h.host,i.itemid, i.key_, i.value_type, i.lastvalue, i.units, '.
    1008                     ' i.description, t.priority, i.valuemapid, t.value as tr_value, t.triggerid '.
    1009             ' FROM hosts h, items i '.
    1010                     ' LEFT JOIN functions f on f.itemid=i.itemid '.
    1011                     ' LEFT JOIN triggers t on t.triggerid=f.triggerid '.
    1012             ' WHERE '.DBcondition('h.hostid',$hostids).
    1013                     ' AND h.status='.HOST_STATUS_MONITORED.
    1014                     ' AND h.hostid=i.hostid '.
    1015                     ' AND i.status='.ITEM_STATUS_ACTIVE.
    1016             ' ORDER BY i.description,i.itemid');

    Comment

    • rue
      Member
      Zabbix Certified Specialist
      • May 2006
      • 43

      #3
      Originally posted by xFlux
      Hello,

      I have an INT item that I am trying to query on the MySQL backend, but ordering this sucker for the last 30 records seems impossible.

      SELECT * FROM history_uint WHERE itemid=22480 ORDER BY clock DESC;

      Can anyone suggest the correct procedure for returning the latest values for an itemid in the Zabbix database?



      Im guessing at this point the values are stored elsewhere for historical hourly graphs?
      SELECT * FROM history_uint WHERE itemid=22480 ORDER BY clock DESC limit 30 ?

      RĂ¼

      Comment

      Working...