Rédiger « OVH/VPC02/Munin » ici.

Installation d'un serveur Munin

Installation des paquets

apt-get install munin apache2

Ajout des serveurs a monitorer

Dans le fichier /etc/munin/munin-conf.d/local.conf :

[infra01.vpc02.auf]
        address infra01.vpc02.auf

[filer01.vpc02.auf]
        address filer01.vpc02.auf

[supervision01.vpc02.auf]
        address supervision01.vpc02.auf

[prod-drupal01-idneuf.vpc02.auf]
        address prod-drupal01-idneuf.vpc02.auf

[prod-drupal02-idneuf.vpc02.auf]
        address prod-drupal02-idneuf.vpc02.auf

[prod-drupal03-idneuf.vpc02.auf]
        address prod-drupal03-idneuf.vpc02.auf

[prod-ori-oai01-idneuf.vpc02.auf]
        address prod-ori-oai01-idneuf.vpc02.auf

[prod-proxy01.vpc02.auf]
        address prod-proxy01.vpc02.auf

[prod-proxy02.vpc02.auf]
        address prod-proxy02.vpc02.auf

[prod-db01-idneuf.vpc02.auf]
        address prod-db01-idneuf.vpc02.auf

[prod-db02-idneuf.vpc02.auf]
        address prod-db02-idneuf.vpc02.auf

[prod-db03-idneuf.vpc02.auf]
        address prod-db03-idneuf.vpc02.auf

[dev-proxy01.vpc02.auf]
        address dev-proxy01.vpc02.auf

[dev-drupal01-idneuf.vpc02.auf]
        address dev-drupal01-idneuf.vpc02.auf

[dev-ori-oai01-idneuf.vpc02.auf]
        address dev-ori-oai01-idneuf.vpc02.auf

Configuration des plugins

Pour relancer l' installation automatique des plugins :

munin-node-configure --shell

Plugin Apache

Source : How to Monitor Apache Web Server Load and Page Statistics

=== Configuration du module ==

Dans le fichier /etc/apache2/mods-enabled/status.conf, décommenter la ligne "Require ip @ip" par les adresses autorisées:

<IfModule mod_status.c>
        # Allow server status reports generated by mod_status,
        # with the URL of http://servername/server-status
        # Uncomment and change the "192.0.2.0/24" to allow access from other hosts.

        <Location /server-status>
                SetHandler server-status
                Require local
                Require ip 10.36.0.0/16
        </Location>

        # Keep track of extended status information for each request
        ExtendedStatus On

        # Determine if mod_status displays the first 63 characters of a request or
        # the last 63, assuming the request itself is greater than 63 chars.
        # Default: Off
        #SeeRequestTail On


        <IfModule mod_proxy.c>
                # Show Proxy LoadBalancer status in mod_status
                ProxyStatus On
        </IfModule>


</IfModule>

Cas de Drupal

Pour ne pas rentrer en conflit avec le site Drupal, il faut créer un autre virtual host.

Fichier /etc/apache2/sites-available/status.conf :

<VirtualHost *:80>


        Alias /status /var/www/status
        
        <Directory /var/www/status>
                Require all granted
                Options FollowSymLinks SymLinksIfOwnerMatch
                Options None
        </Directory>

        <Location /server-status>
                SetHandler server-status
                Order deny,allow
                Deny from all
                Allow from all
        </Location>

</VirtualHost>

On créer le répertoire /var/www/status et on donne les droits :

mkdir /var/www/status
chown www-data-www-data /var/www/status

On active ensuite le tout :

a2ensite status
systemctl reload apache2

Plugins NginX

Ajouter au virtual host

       location /nginx_status {
               stub_status on;
               access_log   off;
               allow 127.0.0.1;
               deny all;
       }

Puis ajouter dans /etc/munin/plugin-conf.d/munin-node

[nginx*]
env.url http://localhost/nginx_status

Plugins MySQL

Installer les paquets

apt-get install libcache-cache-perl

Activer les plugins

root@prod-db01-idneuf:~# munin-node-configure --shell
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_bin_relay_log'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_commands'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_connections'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_files_tables'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_innodb_bpool'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_innodb_bpool_act'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_innodb_insert_buf'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_innodb_io'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_innodb_io_pend'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_innodb_log'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_innodb_rows'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_innodb_semaphores'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_innodb_tnx'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_myisam_indexes'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_network_traffic'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_qcache'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_qcache_mem'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_replication'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_select_types'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_slow'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_sorts'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_table_locks'
ln -s '/usr/share/munin/plugins/mysql_' '/etc/munin/plugins/mysql_tmp_tables'

Puis exécuter les commandes générées.

Pour le plugin mysql_replication, rajouter la configuration suivante dans etc/munin/plugin-conf.d/munin-node :

[mysql_replication]
env.slave_io_running_warning 0.5
env.slave_sql_running_warning 0.5
env.seconds_behind_master_warning 300
env.seconds_behind_master_critical 600

Source : mysql_ - Munin plugin to display misc MySQL server status

Plugins Tomcat6

Installer les paquets

apt-get install libxml-simple-perl

Activer les plugins pour ORI-OAI

ln -s /usr/share/munin/plugins/tomcat_access /etc/munin/plugins/tomcat_repository_access
ln -s /usr/share/munin/plugins/tomcat_jvm /etc/munin/plugins/tomcat_repository_jvm
ln -s /usr/share/munin/plugins/tomcat_threads /etc/munin/plugins/tomcat_repository_threads
ln -s /usr/share/munin/plugins/tomcat_volume /etc/munin/plugins/tomcat_repository_volume


ln -s /usr/share/munin/plugins/tomcat_access /etc/munin/plugins/tomcat_harvester_access
ln -s /usr/share/munin/plugins/tomcat_jvm /etc/munin/plugins/tomcat_harvester_jvm
ln -s /usr/share/munin/plugins/tomcat_threads /etc/munin/plugins/tomcat_harvester_threads
ln -s /usr/share/munin/plugins/tomcat_volume /etc/munin/plugins/tomcat_harvester_volume

ln -s /usr/share/munin/plugins/tomcat_access /etc/munin/plugins/tomcat_indexing_access
ln -s /usr/share/munin/plugins/tomcat_jvm /etc/munin/plugins/tomcat_indexing_jvm
ln -s /usr/share/munin/plugins/tomcat_threads /etc/munin/plugins/tomcat_indexing_threads
ln -s /usr/share/munin/plugins/tomcat_volume /etc/munin/plugins/tomcat_indexing_volume

ln -s /usr/share/munin/plugins/tomcat_access /etc/munin/plugins/tomcat_vocabulary_access
ln -s /usr/share/munin/plugins/tomcat_jvm /etc/munin/plugins/tomcat_vocabulary_jvm
ln -s /usr/share/munin/plugins/tomcat_threads /etc/munin/plugins/tomcat_vocabulary_threads
ln -s /usr/share/munin/plugins/tomcat_volume /etc/munin/plugins/tomcat_vocabulary_volume


ln -s /usr/share/munin/plugins/tomcat_access /etc/munin/plugins/tomcat_search_access
ln -s /usr/share/munin/plugins/tomcat_jvm /etc/munin/plugins/tomcat_search_jvm
ln -s /usr/share/munin/plugins/tomcat_threads /etc/munin/plugins/tomcat_search_threads
ln -s /usr/share/munin/plugins/tomcat_volume /etc/munin/plugins/tomcat_search_volume

Il faut ensuite rajouter la configuration suivante dans etc/munin/plugin-conf.d/munin-node :

[tomcat_repository*]
env.ports 8180
env.user admin
env.password xxxxxxx

[tomcat_harvester*]
env.ports 8181
env.user admin
env.password xxxxxxx

[tomcat_indexing*]
env.ports 8182
env.user admin
env.password xxxxxxx

[tomcat_vocabulary*]
env.ports 8183
env.user admin
env.password xxxxxxx

[tomcat_search*]
env.ports 8184
env.user admin
env.password xxxxxxx

Optimisation de RRD

TMPFS

Pour mettre le repertoire /var/cache/munin/www en tmpfs, ajouter dans /etc/fstab :

tmpfs /var/cache/munin/www tmpfs rw,mode=775,uid=munin,gid=munin,size=300M 0 0

Rrdcached

Installer rrdcached

Source : Scaling the munin master with rrdcached

apt-get install rrdcached

Configuration de rrdcached pour Munin

Créer un répertoire pour le journal

/var/lib/munin/rrdcached-journal

chown munin:munin /var/lib/munin/rrdcached-journal

Script de démarrage

Dans /etc/systemd/system/, créer le fichier rrdcached-munin.service :

[Unit]
Description=Munin rrdcached

[Service]
Restart=always
User=munin
PermissionsStartOnly=yes
ExecStartPre=/usr/bin/install -d -o munin -g munin -m 0755 \
  /var/lib/munin/rrdcached-journal /run/munin
ExecStart=/usr/bin/rrdcached \
  -g -B -b /var/lib/munin/ \
  -p /run/munin/munin-rrdcached.pid \
  -F -j /var/lib/munin/rrdcached-journal/ \
  -m 0660 -l unix:/run/munin/rrdcached.sock \
  -w 1800 -z 1800 -f 3600
ExecStartPost=/bin/sleep 1 ; /bin/setfacl -m u:www-data:rw /run/munin/rrdcached.sock
[Install]
WantedBy=multi-user.target

Puis activer le script :

systemctl enable rrdcached-munin.service

Désactiver ensuite le lancement par défaut créer lors de l'installation du paquet : /etc/default/rrdcached

# 0: start rrdcached on boot, 1: do not start rrdcached on boot
# default: 0
DISABLE=1

Utilisation avec Munin

Dans le fichier /etc/munin/munin.conf

rrdcached_socket /run/munin/rrdcached.sock

Installation de Munin via Ansible

---
- name: munin-node
  hosts:
    - ovh-vpc02-prod
  become: True

  vars: 
    munin_server: 10.242.0.3

  tasks:

  - name: installation Munin Node
    become: true
    apt: pkg="{{ item }}" state=latest
    with_items:
      - munin-node
      - munin-libvirt-plugins

  - name: reconfiguration de munin-node
    tags: configure
    shell: "munin-node-configure --shell | sh"

  - name: configuration Munin Node
    become: true
    lineinfile: dest=/etc/munin/munin-node.conf insertafter="^allow " regexp="^allow \^{{ munin_server | regex_escape }}\$$" line="allow ^{{ munin_server | regex_escape }}$"
    tags: munin-node

  - name: redemarrage munin-node
    service: name=munin-node state=restarted
co

OVH/VPC02/Munin (dernière édition le 2016-10-06 21:07:51 par LionelValentin)