Ad Widget

Collapse

which table store the latest data?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fonefone
    Junior Member
    • Jul 2010
    • 12

    #1

    which table store the latest data?

    Hi All,

    I'd like to know where the latest data stored...
    I'm using mysql database
    can anyone help me
    thanks in advance
  • asaveljevs
    Zabbix developer
    • Feb 2010
    • 36

    #2
    All the data on the server is stored in tables history, history_uint, history_log, history_str, and history_text, depending on the item type.

    Comment

    • zabbix_zen
      Senior Member
      • Jul 2009
      • 426

      #3
      It's stored across the history* tables depending on the item's type.
      To get the intended data, you need the correct itemid, clock, etc..

      Comment

      • alixen
        Senior Member
        • Apr 2006
        • 474

        #4
        Hi,

        If you are only interested in latest value, you can get it directly from items table.
        There are two fields:
        lastvalue varchar(255)
        lastclock int(11)
        that contain latest value and associated timestamp.

        Regards,
        Alixen
        http://www.alixen.fr/zabbix.html

        Comment

        • fonefone
          Junior Member
          • Jul 2010
          • 12

          #5
          i want to get free space on /home min,avg,max statistic between the past week.

          i can see them from the PNG graphs below, but i can not get their value from mysql.


          i can get the latest data by using zabbix_get

          Comment

          • alixen
            Senior Member
            • Apr 2006
            • 474

            #6
            Hi,

            Originally posted by fonefone
            i want to get free space on /home min,avg,max statistic between the past week.
            That's not latest data, the values you want are stored in trends table.
            You'll have to join it with items and hosts tables to get what you want.
            This is the SQL query I use for that:

            Code:
            select i.itemid,
                   from_unixtime(clock),
                   t.num,
                   t.value_min,
                   t.value_avg,
                   t.value_max
              from hosts h,
                   items i,
                   trends t
             where i.hostid=h.hostid
               and t.itemid=i.itemid
               and h.host='my_host'
               and i.description='my_item'
             order by clock desc
            You'll get something like:
            Code:
            +--------+----------------------+-----+-----------+-----------+-----------+
            | itemid | from_unixtime(clock) | num | value_min | value_avg | value_max |
            +--------+----------------------+-----+-----------+-----------+-----------+
            |  19571 | 2010-03-31 10:00:00  |  12 |    0.6400 |    1.6033 |    3.2400 |
            |  19571 | 2010-03-31 09:00:00  |  12 |    0.3700 |    1.0092 |    2.0200 |
            Originally posted by fonefone
            i can see them from the PNG graphs below, but i can not get their value from mysql.
            This URL is not valid

            Originally posted by fonefone
            i can get the latest data by using zabbix_get
            I thought that you wanted to get it from the database not the device.

            Regards,
            Alixen
            http://www.alixen.fr/zabbix.html

            Comment

            • fonefone
              Junior Member
              • Jul 2010
              • 12

              #7
              Originally posted by alixen
              Hi,



              That's not latest data, the values you want are stored in trends table.
              You'll have to join it with items and hosts tables to get what you want.
              This is the SQL query I use for that:

              Code:
              select i.itemid,
                     from_unixtime(clock),
                     t.num,
                     t.value_min,
                     t.value_avg,
                     t.value_max
                from hosts h,
                     items i,
                     trends t
               where i.hostid=h.hostid
                 and t.itemid=i.itemid
                 and h.host='my_host'
                 and i.description='my_item'
               order by clock desc
              You'll get something like:
              Code:
              +--------+----------------------+-----+-----------+-----------+-----------+
              | itemid | from_unixtime(clock) | num | value_min | value_avg | value_max |
              +--------+----------------------+-----+-----------+-----------+-----------+
              |  19571 | 2010-03-31 10:00:00  |  12 |    0.6400 |    1.6033 |    3.2400 |
              |  19571 | 2010-03-31 09:00:00  |  12 |    0.3700 |    1.0092 |    2.0200 |


              This URL is not valid


              I thought that you wanted to get it from the database not the device.

              Regards,
              Alixen

              excellent!!!
              i love you so much~~
              can you tell how to write the sql by the following url:


              need to collect one week data..
              Last edited by fonefone; 24-08-2010, 12:01.

              Comment

              Working...