Ad Widget

Collapse

How to clean all history ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jarek
    Member
    • May 2005
    • 35

    #1

    How to clean all history ?

    Is there any way to clean all history data in zabbix database ?
    By some time, I had wrong time in zabbix server (a month ahead), and when time and date has been corrected, zabbix looks a litle bit screwed.
  • whowd
    Junior Member
    • Jul 2007
    • 28

    #2
    You can connect directly to the database and enter the following:

    Code:
    DELETE FROM history
    DELETE FROM history_str
    DELETE FROM history_uint

    Comment

    • kozian
      Junior Member
      • Oct 2009
      • 7

      #3
      Originally posted by whowd
      You can connect directly to the database and enter the following:

      Code:
      DELETE FROM history
      DELETE FROM history_str
      DELETE FROM history_uint
      What about history_log table? Should it be purged too?

      seems like it is more efficiently to use this:
      Code:
      TRUNCATE TABLE history;
      TRUNCATE TABLE history_str;
      TRUNCATE TABLE history_uint;
      TRUNCATE TABLE history_log;

      Comment

      • Peteris
        Member
        • Feb 2010
        • 89

        #4
        Somebody explain please what is difference between:

        history and history_uint tables in database

        What does one contains and what other?

        Comment

        • alixen
          Senior Member
          • Apr 2006
          • 474

          #5
          Originally posted by Peteris
          Somebody explain please what is difference between:

          history and history_uint tables in database

          What does one contains and what other?
          history contains data items of type "Numeric (float)"
          history_uint contains data items of type "Numeric (integer 64 bits)"

          Code:
          mysql> desc history;
          +--------+---------------------+------+-----+---------+-------+
          | Field  | Type                | Null | Key | Default | Extra |
          +--------+---------------------+------+-----+---------+-------+
          | itemid | bigint(20) unsigned | NO   | MUL | 0       |       |
          | clock  | int(11)             | NO   |     | 0       |       |
          | value  | double(16,4)        | NO   |     | 0.0000  |       |
          +--------+---------------------+------+-----+---------+-------+
          3 rows in set (0.00 sec)
          
          mysql> desc history_uint;
          +--------+---------------------+------+-----+---------+-------+
          | Field  | Type                | Null | Key | Default | Extra |
          +--------+---------------------+------+-----+---------+-------+
          | itemid | bigint(20) unsigned | NO   | MUL | 0       |       |
          | clock  | int(11)             | NO   |     | 0       |       |
          | value  | bigint(20) unsigned | NO   |     | 0       |       |
          +--------+---------------------+------+-----+---------+-------+
          Regards,
          Alixen
          http://www.alixen.fr/zabbix.html

          Comment

          • Avinasha
            Member
            • Jan 2018
            • 40

            #6
            Hi,

            Has anybody tried doing this? I'm in need of removing all history but retaining all configuration. Does dropping just 4 tables will help me to achieve this?

            Regards,
            Avinasha

            Comment

            • doutdex
              Junior Member
              • Mar 2023
              • 3

              #7
              I had the same issue I just delete old history and not trends or config.

              truncate table history;

              truncate table history_log;

              truncate table history_str;

              truncate table history_uint;

              truncate table history_text ;






              Originally posted by Avinasha
              Hi,

              Has anybody tried doing this? I'm in need of removing all history but retaining all configuration. Does dropping just 4 tables will help me to achieve this?

              Regards,
              Avinasha

              Comment

              • Avinasha
                Member
                • Jan 2018
                • 40

                #8

                If you do this --->

                Will the list of alerts fade away? Do we get any issues on the long run?


                mysqldump -uroot -pYOURPASSWORD zabbix --triggers --routines --ignore-table-data="zabbix.history" --ignore-table-data="zabbix.history_str" --ignore-table-data="zabbix.history_uint" --ignore-table-data="zabbix.history_log" --ignore-table-data="zabbix.history_text" --ignore-table-data="zabbix.alerts" --ignore-table-data="zabbix.trends" --ignore-table-data="zabbix.trends_uint" --ignore-table-data="zabbix.events" --ignore-table-data="zabbix.problem">zabbix.sql


                This is what I did. But in the long run, I see that this will cause strange php errors. Did you face any such issue? I have to keep making new DBs without history for the new servers I send to customers. So I need to repeat this and each setup different from one another at least few items. I have 10-20 versions of different apps or changed hardware. as time goes on this number of versions keep increasing and I need to find a consistence way to make versions without history. Biggest problem I see is that, we can export all templates into 1 file, but you can't import them if they are in one file.

                Originally posted by doutdex
                I had the same issue I just delete old history and not trends or config.

                truncate table history;

                truncate table history_log;

                truncate table history_str;

                truncate table history_uint;

                truncate table history_text ;









                Regards,
                Avi

                Comment

                Working...