Aller au contenu

Zabbix

MariaDB

Installation

Bash
apk add --update mariadb mariadb-client

Configuration

Bash
1
2
3
4
mysql_install_db --user=mysql --datadir=/var/lib/mysql
rc-service mariadb start
rc-update add mariadb
mysql_secure_installation

Base de données Zabbix

Bash
mysql -u root -p

⚠ CHANGER LE MOT DE PASSE CI-DESSOUS

Text Only
1
2
3
4
5
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY '';
CREATE DATABASE IF NOT EXISTS zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
FLUSH PRIVILEGES;
QUIT;

PHP

Installation

Bash
apk add --update php82 php82-fpm php82-gd php82-bcmath php82-ctype php82-xml php82-xmlreader php82-xmlwriter php82-session php82-sockets php82-mbstring php82-gettext php82-ldap php82-openssl php82-mysqli

Configuration

date.timezone

Bash
sed -i.bak 's/;date.timezone =/date.timezone = Europe\/Paris/g' /etc/php82/php.ini

memory_limit

Bash
sed -i.bak 's/memory_limit = 128M/memory_limit = 1024M /g' /etc/php82/php.ini

max_input_time

Bash
sed -i.bak 's/max_input_time = 60/max_input_time = 300 /g' /etc/php82/php.ini

max_execution_time

Bash
sed -i.bak 's/max_execution_time = 30/max_execution_time = 300 /g' /etc/php82/php.ini

post_max_size

Bash
sed -i.bak 's/post_max_size = 8M/post_max_size = 16M /g' /etc/php82/php.ini

PHP-fpm

Lancer le service

Bash
rc-service php-fpm82 start
rc-update add php-fpm82

Zabbix

Installation

Bash
apk add --update zabbix zabbix-mysql zabbix-webif zabbix-setup 

Configuration

Bash
nano /etc/zabbix/zabbix_server.conf

Changer :

Text Only
1
2
3
4
DBName=
DBUser=
DBPassword=
FpingLocation=/usr/sbin/fping

Fping

Bash
chmod u+s /usr/sbin/fping

Import de la base de données

Bash
1
2
3
cat /usr/share/zabbix/database/mysql/schema.sql | mysql -u zabbix -p zabbix
cat /usr/share/zabbix/database/mysql/images.sql | mysql -u zabbix -p zabbix
cat /usr/share/zabbix/database/mysql/data.sql | mysql -u zabbix -p zabbix

zabbix.conf.php

Bash
nano /usr/share/webapps/zabbix/conf/zabbix.conf.php

Renseigner :

  • $DB['DATABASE']
  • $DB['USER']
  • $DB['PASSWORD']
  • $ZBX_SERVER_NAME
Text Only
<?php
// Zabbix GUI configuration file.

$DB['TYPE']         = 'MYSQL';
$DB['SERVER']           = 'localhost';
$DB['PORT']         = '0';
$DB['DATABASE']         = '';
$DB['USER']         = '';
$DB['PASSWORD']         = '';

// Schema name. Used for PostgreSQL.
$DB['SCHEMA']           = '';

// Used for TLS connection.
$DB['ENCRYPTION']       = false;
$DB['KEY_FILE']         = '';
$DB['CERT_FILE']        = '';
$DB['CA_FILE']          = '';
$DB['VERIFY_HOST']      = false;
$DB['CIPHER_LIST']      = '';

// Vault configuration. Used if database credentials are stored in Vault secrets manager.
$DB['VAULT']            = '';
$DB['VAULT_URL']        = '';
$DB['VAULT_DB_PATH']        = '';
$DB['VAULT_TOKEN']      = '';
$DB['VAULT_CERT_FILE']      = '';
$DB['VAULT_KEY_FILE']       = '';
// Uncomment to bypass local caching of credentials.
// $DB['VAULT_CACHE']       = true;

// Use IEEE754 compatible value range for 64-bit Numeric (float) history values.
// This option is enabled by default for new Zabbix installations.
// For upgraded installations, please read database upgrade notes before enabling this option.
$DB['DOUBLE_IEEE754']       = true;

// Uncomment and set to desired values to override Zabbix hostname/IP and port.
// $ZBX_SERVER          = '';
// $ZBX_SERVER_PORT     = '';

$ZBX_SERVER_NAME        = '';

$IMAGE_FORMAT_DEFAULT   = IMAGE_FORMAT_PNG;

// Uncomment this block only if you are using Elasticsearch.
// Elasticsearch url (can be string if same url is used for all types).
//$HISTORY['url'] = [
//  'uint' => 'http://localhost:9200',
//  'text' => 'http://localhost:9200'
//];
// Value types stored in Elasticsearch.
//$HISTORY['types'] = ['uint', 'text'];

// Used for SAML authentication.
// Uncomment to override the default paths to SP private key, SP and IdP X.509 certificates, and to set extra settings.
//$SSO['SP_KEY']            = 'conf/certs/sp.key';
//$SSO['SP_CERT']           = 'conf/certs/sp.crt';
//$SSO['IDP_CERT']      = 'conf/certs/idp.crt';
//$SSO['SETTINGS']      = [];

Droits

Bash
chown -R nginx:nginx /usr/share/webapps/zabbix

Démarrer le service

Bash
rc-service zabbix-server start
rc-update add zabbix-server

Nginx

Installation

Bash
apk add --update nginx

Configuration

nginx.conf

Bash
mv /etc/nginx/nginx.conf /etc/nginx/[old]-nginx.conf
nano /etc/nginx/nginx.conf
Text Only
user nginx;
worker_processes auto;

# Configures default error logger.
error_log /var/log/nginx/error.log warn; # Log warn, error, crit, alert, emerg

events {
    # The maximum number of simultaneous connections that can be opened by a worker process.
    worker_connections 1024; # increase if you need more connections
}

http {
    # server_names_hash_bucket_size controls the maximum length
    # of a virtual host entry (ie the length of the domain name).
    server_names_hash_bucket_size   64; # controls the maximum length of a virtual host entry (ie domain name)
    server_tokens                   off; # hide who we are, don't show nginx version to clients
    sendfile                        off; # can cause issues

    # nginx will find this file in the config directory set at nginx build time
    # Includes mapping of file name extensions to MIME types of responses
    include mime.types;

    # fallback in case we can't determine a type
    default_type application/octet-stream;

    # buffering causes issues, disable it
    # increase buffer size. still useful even when buffering is off
    proxy_buffering off;
    proxy_buffer_size 4k;

    # allow the server to close the connection after a client stops responding. Frees up socket-associated memory.
    reset_timedout_connection on;

    # Specifies the main log format.
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
            '$status $body_bytes_sent "$http_referer" '
            '"$http_user_agent" "$http_x_forwarded_for"';

    # Sets the path, format, and configuration for a buffered log write.
    # Buffer log writes to speed up IO, or disable them altogether
    access_log /var/log/nginx/access.log main buffer=16k;
    #access_log off;

    # Include files with config snippets into the root context.
    include conf.d/*.conf;

    # Includes virtual hosts configs.
    include http.d/*.conf;
}

zabbix.conf

Bash
mv /etc/nginx/http.d/default.conf /etc/nginx/http.d/default.conf.old
nano /etc/nginx/http.d/zabbix.conf
Text Only
server {
    listen 80;
    listen [::]:80;

    server_name localhost;

    root /usr/share/webapps/zabbix;

    index index.php index.html index.htm;

    location ~ \.php$ {
        # the following line needs to be adapted, as it changes depending on OS distributions and PHP versions
        #fastcgi_pass unix:/run/php-fpm82/php-fpm.sock;
        fastcgi_pass 127.0.0.1:9000;

        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Démarrer le service

Bash
rc-service nginx start
rc-update add nginx

Mot de passe par défaut

Text Only
Admin
zabbix