From b463f1fbb5b05daa65fd3c320031b4aebf24692d Mon Sep 17 00:00:00 2001 From: Zhang Huangbin Date: Wed, 7 Feb 2018 23:55:31 +0800 Subject: [PATCH] New: integration.netdata.freebsd.html. --- .../0-integration.netdata.freebsd.md | 278 +++++++++++++++ .../0-integration.netdata.linux.md | 81 ++++- html/integration.netdata.freebsd.html | 318 ++++++++++++++++++ html/integration.netdata.linux.html | 92 +++-- 4 files changed, 737 insertions(+), 32 deletions(-) create mode 100644 en_US/integrations/0-integration.netdata.freebsd.md create mode 100644 html/integration.netdata.freebsd.html diff --git a/en_US/integrations/0-integration.netdata.freebsd.md b/en_US/integrations/0-integration.netdata.freebsd.md new file mode 100644 index 00000000..3cc79230 --- /dev/null +++ b/en_US/integrations/0-integration.netdata.freebsd.md @@ -0,0 +1,278 @@ +# Integrate netdata monitor (on FreeBSD server) + +[TOC] + +!!! attention + + * This tutorial is tested on FreeBSD 11.x. If you need to run netdata on + CentOS, Debian, Ubuntu, please check this tutorial instead: + [Integrate netdata on Linux](./integration.netdata.linux.html). + * netdata is an optional component since iRedMail-0.9.8. + +## What's netdata + +netdata () is a "Simple. Effective. Awesome!" monitor +which can monitor almost everyting on your Linux/FreeBSD system. You can visit +its website to check online demo. + +We will show you how to install and configure netdata on iRedMail server +(Linux) to monitor mail service related softwares. + +## Install netdata + +``` +cd /usr/ports/net-mgmt/netdata +make install clean +``` + +## Configure netdata + +Main config file of netdata is `/usr/local/etc/netdata/netdata.conf`, it +contains many parameters with detailed comments. Here's the +[config file](https://bitbucket.org/zhb/iredmail/src/default/iRedMail/samples/netdata/netdata.conf) +used by iRedMail: + +* It binds to address `127.0.0.1` and port `19999` by default. Since it doesn't + have ACL control, we will run netdata behind Nginx to get ACL control done in + Nginx. + +``` +[registry] + enabled = no + +[global] + bind to = 127.0.0.1 + run as user = netdata + default port = 19999 + update every = 3 + +[plugin:proc] + # Disable IPVS check since iRedMail doesn't use ipvs by default + /proc/net/ip_vs/stats = no + + # inbound packets dropped + /proc/net/dev = no +``` + +netdata ships a lot modular config files to gather information of softwares +running on the server, they have very good default settings and most config +files don't need your attention at all, including: + +* System resources (CPU, RAM, disk I/O, etc) +* Nginx log file monitoring +* Fail2ban jails +* Memcached +* ... + +But some applications do require extra settings, we will cover them below. + +### Monitor Nginx and php-fpm + +We need to enable `stub_status` in Nginx to get detailed server info, also +update php-fpm config file to enable similar feature. + +* Create Nginx config snippet `/usr/local/etc/nginx/templates/stub_status.tmpl` with + content below: + +``` +location = /stub_status { + stub_status on; + access_log off; + allow 127.0.0.1; + deny all; +} + +location = /status { + include fastcgi_params; + fastcgi_pass php_workers; + fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; + access_log off; + allow 127.0.0.1; + deny all; +} +``` + +* Update default virtual host config file `/usr/local/etc/nginx/sites-enabled/00-default.conf`, + include new snippet config file `stub_status.tmpl` after the + `redirect_to_https.tmpl` line like below: + +``` +server { + ... + include /usr/local/etc/nginx/templates/redirect_to_https.tmpl; + include /usr/local/etc/nginx/templates/stub_status.tmpl; # <- add this line + ... +} +``` + +* Update php-fpm pool config file `/usr/local/etc/php-fpm.d/www.conf`, enable + parameter `pm.status_path` like below: + +``` +pm.status_path = /status +``` + +* Restart both php-fpm and Nginx service. + +### Monitor Dovecot + +We need to enable statistics module in Dovecot. + +* Please open Dovecot config file `/usr/local/etc/dovecot/dovecot.conf`, + append plugin `stats` in global parameter `mail_plugins`, and `imap_stats` + for imap protocol: + +``` +mail_plugins = ... stats + +protocol imap { + mail_plugins = ... imap_stats + ... +} +``` + +* Append settings below in Dovecot config file: + +``` +plugin { + # how often to session statistics (must be set) + stats_refresh = 30 secs + # track per-IMAP command statistics (optional) + stats_track_cmds = yes +} + +service stats { + fifo_listener stats-mail { + user = vmail + mode = 0644 + } + + inet_listener { + address = 127.0.0.1 + port = 24242 + } +} +``` + +* Restart Dovecot service. + +### Monitor MySQL/MariaDB server + +netdata requires a SQL user (we use `netdata` here) with privilege `USAGE` to +gather MySQL server information. + +* Create the SQL user with a strong password (please replace `` in + command below by the real (and strong) password). + +``` +# mysql -u root +sql> GRANT USAGE ON *.* TO netdata@localhost IDENTIFIED BY ''; +sql> FLUSH PRIVILEGES; +``` + +* Create file `/usr/local/etc/netdata/python.d/mysql.conf` with content below. + + !!! attention + + * This file already exists, feel free to remove all content in this file + and copy content below as its new content. + * Please replace `` below by the real password. + +``` +tcp: + name: 'local' + host: '127.0.0.1' + port: '3306' + user: 'netdata' + pass: '' +``` + +### Monitor PostgreSQL server + +netdata requires a SQL user (we use `netdata` here) to gather PostgreSQL server +information. + +* Create the SQL user with a strong password (please replace `` in + command below by the real (and strong) password). + +``` +# su - postgres +$ psql +sql> CREATE USER netdata WITH ENCRYPTED PASSWORD '' NOSUPERUSER NOCREATEDB NOCREATEROLE; +``` + +* Create file `/usr/local/etc/netdata/python.d/mysql.conf` with content below. + + !!! attention + + * This file already exists, feel free to remove all content in this file + and copy content below as its new content. + * Please replace `` below by the real password. + +``` +socket: + name : 'local' + user : 'netdata' + password : '' + database : 'postgres' +``` + +## Configure Nginx to forward requests to netdata + +* Create Nginx config snippet `/usr/local/etc/nginx/templates/netdata.tmpl` with + content below: + +``` +# Running netdata as a subfolder to an existing virtual host +# FYI: https://github.com/firehol/netdata/wiki/Running-behind-nginx + +location = /netdata { + return 301 /netdata/; +} + +location ~ /netdata/(?.*) { + proxy_redirect off; + proxy_set_header Host $host; + + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Server $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_http_version 1.1; + proxy_pass_request_headers on; + proxy_set_header Connection "keep-alive"; + proxy_store off; + proxy_pass http://netdata/$ndpath$is_args$args; + + gzip on; + gzip_proxied any; + gzip_types *; + + auth_basic "Authentication Required"; + auth_basic_user_file /usr/local/etc/nginx/netdata.users; +} +``` + +* Update default virtual host (https site) config file + `/usr/local/etc/nginx/sites-enabled/00-default-ssl.conf`, + include new snippet config file `netdata.tmpl` before the + `misc.tmpl` line like below: + +``` +server { + ... + include /usr/local/etc/nginx/templates/netdata.tmpl; # <- add this line + include /usr/local/etc/nginx/templates/misc.tmpl; + ... +} +``` + +* Create new file `/usr/local/etc/nginx/netdata.users` and an account used to access + netdata. NOTE: Please replace `` below by a real, strong password. + +``` +touch /usr/local/etc/nginx/netdata.users +doveadm pw -s SSHA -p '' +``` + +* Now restart nginx service and access url `https://your-server/netdata/` + (please replace `your-server` by the real domain name). diff --git a/en_US/integrations/0-integration.netdata.linux.md b/en_US/integrations/0-integration.netdata.linux.md index 8bcf638f..56e51c21 100644 --- a/en_US/integrations/0-integration.netdata.linux.md +++ b/en_US/integrations/0-integration.netdata.linux.md @@ -4,9 +4,10 @@ !!! attention - This tutorial is tested on CentOS 7, Debian 9, Ubuntu 16.04. - For FreeBSD, please check this tutorial instead: - [Integrate netdata on FreeBSD](./integration.netdata.freebsd.html). + * This tutorial is tested on CentOS 7, Debian 9, Ubuntu 16.04. + For FreeBSD, please check this tutorial instead: + [Integrate netdata on FreeBSD](./integration.netdata.freebsd.html). + * netdata is an optional component since iRedMail-0.9.8. ## What's netdata @@ -148,8 +149,6 @@ server { * On RHEL/CentOS, it's `/etc/php-fpm.d/www.conf` * On Debian, it's `/etc/php5/fpm/pool.d/www.conf` * On Ubuntu, it's `/etc/php/7.0/fpm/pool.d/www.conf` (note: php version number may be different on your server) - * On FreeBSD, it's `/usr/local/etc/php-fpm.d/www.conf` - * On OpenBSD, it's `/etc/php-fpm.conf` ``` pm.status_path = /status @@ -161,18 +160,16 @@ pm.status_path = /status We need to enable statistics module in Dovecot. -* Please open Dovecot config file: - * on Linux and OpenBSD, its `/etc/dovecot/dovecot.conf`. - * on FreeBSD, it's `/usr/local/etc/dovecot/dovecot.conf`. - -* Append plugin `stats` in global parameter `mail_plugins`, and `imap_stats` - for imap protocol: +* Please open Dovecot config file `/etc/dovecot/dovecot.conf`, append plugin + `stats` in global parameter `mail_plugins`, and `imap_stats` for imap protocol: ``` mail_plugins = ... stats protocol imap { mail_plugins = ... imap_stats + ... +} ``` * Append settings below in Dovecot config file: @@ -261,8 +258,6 @@ socket: database : 'postgres' ``` -## Configure Nginx to forward requests to netdata - ## System tuning To get better performance, netdata requires few sysctl settings. Please add @@ -292,3 +287,63 @@ Reload systemd daemon: ``` systemctl daemon-reload ``` + +## Configure Nginx to forward requests to netdata + +* Create Nginx config snippet `/etc/nginx/templates/netdata.tmpl` with + content below: + +``` +# Running netdata as a subfolder to an existing virtual host +# FYI: https://github.com/firehol/netdata/wiki/Running-behind-nginx + +location = /netdata { + return 301 /netdata/; +} + +location ~ /netdata/(?.*) { + proxy_redirect off; + proxy_set_header Host $host; + + proxy_set_header X-Forwarded-Host $host; + proxy_set_header X-Forwarded-Server $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_http_version 1.1; + proxy_pass_request_headers on; + proxy_set_header Connection "keep-alive"; + proxy_store off; + proxy_pass http://netdata/$ndpath$is_args$args; + + gzip on; + gzip_proxied any; + gzip_types *; + + auth_basic "Authentication Required"; + auth_basic_user_file /etc/nginx/netdata.users; +} +``` + +* Update default virtual host (https site) config file + `/etc/nginx/sites-enabled/00-default-ssl.conf`, + include new snippet config file `netdata.tmpl` before the + `misc.tmpl` line like below: + +``` +server { + ... + include /etc/nginx/templates/netdata.tmpl; # <- add this line + include /etc/nginx/templates/misc.tmpl; + ... +} +``` + +* Create new file `/etc/nginx/netdata.users` and an account used to access + netdata. NOTE: Please replace `` below by a real, strong password. + +``` +touch /etc/nginx/netdata.users +doveadm pw -s SSHA -p '' +``` + +* Now restart nginx service and access url `https://your-server/netdata/` + (please replace `your-server` by the real domain name). diff --git a/html/integration.netdata.freebsd.html b/html/integration.netdata.freebsd.html new file mode 100644 index 00000000..267971b2 --- /dev/null +++ b/html/integration.netdata.freebsd.html @@ -0,0 +1,318 @@ + + + + + Integrate netdata monitor (on FreeBSD server) + + + + +

Integrate netdata monitor (on FreeBSD server)

+ +
+

Attention

+
    +
  • This tutorial is tested on FreeBSD 11.x. If you need to run netdata on + CentOS, Debian, Ubuntu, please check this tutorial instead: + Integrate netdata on Linux.
  • +
  • netdata is an optional component since iRedMail-0.9.8.
  • +
+
+

What's netdata

+

netdata (http://my-netdata.io) is a "Simple. Effective. Awesome!" monitor +which can monitor almost everyting on your Linux/FreeBSD system. You can visit +its website to check online demo.

+

We will show you how to install and configure netdata on iRedMail server +(Linux) to monitor mail service related softwares.

+

Install netdata

+
cd /usr/ports/net-mgmt/netdata
+make install clean
+
+ +

Configure netdata

+

Main config file of netdata is /usr/local/etc/netdata/netdata.conf, it +contains many parameters with detailed comments. Here's the +config file +used by iRedMail:

+
    +
  • It binds to address 127.0.0.1 and port 19999 by default. Since it doesn't + have ACL control, we will run netdata behind Nginx to get ACL control done in + Nginx.
  • +
+
[registry]
+    enabled = no
+
+[global]
+    bind to = 127.0.0.1
+    run as user = netdata
+    default port = 19999
+    update every = 3
+
+[plugin:proc]
+    # Disable IPVS check since iRedMail doesn't use ipvs by default
+    /proc/net/ip_vs/stats = no
+
+    # inbound packets dropped
+    /proc/net/dev = no
+
+ +

netdata ships a lot modular config files to gather information of softwares +running on the server, they have very good default settings and most config +files don't need your attention at all, including:

+
    +
  • System resources (CPU, RAM, disk I/O, etc)
  • +
  • Nginx log file monitoring
  • +
  • Fail2ban jails
  • +
  • Memcached
  • +
  • ...
  • +
+

But some applications do require extra settings, we will cover them below.

+

Monitor Nginx and php-fpm

+

We need to enable stub_status in Nginx to get detailed server info, also +update php-fpm config file to enable similar feature.

+
    +
  • Create Nginx config snippet /usr/local/etc/nginx/templates/stub_status.tmpl with + content below:
  • +
+
location = /stub_status {
+    stub_status on;
+    access_log off;
+    allow 127.0.0.1;
+    deny all;
+}
+
+location = /status {
+    include fastcgi_params;
+    fastcgi_pass php_workers;
+    fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
+    access_log off;
+    allow 127.0.0.1;
+    deny all;
+}
+
+ +
    +
  • Update default virtual host config file /usr/local/etc/nginx/sites-enabled/00-default.conf, + include new snippet config file stub_status.tmpl after the + redirect_to_https.tmpl line like below:
  • +
+
server {
+    ...
+    include /usr/local/etc/nginx/templates/redirect_to_https.tmpl;
+    include /usr/local/etc/nginx/templates/stub_status.tmpl;      # <- add this line
+    ...
+}
+
+ +
    +
  • Update php-fpm pool config file /usr/local/etc/php-fpm.d/www.conf, enable + parameter pm.status_path like below:
  • +
+
pm.status_path = /status
+
+ +
    +
  • Restart both php-fpm and Nginx service.
  • +
+

Monitor Dovecot

+

We need to enable statistics module in Dovecot.

+
    +
  • Please open Dovecot config file /usr/local/etc/dovecot/dovecot.conf, + append plugin stats in global parameter mail_plugins, and imap_stats + for imap protocol:
  • +
+
mail_plugins = ... stats
+
+protocol imap {
+    mail_plugins = ... imap_stats
+    ...
+}
+
+ +
    +
  • Append settings below in Dovecot config file:
  • +
+
plugin {
+    # how often to session statistics (must be set)
+    stats_refresh = 30 secs
+    # track per-IMAP command statistics (optional)
+    stats_track_cmds = yes
+}
+
+service stats {
+    fifo_listener stats-mail {
+        user = vmail
+        mode = 0644
+    }
+
+    inet_listener {
+        address = 127.0.0.1
+        port = 24242
+    }
+}
+
+ +
    +
  • Restart Dovecot service.
  • +
+

Monitor MySQL/MariaDB server

+

netdata requires a SQL user (we use netdata here) with privilege USAGE to +gather MySQL server information.

+
    +
  • Create the SQL user with a strong password (please replace <password> in + command below by the real (and strong) password).
  • +
+
# mysql -u root
+sql> GRANT USAGE ON *.* TO netdata@localhost IDENTIFIED BY '<password>';
+sql> FLUSH PRIVILEGES;
+
+ +
    +
  • +

    Create file /usr/local/etc/netdata/python.d/mysql.conf with content below.

    +
    +

    Attention

    +
      +
    • This file already exists, feel free to remove all content in this file + and copy content below as its new content.
    • +
    • Please replace <password> below by the real password.
    • +
    +
    +
  • +
+
tcp:
+    name: 'local'
+    host: '127.0.0.1'
+    port: '3306'
+    user: 'netdata'
+    pass: '<password>'
+
+ +

Monitor PostgreSQL server

+

netdata requires a SQL user (we use netdata here) to gather PostgreSQL server +information.

+
    +
  • Create the SQL user with a strong password (please replace <password> in + command below by the real (and strong) password).
  • +
+
# su - postgres
+$ psql
+sql> CREATE USER netdata WITH ENCRYPTED PASSWORD '<password>' NOSUPERUSER NOCREATEDB NOCREATEROLE;
+
+ +
    +
  • +

    Create file /usr/local/etc/netdata/python.d/mysql.conf with content below.

    +
    +

    Attention

    +
      +
    • This file already exists, feel free to remove all content in this file + and copy content below as its new content.
    • +
    • Please replace <password> below by the real password.
    • +
    +
    +
  • +
+
socket:
+    name     : 'local'
+    user     : 'netdata'
+    password : '<password>'
+    database : 'postgres'
+
+ +

Configure Nginx to forward requests to netdata

+
    +
  • Create Nginx config snippet /usr/local/etc/nginx/templates/netdata.tmpl with + content below:
  • +
+
# Running netdata as a subfolder to an existing virtual host
+# FYI: https://github.com/firehol/netdata/wiki/Running-behind-nginx
+
+location = /netdata {
+    return 301 /netdata/;
+}
+
+location ~ /netdata/(?<ndpath>.*) {
+    proxy_redirect off;
+    proxy_set_header Host $host;
+
+    proxy_set_header X-Forwarded-Host $host;
+    proxy_set_header X-Forwarded-Server $host;
+    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    proxy_http_version 1.1;
+    proxy_pass_request_headers on;
+    proxy_set_header Connection "keep-alive";
+    proxy_store off;
+    proxy_pass http://netdata/$ndpath$is_args$args;
+
+    gzip on;
+    gzip_proxied any;
+    gzip_types *;
+
+    auth_basic "Authentication Required";
+    auth_basic_user_file /usr/local/etc/nginx/netdata.users;
+}
+
+ +
    +
  • Update default virtual host (https site) config file + /usr/local/etc/nginx/sites-enabled/00-default-ssl.conf, + include new snippet config file netdata.tmpl before the + misc.tmpl line like below:
  • +
+
server {
+    ...
+    include /usr/local/etc/nginx/templates/netdata.tmpl;      # <- add this line
+    include /usr/local/etc/nginx/templates/misc.tmpl;
+    ...
+}
+
+ +
    +
  • Create new file /usr/local/etc/nginx/netdata.users and an account used to access + netdata. NOTE: Please replace <password> below by a real, strong password.
  • +
+
touch /usr/local/etc/nginx/netdata.users
+doveadm pw -s SSHA -p '<password>'
+
+ +
    +
  • Now restart nginx service and access url https://your-server/netdata/ + (please replace your-server by the real domain name).
  • +
+ + + + \ No newline at end of file diff --git a/html/integration.netdata.linux.html b/html/integration.netdata.linux.html index 144887fd..0c443181 100644 --- a/html/integration.netdata.linux.html +++ b/html/integration.netdata.linux.html @@ -29,17 +29,20 @@
  • Monitor PostgreSQL server
  • -
  • Configure Nginx to forward requests to netdata
  • System tuning
  • +
  • Configure Nginx to forward requests to netdata
  • Attention

    -

    This tutorial is tested on CentOS 7, Debian 9, Ubuntu 16.04. -For FreeBSD, please check this tutorial instead: -Integrate netdata on FreeBSD.

    +
      +
    • This tutorial is tested on CentOS 7, Debian 9, Ubuntu 16.04. + For FreeBSD, please check this tutorial instead: + Integrate netdata on FreeBSD.
    • +
    • netdata is an optional component since iRedMail-0.9.8.
    • +

    What's netdata

    netdata (http://my-netdata.io) is a "Simple. Effective. Awesome!" monitor @@ -169,8 +172,6 @@ location = /status {

  • On RHEL/CentOS, it's /etc/php-fpm.d/www.conf
  • On Debian, it's /etc/php5/fpm/pool.d/www.conf
  • On Ubuntu, it's /etc/php/7.0/fpm/pool.d/www.conf (note: php version number may be different on your server)
  • -
  • On FreeBSD, it's /usr/local/etc/php-fpm.d/www.conf
  • -
  • On OpenBSD, it's /etc/php-fpm.conf
  • @@ -183,22 +184,15 @@ location = /status {

    Monitor Dovecot

    We need to enable statistics module in Dovecot.

      -
    • -

      Please open Dovecot config file:

      -
        -
      • on Linux and OpenBSD, its /etc/dovecot/dovecot.conf.
      • -
      • on FreeBSD, it's /usr/local/etc/dovecot/dovecot.conf.
      • -
      -
    • -
    • -

      Append plugin stats in global parameter mail_plugins, and imap_stats - for imap protocol:

      -
    • +
    • Please open Dovecot config file /etc/dovecot/dovecot.conf, append plugin + stats in global parameter mail_plugins, and imap_stats for imap protocol:
    mail_plugins = ... stats
     
     protocol imap {
         mail_plugins = ... imap_stats
    +    ...
    +}
     
      @@ -292,7 +286,6 @@ sql> CREATE USER netdata WITH ENCRYPTED PASSWORD '<password>' NOSUPERUS database : 'postgres' -

      Configure Nginx to forward requests to netdata

      System tuning

      To get better performance, netdata requires few sysctl settings. Please add lines below in /etc/sysctl.conf:

      @@ -312,7 +305,68 @@ LimitNOFILE=30000

      Reload systemd daemon:

      systemctl daemon-reload
      -