Zimbra CLI commands

The documents of zimbra online is so messy with a lot of Zimbra versions and supported/unsupported articles. I write this for myself.

Show current config

 zmprov desc -a attribute

zimbra log directory


[ MySQL ] How to grab database and table size.

1. Grab all database size.

SELECT table_schema, SUM(data_length + index_length)/1024/1024 AS total_mb, SUM(data_length)/1024/1024 AS data_mb, SUM(index_length)/1024/1024 AS index_mb, COUNT(*) AS tables, CURDATE() AS today FROM information_schema.tables GROUP BY table_schema ORDER BY 2 DESC;

2. Grab all table size.

SELECT table_schema, table_name, (data_length + index_length)/1024/1024 AS total_mb, (data_length)/1024/1024 AS data_mb, (index_length)/1024/1024 AS index_mb, CURDATE() AS today FROM information_schema.tables ORDER BY 3 DESC;


ERROR: Cannot add watch /Dir (28:No space left on device)

Today I got the lsyncd problem and found the following error in /var/log/lsyncd.
Wed Sep 21 03:48:24 2016: ERROR: Cannot add watch /Dir_name/file_name (28:No space left on device)
I googled the error message and found the solution. The max_user_watches reached its limit. I need to increase the value of max_user_watches. 

At first, checked the current value.
 [root@host ~]# cat /proc/sys/fs/inotify/max_user_watches

To increase the max_user_watches, I edited the /etc/sysctl.cnf.
 [root@host ~]# vi /etc/sysctl.confadded the folowing line.
 fs.inotify.max_user_watches = 500000

To take a effect, I did the following command.
[root@host ~]# sysctl -p

That's it!

Temporary solution
  echo 65536 >/proc/sys/fs/inotify/max_user_watches

 [root@host ~]# cat /proc/sys/fs/inotify/max_user_watches

Finally I got around the error. :) 


How to configure your s3 bucket public.

To set the all files in bucket public, add the bucket policy to your s3 bucket.
1. Go to https://awspolicygen.s3.amazonaws.com/policygen.html
2.  Set the following parameters.
          Select Type of Policy with "S3 bucket policy".
          Effect: Allow
          Principal:   *
          AWS Service: S3
          Actions:  GetObject
          Amazon Resource Name (ARN):    arn:aws:s3:::bucket-name/*

 3. Then, click 'Add Statement'
 4.  Click the 'Generate Policy' button. You'll get the following information like below.

  "Id": "Policy1462558474573",
  "Version": "2012-10-17",
  "Statement": [
      "Sid": "Stmt1462581569846",
      "Action": [
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::bucket-name/*",
      "Principal": "*"
5. Add above information in your s3 bucket policy.
That's it!


[Linux] find old files and delete, or move

Example: delete files older than one year
find /path/to/source  -mtime +365 -exec rm {} \;

Example: move files older than one year.
find /path/to/source -mtime +365 -exec mv {} /path/to/destination/ \;

Example: find files which file name starts ABC and older than 30 days and move.

find . -name "ABC*.csv" -mtime +30 -exec mv {} /path/to/destination/  \;




in reply to end of DATA command
<xxx_example@docomo.ne.jp>: host mfsmax.docomo.ne.jp[]
    said: 550 Unknown user xxx_example@docomo.ne.jp (in reply to end of DATA command)


<xxx_doesnt_exist@gmail.com>: host aspmx.l.google.com[] said: 550-5.1.1
    The email account that you tried to reach does not exist. Please try
    550-5.1.1 double-checking the recipient's email address for typos or
    550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1
    https://support.google.com/mail/answer/6596 tn4si27093780pbc.45 - gsmtp (in reply to RCPT TO command)

宛先不明 -> メールアドレスに間違いがないか確認する。



Change timezone from UTC with RDS instance

Here is how to change timezone setting in your RDS instance

1, connect your RDS instance as root.
[user@ec2 ~]$ mysql -u root -p -h xxxxxx.yyyyyy.zzzzzz.rds.amazonaws.com

2. Change the timezone setting.
mysql> DELIMITER |
mysql> CREATE PROCEDURE mysql.`set_PST`()
    -> IF NOT (POSITION('rdsadmin@' IN CURRENT_USER()) = 1) THEN
    ->    SET SESSION time_zone = 'America/Los_Angeles';
    -> END IF |
mysql> DELIMITER ;

3. Create parameter group
find init_connect parameter and input 'CALL set_PST'. Then save changes.

4. Apply new parameter group to your RDS instance.

5. Log in to your RDS instance. Then submit the following command.

mysql> GRANT EXECUTE ON PROCEDURE mysql.set_PST TO 'username'@'hostname';


サイボウズガルーン v4.0.1、パッケージ版URLからクラウド版URLのリダイレクト

I figured out how to redirect web pages on Cybozu Garoon package edition to their cloud edition.
work as root user.

cd /var/www/cgi-bin/cbgrn/
mv grn.cgi grn.cgi.org
vi grn.cgi
write redirect script like following. then save it.

$uri = $ENV{'REQUEST_URI'};
my @param = split('grn.cgi',$uri);
$rdrURL =  "Location: https://xxxxxx.cybozu.com/g/$param[1]\n\n";
print $rdrURL;


chmod 755 grn.cgi
chown apache:root grn.cgi

That's it! Test the redirection.


How to make send only sendmail server.

I have a EC2 instance in AWS. I configured my sendmail to send only for some purpose. Here is how. Let's say the your servers are in the subnet of and the IP address of the relay server is

1. Allow relay from your VPC in /etc/mail/access

[root@host /]# cd /etc/mail
[root@host /]# cp access access.org
[root@host /]# cp access.db access.db.org
[root@host /]# vi access
Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:                       RELAY
Connect:10.0                            RELAY  <-- Add
[root@host /]# makemap -v hash access.db < access

[root@host /]# cp submit.mc submit.mc.org
[root@host /]# cp submit.cf submit.cf.org
[root@host /]# vi submit.mc
define(`confDOMAIN_NAME', `yourdomain.com')dnl  <-- Add
FEATURE(`msp', `[]')dnl  <-- Change to your relay server.
[root@host /]# m4 submit.mc > submit.cf

[root@host /]# cp sendmail.mc sendmail.mc.org
[root@host /]# cp sendmail.cf sendmail.cf.org
[root@host /]# vi sendmail.mc
define(`SMART_HOST', `[]')dnl  <-- Add
define(`MAIL_HUB', `yourdomain.com.')dnl  <-- Add
define(`LOCAL_RELAY', `yourdomain.com.')dnl  <-- Add
[root@host /]# make sendmail.cf
[root@host /]# service sendmail restart

That's it!
Then test it from your web server.