Ad Widget

Collapse

Help on cleaning up the database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • burn1024
    Member
    • Jun 2012
    • 52

    #1

    Help on cleaning up the database

    Our database seems to be growing too quick, and so we decided to have some serious cleanup:
    1) disable most triggers that come by default (/vmlinuz size, "Configured max number of opened files", etc)
    2) set larger update intervals for all items
    3) disable all items that are not used in any triggers
    4) clear history and trends for all disabled items

    The question is - how do I perform 3) and 4) without spending 2 days in Zabbix WebUI?

    We're using Zabbix 1.8.1 with Postgresql 8.4.17.
  • burn1024
    Member
    • Jun 2012
    • 52

    #2
    Just for the record:
    1-3) Done manually, it turned out to be quick.

    4)
    Code:
    delete FROM alerts where age(to_timestamp(alerts.clock)) > interval '7 days';
    
    delete FROM acknowledges where age(to_timestamp(acknowledges.clock)) > interval '7 days';
    
    delete FROM events where age(to_timestamp(events.clock)) > interval '7 days';
    
    delete FROM history where age(to_timestamp(history.clock)) > interval '7 days';
    delete FROM history_uint where age(to_timestamp(history_uint.clock)) > interval '7 days' ;
    delete FROM history_str  where age(to_timestamp(history_str.clock)) > interval '7 days' ;
    delete FROM history_text where age(to_timestamp(history_text.clock)) > interval '7 days' ;
    delete FROM history_log where age(to_timestamp(history_log.clock)) > interval '7 days' ;
    
    delete FROM trends where age(to_timestamp(trends.clock)) > interval '90 days';
    delete FROM trends_uint where age(to_timestamp(trends_uint.clock)) > interval '90 days' ;
    Code:
    delete from history where itemid not in (select itemid from items where status='0');
    delete from history_uint where itemid not in (select itemid from items where status='0');
    delete from history_str where itemid not in (select itemid from items where status='0');
    delete from history_text where itemid not in (select itemid from items where status='0');
    delete from history_log where itemid not in (select itemid from items where status='0');
    
    delete from trends where itemid not in (select itemid from items where status='0');
    delete from trends_uint where itemid not in (select itemid from items where status='0');
    and also applied https://github.com/mattiasgeniar/zab...d-data-cleanup

    Comment

    • barbaros
      Member
      • Aug 2010
      • 32

      #3
      Originally posted by burn1024
      Does those scripts work for PostgreSQL?

      Comment

      • burn1024
        Member
        • Jun 2012
        • 52

        #4
        Originally posted by barbaros
        Does those scripts work for PostgreSQL?
        yes.

        P.S. let the admin who configured "your message is too short" for this forum rot in hell.

        Comment

        • barbaros
          Member
          • Aug 2010
          • 32

          #5
          Didn't you have any problems with Zabbix after manual data deleting?

          Comment

          • burn1024
            Member
            • Jun 2012
            • 52

            #6
            No, why would I?

            Comment

            • barbaros
              Member
              • Aug 2010
              • 32

              #7
              Sometimes manual intervention brokes things . Good to know everything went well, I am going to do the same operation on my DB.

              Comment

              • barbaros
                Member
                • Aug 2010
                • 32

                #8
                "select itemid from items where status='0'" means disabled items?

                Comment

                • burn1024
                  Member
                  • Jun 2012
                  • 52

                  #9
                  No it means enabled.

                  Comment

                  • barbaros
                    Member
                    • Aug 2010
                    • 32

                    #10
                    Yes, I've meant enabled, sorry . THX.

                    Comment

                    Working...