Ad Widget

Collapse

What's the best way to query Zabbix DB?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dickinson
    Member
    • Oct 2010
    • 44

    #1

    What's the best way to query Zabbix DB?

    Hi everyone,

    I want to get some data collected by Zabbix some weeks ago in order to make some analisys of a problem we have.

    My question is, what's the best way to get that data? I tried by using the GUI but i guess it isnt possible.

    Thanks in advance.
  • Zaniwoop
    Senior Member
    • Jan 2010
    • 232

    #2
    ... with SQL queries.

    What database are you using?

    Comment

    • hirschnf
      Member
      • Jan 2010
      • 56

      #3
      if you use MySQL you can use the script in this thread http://www.zabbix.com/forum/showthread.php?t=22478 as an example.
      Of course you have to build your own queries.

      Comment

      • dickinson
        Member
        • Oct 2010
        • 44

        #4
        Hello, tnx for your answers. I'm using mysql, but the link you told me has no relationship with this topic.

        For example, i need to see the data collected for Zabbix of a web monitoring two weeks ago.

        Comment

        • Zaniwoop
          Senior Member
          • Jan 2010
          • 232

          #5
          how well do you know SQL?

          Comment

          • hirschnf
            Member
            • Jan 2010
            • 56

            #6
            @dickinson:
            the relationship is how to connect to the zabbix database to collect your data.
            The precondition is that you know something about SQL to make your queries and a little bit about PHP.
            I use little PHP-Scripts like this to collect data from the zabbix DB which I use in other applications or for extended analysis.

            Comment

            • dickinson
              Member
              • Oct 2010
              • 44

              #7
              Zaniwoop: i'm able to make some queries, i'd need to know where Zabbix store that info in DB


              Hirschnf: Could you share one of those scripts with me?

              Thank guys

              Comment

              • ghoz
                Senior Member
                • May 2011
                • 204

                #8
                on a related note, if you didn't find all the historical data and trends in the gui, you won't find them in the database either...

                Comment

                • hirschnf
                  Member
                  • Jan 2010
                  • 56

                  #9
                  yes, that's right.
                  But if you need the data somewhere else you can take a look to the zabbix database.
                  For the first steps I use a database client for MySQL - phpmyadmin, sidu24, heidisql... . There you have a nice graphical overview what tables the database have.

                  To find the host:
                  Code:
                  select * from hosts where host like 'Serverxy%';
                  Here you can see the column hostid, which I use in the next SQL Statement

                  Code:
                  select * from items where hostid = '12345';
                  Here you will see all items from this host

                  Take the itemid you want and use the next statement to get the values.
                  Code:
                  select * from zabbix.history where itemid = '23402';
                  This is the manual way. So place the statements in your code and modify the result as you need.
                  In my opinion the zabbix database is easy to understand and to use.

                  Comment

                  • Zaniwoop
                    Senior Member
                    • Jan 2010
                    • 232

                    #10
                    There is also the official MySQL Workbench, downloadable from the mysql (Oracle ) site.

                    Not only can you do queries from it, but it also has a feature to reverse engineer Entiny Relationship Models

                    Comment

                    • dickinson
                      Member
                      • Oct 2010
                      • 44

                      #11
                      Uff..great..that way seems easy...i'm gonna try

                      Ghoz..have a question, where i can find values (not only a graph) since one month ago using the GUI?

                      Comment

                      • ghoz
                        Senior Member
                        • May 2011
                        • 204

                        #12
                        when looking at a simple graph, choose 'value' from the drop down menu on the top right.

                        but again, the data will be there only if the item's "keep history" is big enought

                        If you want the trends values , I'm afraid the data is only avaiable in the database in the trend* tables

                        Comment

                        • dickinson
                          Member
                          • Oct 2010
                          • 44

                          #13
                          Thanks everyone

                          Comment

                          Working...