Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-18776

zabbix_agent2 doesn't logrotate

XMLWordPrintable

    • Icon: Problem report Problem report
    • Resolution: Unresolved
    • Icon: Trivial Trivial
    • None
    • 5.0.6
    • None
    • None
    • ZabbixAgent2 5.0.6
      CentOS 8.2.2004

      Case:
      Zabbix Agent 2 can not logrotate that using default /etc/logrotate.d/zabbix-agent2.
      /etc/logrotate.d/zabbix-agent2 need to change config using copytruncate.

      Environment:
      zabbix-agent2-5.0.6-1.el8.x86_64

      # cat /etc/logrotate.d/zabbix-agent2
      
      /var/log/zabbix/zabbix_agent2.log {
              weekly
              rotate 12
              compress
              delaycompress
              missingok
              notifempty
              create 0664 zabbix zabbix
      }
      

      For instance:
      zabbix_agent2 doesn't write log but writes in old logfile

      Result:

      Use default config (/etc/logrotate.d/zabbix-agent2)

      # ls -l /var/log/zabbix/zabbix_agent2.log*
      -rw-rw-r--. 1 zabbix zabbix 3453 Dec 16 06:42 /var/log/zabbix/zabbix_agent2.log
      
      # logrotate -f /etc/logrotate.d/zabbix-agent2
      
      # ls -l /var/log/zabbix/zabbix_agent2.log*
      -rw-rw-r--. 1 zabbix zabbix    0 Dec 16 06:43 /var/log/zabbix/zabbix_agent2.log
      -rw-rw-r--. 1 zabbix zabbix 3649 Dec 16 06:43 /var/log/zabbix/zabbix_agent2.log.1
      
      # ls -l /var/log/zabbix/zabbix_agent2.log*
      -rw-rw-r--. 1 zabbix zabbix    0 Dec 16 06:43 /var/log/zabbix/zabbix_agent2.log
      -rw-rw-r--. 1 zabbix zabbix 4237 Dec 16 06:46 /var/log/zabbix/zabbix_agent2.log.1
      

      Use copytruncate

      # cat /etc/logrotate.d/zabbix-agent2
      /var/log/zabbix/zabbix_agent2.log {
      	weekly
      	rotate 12
      	compress
      	delaycompress
      	missingok
      	notifempty
      	copytruncate
      }
      
      # ls -l /var/log/zabbix/zabbix_agentd2.log*
      -rw-rw-r--. 1 zabbix zabbix  3061 Dec 16 07:40 zabbix_agent2.log
      
      # logrotate -f /etc/logrotate.d/zabbix-agent2
      
      # ls -l /var/log/zabbix/zabbix_agent2.log*
      -rw-rw-r--. 1 zabbix zabbix  196 Dec 16 07:41 /var/log/zabbix/zabbix_agent2.log
      -rw-rw-r--. 1 zabbix zabbix 3257 Dec 16 07:40 /var/log/zabbix/zabbix_agent2.log.1
      

            zabbix.dev Zabbix Development Team
            kt_eng06 Keita Higa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: