Monitoring

--------

tail -f  /opt/zimbra/log/mailbox.log

/opt/zimbra/log/mailbox.log

Track messages sent and received by a user

/opt/zimbra/libexec/zmmsgtrace' shows the logs for all the users.

Using '-s' shows all the emails sent by 'user@example.com' :

/opt/zimbra/libexec/zmmsgtrace -s user@example.com

'-r' sorts emails by the receiver. So for the emails sent to 'gmail.com':

/opt/zimbra/libexec/zmmsgtrace -r '@gmail.com' 

If you have multiple log files, using '/var/log/zimbra*' will search all of the log files in that directory:

/opt/zimbra/libexec/zmmsgtrace -r '@gmail.com' /var/log/zimbra*

Understanding zimbra.log And Postfix Log Event

$ egrep '(reject|warning|error|fatal|panic):' /var/log/zimbra.log

Script to collect information from Zimbra Collaboration

In order to collect information from the Zimbra Collaboration mail queues, as well as to calculate messages sent, etc., I have used the pflogsumm itself, and with it I have modified the output to be in InfluxDB format.

You can download the script from here and locate it in the following route, I have called it zimbra_pflogsumm. pl and make it executable:

/opt/zimbra/common/bin/zimbra_pflogsumm.pl chmod +rwxr+xr+x /opt/zimbra/common/bin/zimbra_pflogsumm.pl

You can prove that it returns content to you, and that the telegraph user can run it by launching:

sudo -u telegraf /opt/zimbra/common/bin/zimbra_pflogsumm.pl /var/log/zimbra.log

If everything went well, you can see a result similar to this one, but with your numbers of course:

zimbra-stats received=76 zimbra-stats delivered=327 zimbra-stats forwarded=0 zimbra-stats deferred=1 zimbra-stats bounced=5 zimbra-stats rejected=6 zimbra-stats reject_warnings=0 zimbra-stats held=0 zimbra-stats discarded=0 zimbra-stats bytes_received=11889 zimbra-stats bytes_delivered=32229 zimbra-stats senders=7 zimbra-stats sending_hosts_domains=5 zimbra-stats recipients=73 zimbra-stats recipient_hosts_domains=6

Telegraf configuration in Zimbra Collaboration agents

In the servers of Zimbra Collaboration we will have to install Telegraf, you have all the steps in the following Blog post, once we have Telegraf installed, we will have to configure our additional scripts at the end of the file, this way my part at the end shows the scripts of Zimbra and the others to monitor the state of the server:

# Read metrics about cpu usage [[inputs.cpu]]   ## Whether to report per-cpu stats or not   percpu = true   ## Whether to report total system cpu stats or not   totalcpu = true   ## Comment this line if you want the raw CPU time metrics   fielddrop = ["time_*"]  # Read metrics about disk usage by mount point [[inputs.disk]]   ignore_fs = ["tmpfs", "devtmpfs"]  # Read metrics about disk IO by device [[inputs.diskio]]  # Get kernel statistics from /proc/stat [[inputs.kernel]]  # Read metrics about memory usage [[inputs.mem]]  # Get the number of processes and group them by status [[inputs.processes]]  # Read metrics about swap memory usage [[inputs.swap]]  # Read metrics about system load & uptime [[inputs.system]]  [[inputs.procstat]]   exe = "memcached"   prefix = "memcached"  [[inputs.procstat]]   exe = "java"   prefix = "java"  [[inputs.procstat]]   exe = "mysqld"   prefix = "mysqld"  [[inputs.procstat]]   exe = "slapd"   prefix = "slapd"  [[inputs.procstat]]   exe = "nginx"   prefix = "nginx"  [[inputs.net]]  [[inputs.exec]]   commands = ["/opt/zimbra/common/bin/zimbra_pflogsumm.pl -d today /var/log/zimbra.log"]   name_override = "zimbra_stats"   data_format = "influx"  [[inputs.exec]]   commands = ["sed 's/........................//' /opt/zimbra/jetty/webapps/zimbra/downloads/.git/HEAD"]   name_override = "zimbra_stats"   data_format = "value"   data_type = "string"

Once this is done, we'll be able to reboot the service:

service telegraf restart

How to monitor a Zimbra Collaboration Environment using pflogsumm, Telegraf, InfluxDB and Grafana

----------