Zimbra:telegraf+Grafana

源頭:https://github.com/jorgedlcruz/zimbra-grafana

建立 checkzimbraversion.sh:

nano /opt/zimbra/common/bin/checkzimbraversion.sh
#!/bin/bash
if [ -f /etc/redhat-release ]; then
  rpm -q --queryformat "%{version}" zimbra-core | awk -F. '{print $1"."$2"."$3 }' | awk -F_ '{print $1" "$2 }'
fi

if [ -f /etc/lsb-release ]; then
  dpkg -s zimbra-core | awk -F"[ ',]+" '/Version:/{print $2}' | awk -F. '{print $1"."$2"."$3" "$4}'
fi

給予權限:

chmod +x /opt/zimbra/common/bin/checkzimbraversion.sh

安裝 telegraf:

wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/lsb-release
echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
apt update
apt-get install telegraf

新增檔案:

nano /etc/telegraf/telegraf.d/zimbra.conf
# Read metrics about cpu usage
[[inputs.cpu]]
  percpu = true
  totalcpu = true
  fielddrop = ["time_*"]

# Read metrics about disk usage by mount point
[[inputs.disk]]
  ignore_fs = ["tmpfs", "devtmpfs"]

[[inputs.diskio]]

[[inputs.kernel]]

[[inputs.mem]]

[[inputs.processes]]

[[inputs.swap]]

[[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/checkzimbraversion.sh"]
  name_override = "zimbra_stats"
  data_format = "value"
  data_type = "string"

# # OpenLDAP cn=Monitor plugin
# # As zimbra user run the next to obatin the password zmlocalconfig -s zimbra_ldap_password ldap_master_url
 [[inputs.openldap]]
   host = "YOURZIMBRASERVERHOSTNAME"
   port = 389
   insecure_skip_verify = true
   bind_dn = "uid=zimbra,cn=admins,cn=zimbra"
   bind_password = "YOURZIMBRALDAPPASSWORD"
   reverse_metric_names = true

 [[inputs.postfix]]
    queue_directory = "/opt/zimbra/data/postfix/spool"
    interval = "1s"

編輯telegraf:

nano /etc/telegraf/telegraf.conf

修改以下兩處:

urls = ["http://10.0.1.100:8086"]
  database = "zimbra"

重啟服務:

service telegraf restart

進入到 influxdb LXC/VM:

influx
create database zimbra
show series
exit

Grafana Dashboard:

https://github.com/jorgedlcruz/zimbra-grafana/blob/master/grafana-zimbra-collaboration-dashboard.json
阅读剩余
THE END