readd directory
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
echo "====Informations générales===="
|
||||
echo "Nombre de CPU: " $(grep processor /proc/cpuinfo | wc -l)
|
||||
echo 'Mémoire RAM en Go: ' $(echo "scale=2; $(grep MemTotal /proc/meminfo |awk '{print $2}') / 1024^2" | bc)
|
||||
echo "OS: " $(cat /etc/redhat-release)
|
||||
echo "Noyau: " $(uname -r)
|
||||
echo "Zimbra: " $(sudo -u zimbra /opt/zimbra/bin/zmcontrol -v)
|
||||
echo ""
|
||||
echo "====Arborescence des périphérique de stockage===="
|
||||
lsblk -fe7
|
||||
echo ""
|
||||
echo "====Utilisation du système de fichier===="
|
||||
df -H
|
||||
echo ""
|
||||
echo "====Information concernant les cartes réseau===="
|
||||
ip a
|
||||
echo ""
|
||||
echo "====Liste des zimlets installées sur ce serveur===="
|
||||
awk '/Installed Zimlets in LDAP:/{exit}1' < <(sudo -u zimbra /opt/zimbra/bin/zmzimletctl listzimlets)
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
#- name: set script
|
||||
# ansible.builtin.copy:
|
||||
# src: get_info.sh
|
||||
# dest: /root/tmp.sh
|
||||
# mode: 0700
|
||||
|
||||
- name: delete script
|
||||
ansible.builtin.file:
|
||||
path: /root/tmp.sh
|
||||
state: absent
|
||||
Binary file not shown.
@@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
# Script qui met en forme des données d'un serveur zimbra au format influxdb
|
||||
# Ce script est éxecuté une fois par jour
|
||||
|
||||
OUTPUT_LINE="zimbra_one_per_day "
|
||||
|
||||
##############################################################
|
||||
## Info de Version
|
||||
##############################################################
|
||||
version_install_full=$(dpkg -s zimbra-patch | egrep '^Version:' | sed -e 's/Version: //')
|
||||
version_install_array=(${version_install_full//./ })
|
||||
release=${version_install_array[0]}.${version_install_array[1]}.${version_install_array[2]}
|
||||
patch=${version_install_array[4]}
|
||||
edition=$([ -e "/opt/zimbra/bin/zmbackupquery" ] && echo NETWORK || echo FOSS)
|
||||
|
||||
OUTPUT_LINE+="release=\"$release\",edition=\"$edition\",patch=\"$patch\","
|
||||
|
||||
##############################################################
|
||||
## Récup les 5 plus gros compte
|
||||
##############################################################
|
||||
top5_biggest_account=$(echo "select comment,size_checkpoint from mailbox order by size_checkpoint desc limit 5;" | /opt/zimbra/bin/mysql zimbra)
|
||||
|
||||
OUTPUT_LINE+="top5_biggest_account=\"$top5_biggest_account\","
|
||||
|
||||
##############################################################
|
||||
## Le nombre de serveurs
|
||||
##############################################################
|
||||
zimbra_number_of_servers=$(sh -c "/opt/zimbra/bin/zmprov gas |wc -l")
|
||||
|
||||
OUTPUT_LINE+="zimbra_number_of_servers=\"$zimbra_number_of_servers\","
|
||||
|
||||
##############################################################
|
||||
## Le nombre de domaines
|
||||
##############################################################
|
||||
zimbra_number_of_domain=$(sh -c "/opt/zimbra/bin/zmprov gad |wc -l")
|
||||
|
||||
OUTPUT_LINE+="zimbra_number_of_domain=\"$zimbra_number_of_domain\","
|
||||
|
||||
##############################################################
|
||||
## Total de compte admin
|
||||
##############################################################
|
||||
nb_admin_total=$(sh -c "/opt/zimbra/bin/zmprov gaaa |wc -l")
|
||||
|
||||
OUTPUT_LINE+="zimbra_number_of_administrator=\"$nb_admin_total\","
|
||||
|
||||
##############################################################
|
||||
## Total de liste de diffusion
|
||||
##############################################################
|
||||
zimbra_number_of_list=$(sh -c "/opt/zimbra/bin/zmprov gadl |wc -l")
|
||||
|
||||
OUTPUT_LINE+="zimbra_number_of_list=\"$zimbra_number_of_list\","
|
||||
|
||||
##############################################################
|
||||
## Nombre de compte supprimé
|
||||
##############################################################
|
||||
zimbra_account_closed=$(sh -c "/opt/zimbra/bin/zmprov searchAccounts zimbraAccountStatus=*closed* | wc -l")
|
||||
|
||||
OUTPUT_LINE+="zimbra_account_closed=\"$zimbra_account_closed\","
|
||||
|
||||
##############################################################
|
||||
## Info certificat ssl
|
||||
##############################################################
|
||||
zimbra_crt_info=$(sh -c "sudo -u telegraf sudo -u zimbra /opt/zimbra/bin/zmcertmgr viewdeployedcrt")
|
||||
|
||||
OUTPUT_LINE+="zimbra_crt_info=\"$zimbra_crt_info\""
|
||||
|
||||
|
||||
##############################################################
|
||||
## Fin du script
|
||||
##############################################################
|
||||
echo "$OUTPUT_LINE"
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
# Script qui met en forme des données d'un serveur zimbra au format influxdb
|
||||
# Ce script est éxecuté une fois par heure
|
||||
|
||||
OUTPUT_LINE="zimbra_one_per_hour "
|
||||
|
||||
##############################################################
|
||||
## Nombre total de compte
|
||||
##############################################################
|
||||
nb_total=$(echo 'select count(id) from mailbox;' | /opt/zimbra/bin/mysql zimbra | sed -n 2p)
|
||||
|
||||
OUTPUT_LINE+="zimbra_number_of_account=\"$nb_total\","
|
||||
|
||||
##############################################################
|
||||
## Quota des comptes sur la license zxsuite
|
||||
##############################################################
|
||||
ZXS=/opt/zimbra/bin/zxsuite
|
||||
if [ -f "$ZXS" ]; then
|
||||
zxsuite_licensed_users=$(sudo -u zimbra $ZXS core getLicenseInfo | grep licensedUsers | awk '{print $2}')
|
||||
else
|
||||
zxsuite_licensed_users="No Zxsuite"
|
||||
fi
|
||||
|
||||
OUTPUT_LINE+="zxsuite_licensed_users=\"$zxsuite_licensed_users\","
|
||||
|
||||
##############################################################
|
||||
## Quota des comptes mobile sur la license zxsuite
|
||||
##############################################################
|
||||
ZXS=/opt/zimbra/bin/zxsuite
|
||||
if [ -f "$ZXS" ]; then
|
||||
zxsuite_licensed_mobile_users=$(sudo -u zimbra $ZXS core getLicenseInfo | grep ZxMobile -A 1 | tail -n1 | awk '{print $2}')
|
||||
else
|
||||
zxsuite_licensed_mobile_users="No Zxsuite"
|
||||
fi
|
||||
|
||||
OUTPUT_LINE+="zxsuite_licensed_mobile_users=\"$zxsuite_licensed_mobile_users\","
|
||||
|
||||
|
||||
##############################################################
|
||||
## Date d'expiration de la license zxsuite
|
||||
##############################################################
|
||||
ZXS=/opt/zimbra/bin/zxsuite
|
||||
if [ -f "$ZXS" ]; then
|
||||
zxsuite_expirate_date=$(sudo -u zimbra $ZXS core getLicenseInfo | grep dateEnd | awk '{print $2,$3,$4}')
|
||||
else
|
||||
zxsuite_expirate_date="No Zxsuite"
|
||||
fi
|
||||
|
||||
OUTPUT_LINE+="zxsuite_expirate_date=\"$zxsuite_expirate_date\","
|
||||
|
||||
##############################################################
|
||||
## Date du dernier backup zxsuite
|
||||
##############################################################
|
||||
ZXS=/opt/zimbra/bin/zxsuite
|
||||
if [ -f "$ZXS" ]; then
|
||||
zxsuite_backup_lastScan=$(sudo -u zimbra $ZXS backup getBackupInfo |grep lastScan | awk '{print $2,$3,$4}')
|
||||
else
|
||||
zxsuite_backup_lastScan="No Zxsuite"
|
||||
fi
|
||||
|
||||
OUTPUT_LINE+="zxsuite_backup_lastScan=\"$zxsuite_backup_lastScan\""
|
||||
|
||||
|
||||
##############################################################
|
||||
## Fin du script
|
||||
##############################################################
|
||||
echo "$OUTPUT_LINE"
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Reload Telegraf
|
||||
ansible.builtin.systemd:
|
||||
name: telegraf
|
||||
state: reloaded
|
||||
@@ -0,0 +1,92 @@
|
||||
---
|
||||
- name: Telegraf repository key
|
||||
ansible.builtin.apt_key:
|
||||
url: https://repos.influxdata.com/influxdata-archive_compat.key
|
||||
state: present
|
||||
|
||||
- name: Telegraf repository
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb https://repos.influxdata.com/ubuntu {{ ansible_distribution_release }} stable"
|
||||
state: present
|
||||
filename: telegraf
|
||||
register: repo_telegraf
|
||||
|
||||
- name: Update cache
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
when: repo_telegraf.changed
|
||||
|
||||
- name: Telegraf packages
|
||||
ansible.builtin.apt:
|
||||
name: telegraf
|
||||
state: present
|
||||
|
||||
- name: Cherche si postfix est présent
|
||||
ansible.builtin.stat:
|
||||
path: /opt/zimbra/common/sbin/mailq
|
||||
register: postfix
|
||||
|
||||
- name: Ajoute les groupes nécessaire à l'utilisateur telegraf
|
||||
ansible.builtin.user:
|
||||
name: telegraf
|
||||
groups: zimbra,sudo,postfix,postdrop
|
||||
when: postfix.stat.exists
|
||||
|
||||
- name: Ajoute les groupes nécessaire à l'utilisateur telegraf
|
||||
ansible.builtin.user:
|
||||
name: telegraf
|
||||
groups: zimbra,sudo
|
||||
when: not postfix.stat.exists
|
||||
|
||||
- name: Donne le droit a telegraf d'éxecuter les commandes zimbra sans pass
|
||||
community.general.sudoers:
|
||||
name: zxsuite-telegraf
|
||||
user: telegraf
|
||||
runas: zimbra
|
||||
commands:
|
||||
- /opt/zimbra/bin/*
|
||||
|
||||
- name: Récupération du secret de LDAP
|
||||
ansible.builtin.shell: |
|
||||
/opt/zimbra/bin/zmlocalconfig -s zimbra_ldap_password | awk '{ print $3}'
|
||||
register: zimbra_ldap_password
|
||||
|
||||
- name: Set fact
|
||||
ansible.builtin.set_fact:
|
||||
zimbra_ldap_password: "{{ zimbra_ldap_password.stdout }}"
|
||||
|
||||
- name: Installation des scripts de récupération des données zimbra
|
||||
ansible.builtin.copy:
|
||||
src: files/{{ item }}
|
||||
dest: /etc/telegraf/scripts/
|
||||
mode: '0755'
|
||||
owner: root
|
||||
group: root
|
||||
loop:
|
||||
# - zimbra_one_per_day.sh
|
||||
# - zimbra_one_per_hour.sh
|
||||
- recup_info_zimbra
|
||||
notify: Reload Telegraf
|
||||
tags:
|
||||
- shscript
|
||||
|
||||
- name: Installation de la configuration générale de telegraf
|
||||
ansible.builtin.template:
|
||||
src: templates/telegraf.conf.j2
|
||||
dest: /etc/telegraf/telegraf.conf
|
||||
mode: '0755'
|
||||
owner: root
|
||||
group: root
|
||||
notify: Reload Telegraf
|
||||
|
||||
- name: Installation de la configuration spécific zimbra pour telegraf
|
||||
ansible.builtin.template:
|
||||
src: templates/{{ item }}.j2
|
||||
dest: /etc/telegraf/telegraf.d/{{ item }}
|
||||
mode: '0644'
|
||||
owner: root
|
||||
group: root
|
||||
loop:
|
||||
- zimbra_general.conf
|
||||
- zimbra_specific.conf
|
||||
notify: Reload Telegraf
|
||||
@@ -0,0 +1,16 @@
|
||||
# /!\ NE PAS MODIFIER /!\ DON'T TOUCH THIS FILE /!\
|
||||
# Fichier géré par zextras déposé via ansible
|
||||
|
||||
# Global Agent Configuration
|
||||
[agent]
|
||||
hostname = "{{ ansible_fqdn }}"
|
||||
flush_interval = "15s"
|
||||
interval = "15s"
|
||||
collection_jitter = "1m"
|
||||
|
||||
# Output Plugin InfluxDB
|
||||
[[outputs.influxdb]]
|
||||
database = "telegraf"
|
||||
urls = [ "https://fluxsup.zextras.fr" ]
|
||||
username = "zextras"
|
||||
password = "syj4HGGLAgON4XfjbP4u"
|
||||
@@ -0,0 +1,43 @@
|
||||
# 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", "squashfs"]
|
||||
|
||||
[[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]]
|
||||
@@ -0,0 +1,47 @@
|
||||
# OpenLDAP cn=Monitor plugin
|
||||
[[inputs.openldap]]
|
||||
host = "{{ ansible_fqdn }}"
|
||||
port = 389
|
||||
insecure_skip_verify = true
|
||||
bind_dn = "uid=zimbra,cn=admins,cn=zimbra"
|
||||
bind_password = "{{ zimbra_ldap_password }}"
|
||||
reverse_metric_names = true
|
||||
|
||||
## Postfix plugin
|
||||
#[[inputs.postfix]]
|
||||
# queue_directory = "/opt/zimbra/data/postfix/spool"
|
||||
# interval = "1s"
|
||||
|
||||
## Zimbra metric hourly
|
||||
#[[inputs.exec]]
|
||||
# commands = ["/etc/telegraf/scripts/zimbra_one_per_hour.sh"]
|
||||
# data_format = "influx"
|
||||
# interval = "1h"
|
||||
# timeout = "15s"
|
||||
#
|
||||
## Zimbra metric daily
|
||||
#[[inputs.exec]]
|
||||
# commands = ["/etc/telegraf/scripts/zimbra_one_per_day.sh"]
|
||||
# data_format = "influx"
|
||||
# interval = "24h"
|
||||
# timeout = "90s"
|
||||
|
||||
[[inputs.exec]]
|
||||
commands = ["/etc/telegraf/scripts/recup_info_zimbra -daily"]
|
||||
interval = "24h"
|
||||
timeout = "30s"
|
||||
data_format = "json_v2"
|
||||
[[inputs.exec.json_v2]]
|
||||
measurement_name = "flux_zimbra"
|
||||
[[inputs.exec.json_v2.object]]
|
||||
path = "flux_zimbra"
|
||||
|
||||
[[inputs.exec]]
|
||||
commands = ["/etc/telegraf/scripts/recup_info_zimbra -hourly"]
|
||||
interval = "1h"
|
||||
timeout = "30s"
|
||||
data_format = "json_v2"
|
||||
[[inputs.exec.json_v2]]
|
||||
measurement_name = "flux_zimbra"
|
||||
[[inputs.exec.json_v2.object]]
|
||||
path = "flux_zimbra"
|
||||
Reference in New Issue
Block a user