Old logs in /opt/zimbra/zmstats

Discuss your pilot or production implementation with other Zimbra admins or our engineers.
Post Reply
mtk
Posts: 37
Joined: Sat Jun 21, 2014 1:00 am

Old logs in /opt/zimbra/zmstats

Post by mtk »

Hi,

using Zimbra for quite some years, the installation seems to have stored several years of daily logs in /opt/zimbra/zmstats in folders like

Code: Select all

drwxr-x--- 2 zimbra zimbra     4096 Jan  2  2015 2015-01-01
drwxr-x--- 2 zimbra zimbra     4096 Jan  3  2015 2015-01-02
drwxr-x--- 2 zimbra zimbra     4096 Jan  4  2015 2015-01-03
drwxr-x--- 2 zimbra zimbra     4096 Jan  5  2015 2015-01-04
drwxr-x--- 2 zimbra zimbra     4096 Jan  6  2015 2015-01-05
Containing each:

Code: Select all

-rw-r----- 1 zimbra zimbra 2026410 Jan  2  2015 allprocs.csv.gz
-rw-r----- 1 zimbra zimbra   75334 Jan  2  2015 cpu.csv.gz
-rw-r----- 1 zimbra zimbra    1036 Jan  2  2015 df.csv.gz
-rw-r----- 1 zimbra zimbra    9387 Jan  2  2015 fd.csv.gz
-rw-r----- 1 zimbra zimbra   28958 Jan  2  2015 io.csv.gz
-rw-r----- 1 zimbra zimbra   75379 Jan  2  2015 io-x.csv.gz
-rw-r----- 1 zimbra zimbra   34277 Jan  2  2015 ldap.csv.gz
-rw-r----- 1 zimbra zimbra   60481 Jan  2  2015 mailboxd.csv.gz
-rw-r----- 1 zimbra zimbra    7321 Jan  2  2015 mtaqueue.csv.gz
-rw-r----- 1 zimbra zimbra  449571 Jan  2  2015 mysql.csv.gz
-rw-r----- 1 zimbra zimbra   18031 Jan  2  2015 nginx.csv.gz
-rw-r----- 1 zimbra zimbra   69192 Jan  2  2015 proc.csv.gz
-rw-r----- 1 zimbra zimbra    4555 Jan  2  2015 soap.csv.gz
-rw-r----- 1 zimbra zimbra   15261 Jan  2  2015 sql.csv.gz
-rw-r----- 1 zimbra zimbra    4321 Jan  2  2015 threads.csv.gz
-rw-r----- 1 zimbra zimbra  189198 Jan  2  2015 vm.csv.gz
Questions:
  • - Can those folders simply be deleted?
    - Is there any flag for log rotation or purging, that I am missing?
Thanks for your help in advance!
User avatar
JDunphy
Outstanding Member
Outstanding Member
Posts: 901
Joined: Fri Sep 12, 2014 11:18 pm
Location: Victoria, BC
ZCS/ZD Version: 9.0.0_P39 NETWORK Edition

Re: Old logs in /opt/zimbra/zmstats

Post by JDunphy »

Take a look at zmstat-cleanup which is a bash script:

Code: Select all

# su - zimbra
% /opt/zimbra/libexec/zmstat-cleanup --help

Usage: /opt/zimbra/libexec/zmstat-cleanup [-k <keep count>] [-h] [-l] [-p]

    -h|--help    Help/usage information
    -k|--keep    Number of archived copies of zmstat data to retain.
    -l|--list    Generate a listing of log dates archived.
    -p|--purge   Purge ALL archived zmstats data.
FYI... purge isn't doing anything sophisticated... finding a list directories and looping to delete each directory with /bin/rm -rf ... just historical data to look at
User avatar
JDunphy
Outstanding Member
Outstanding Member
Posts: 901
Joined: Fri Sep 12, 2014 11:18 pm
Location: Victoria, BC
ZCS/ZD Version: 9.0.0_P39 NETWORK Edition

Re: Old logs in /opt/zimbra/zmstats

Post by JDunphy »

Probably should provide a usage for others in the future.... Here is an example of one method:

Code: Select all

su - zimbra
ls
2019-05-15  2019-05-21  2019-05-27  2019-06-02  2019-06-08  2019-06-14  2019-06-20  2019-06-26  2019-07-02       df.csv     ldap.csv      pid        sync.csv                zmstat.out-20190630.gz
2019-05-16  2019-05-22  2019-05-28  2019-06-03  2019-06-09  2019-06-15  2019-06-21  2019-06-27  2019-07-03       df.csv.gz  mailboxd.csv  pop3.csv   threads.csv             zmstat.out-20190701.gz
2019-05-17  2019-05-23  2019-05-29  2019-06-04  2019-06-10  2019-06-16  2019-06-22  2019-06-28  allprocs.csv     fd.csv     mtaqueue.csv  proc.csv   vm.csv                  zmstat.out-20190702.gz
2019-05-18  2019-05-24  2019-05-30  2019-06-05  2019-06-11  2019-06-17  2019-06-23  2019-06-29  allprocs.csv.gz  imap.csv   mysql.csv     slapd.csv  zmstat.out              zmstat.out-20190703.gz
2019-05-19  2019-05-25  2019-05-31  2019-06-06  2019-06-12  2019-06-18  2019-06-24  2019-06-30  convertd.csv     io-x.csv   mysql.csv.gz  soap.csv   zmstat.out-20190628.gz  zmstat.out-20190704.gz
2019-05-20  2019-05-26  2019-06-01  2019-06-07  2019-06-13  2019-06-19  2019-06-25  2019-07-01  cpu.csv          io.csv     nginx.csv     sql.csv    zmstat.out-20190629.gz
[zimbra@tmail zmstat]$ /opt/zimbra/libexec/zmstat-cleanup --keep 5 
Deleting 2019-06-28 zmstat archive.
Deleting 2019-06-27 zmstat archive.
Deleting 2019-06-26 zmstat archive.
Deleting 2019-06-25 zmstat archive.
Deleting 2019-06-24 zmstat archive.
Deleting 2019-06-23 zmstat archive.
Deleting 2019-06-22 zmstat archive.
Deleting 2019-06-21 zmstat archive.
Deleting 2019-06-20 zmstat archive.
Deleting 2019-06-19 zmstat archive.
Deleting 2019-06-18 zmstat archive.
Deleting 2019-06-17 zmstat archive.
Deleting 2019-06-16 zmstat archive.
Deleting 2019-06-15 zmstat archive.
Deleting 2019-06-14 zmstat archive.
Deleting 2019-06-13 zmstat archive.
Deleting 2019-06-12 zmstat archive.
Deleting 2019-06-11 zmstat archive.
Deleting 2019-06-10 zmstat archive.
Deleting 2019-06-09 zmstat archive.
Deleting 2019-06-08 zmstat archive.
Deleting 2019-06-07 zmstat archive.
Deleting 2019-06-06 zmstat archive.
Deleting 2019-06-05 zmstat archive.
Deleting 2019-06-04 zmstat archive.
Deleting 2019-06-03 zmstat archive.
Deleting 2019-06-02 zmstat archive.
Deleting 2019-06-01 zmstat archive.
Deleting 2019-05-31 zmstat archive.
Deleting 2019-05-30 zmstat archive.
Deleting 2019-05-29 zmstat archive.
Deleting 2019-05-28 zmstat archive.
Deleting 2019-05-27 zmstat archive.
Deleting 2019-05-26 zmstat archive.
Deleting 2019-05-25 zmstat archive.
Deleting 2019-05-24 zmstat archive.
Deleting 2019-05-23 zmstat archive.
Deleting 2019-05-22 zmstat archive.
Deleting 2019-05-21 zmstat archive.
Deleting 2019-05-20 zmstat archive.
Deleting 2019-05-19 zmstat archive.
Deleting 2019-05-18 zmstat archive.
Deleting 2019-05-17 zmstat archive.
Deleting 2019-05-16 zmstat archive.
Deleting 2019-05-15 zmstat archive.
[zimbra@tmail zmstat]$ ls
2019-06-29  2019-07-02    allprocs.csv.gz  df.csv     imap.csv  ldap.csv      mysql.csv     pid       slapd.csv  sync.csv     zmstat.out              zmstat.out-20190630.gz  zmstat.out-20190703.gz
2019-06-30  2019-07-03    convertd.csv     df.csv.gz  io-x.csv  mailboxd.csv  mysql.csv.gz  pop3.csv  soap.csv   threads.csv  zmstat.out-20190628.gz  zmstat.out-20190701.gz  zmstat.out-20190704.gz
2019-07-01  allprocs.csv  cpu.csv          fd.csv     io.csv    mtaqueue.csv  nginx.csv     proc.csv  sql.csv    vm.csv       zmstat.out-20190629.gz  zmstat.out-20190702.gz
Add this to your zimbra's crontab if you wanted to retain a month or year, etc.
mtk
Posts: 37
Joined: Sat Jun 21, 2014 1:00 am

Re: Old logs in /opt/zimbra/zmstats

Post by mtk »

Thank you! That worked.
Post Reply