Want to subscribe to topics you're interested in?
Become a Member

Nginx Nginx - Perfect install for netdata (system monitor) - Step by step

Discussion in 'Centmin Mod User Tutorials & Guides' started by EckyBrazzz, May 16, 2019.

  1. EckyBrazzz

    EckyBrazzz Active Member

    463
    95
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +177
    Local Time:
    4:18 PM
    1.17.x
    10.3.x
    I just got Nginx monitoring working on the installation. See First post for update!
     
    • Like Like x 3
  2. EckyBrazzz

    EckyBrazzz Active Member

    463
    95
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +177
    Local Time:
    4:18 PM
    1.17.x
    10.3.x
    Updated the first post to clean it up now the title of the topic changed. Missing is the part to protect the outside world from seeing the netdata stats, but in the next days I will add this configuration.
     
    • Like Like x 1
  3. jair

    jair Member

    39
    4
    8
    Jan 8, 2017
    Ratings:
    +8
    Local Time:
    10:18 PM
    I am just getting in to netdata, so can't be of much help at the moment, becides I am a regular noob. My end goal is to have netdata to monitor not only the hardware, but also nginx (I see that you have that already), php-fpm, mariadb, and redis.

    I will post what I found here if you don't mind.
     
    • Agree Agree x 1
    style="display:inline-block;min-width:400px;max-width:970px;width:95%;height:90px" data-ad-client="ca-pub-6669518204467592" data-ad-slot="4024536743" data-ad-format="auto">
  4. EckyBrazzz

    EckyBrazzz Active Member

    463
    95
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +177
    Local Time:
    4:18 PM
    1.17.x
    10.3.x
    Please do! That's what the forum needs, users that give feedback.

    FYI, other users, I fixed a bit of security so that nobody can access your netdata stats. It's real easy, just edit the global.ini file and add you "static" ip on some places. I will update the first post when I have some spare time and give an update when done!
     
  5. jair

    jair Member

    39
    4
    8
    Jan 8, 2017
    Ratings:
    +8
    Local Time:
    10:18 PM
    Adding a php-fpm monitoring is very much similar to nginx one - you need to enable the status page and then give this url to netdata for monitoring.

    Steps:

    1. Enable the php status page. On a default centminmod install you just need to uncomment:
    Code:
    #include /usr/local/nginx/conf/phpstatus.conf;
    
    from /usr/local/nginx/conf/conf.d/virtual.conf

    Then restart nginx and php-fpm.

    Full instructions here in the section How To Enable Php-Fpm Usage Stats Display ? : PHP-FPM - CentminMod.com LEMP Nginx web stack for CentOS

    2. Create (if it doesn't exist already) a file phpfpm.conf in /etc/netdata/python.d with the following contents:
    Code:
    local:
      url     : 'http://localhost/phpstatus'
    3. Restart netdata:
    Code:
    service netdata restart
    Thats it! Now you should be able to see php-fpm stats in the right menu under PHP-FPM Local.
     
    • Like Like x 1
  6. jair

    jair Member

    39
    4
    8
    Jan 8, 2017
    Ratings:
    +8
    Local Time:
    10:18 PM
    Succeeded with mariadb as well, but it was more tricky.

    1. Create a user for netdata to use to access the database.
    Code:
    # mysql -u root -p
    MariaDB [(none)]> CREATE USER 'netdata'@'localhost';
    MariaDB [(none)]> GRANT USAGE on *.* to 'netdata'@'localhost';
    MariaDB [(none)]> FLUSH PRIVILEGES;
    MariaDB [(none)]> exit
    Commands taken from: How to Monitor MySQL/MariaDB Databases using Netdata on CentOS 7

    2. Install the required python libraries as outlined at the top of the page here: mysql - Netdata Documentation In my case it was simply running:
    Code:
    pip install mysqlclient
    3. Create mysql.conf in /etc/netdata/python.d/ with the following contents:
    Code:
    local:
      'my.cnf'   : '/etc/my.cnf'
      user     : 'netdata'
    I am not even sure that the first line is needed too.

    4. Restart netdata and enjoy the MySQL Local stats in the right menu.

    I will explore at a later point whether I need this: User Statistics For now, it looks sufficient.
     
    • Like Like x 1
  7. jair

    jair Member

    39
    4
    8
    Jan 8, 2017
    Ratings:
    +8
    Local Time:
    10:18 PM
    Redis is also done.

    If you are having redis server listening to the default port, all it takes is creating redis.conf in /etc/netdata/python.d/ with the following contents:

    Code:
    socket:
      name     : 'local'
      socket   : '/var/lib/redis/redis.sock'
    
    localhost:
      name     : 'local'
      host     : 'localhost'
      port     : 6379
    Info taken from the docs: redis - Netdata Documentation
     
  8. EckyBrazzz

    EckyBrazzz Active Member

    463
    95
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +177
    Local Time:
    4:18 PM
    1.17.x
    10.3.x
    Not needed, just tested it. Netdata started to collect to MySQL data directly after restarting netdata. You only need to put this into the mysql.conf that you create in /etc/netdata/python.d/
    Code (Text):
    local:
      user     : 'netdata'
    
     
    • Agree Agree x 1
  9. jair

    jair Member

    39
    4
    8
    Jan 8, 2017
    Ratings:
    +8
    Local Time:
    10:18 PM
    Looking forward to that part, at least some pointers would be helpful. I am not able to find global.ini at all.

    Edit: I added in the [web] part of netdata.conf the following string:

    Code:
    allow connections from = localhost <my ip>
    Seems to work fine. Per this comment from the docs, it seems like the most restrictive option. Good enough for now for me.

     
    Last edited: Jul 8, 2019
  10. EckyBrazzz

    EckyBrazzz Active Member

    463
    95
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +177
    Local Time:
    4:18 PM
    1.17.x
    10.3.x
    Correct, I the hurry I typed in the wrong file:rolleyes:
     
  11. jair

    jair Member

    39
    4
    8
    Jan 8, 2017
    Ratings:
    +8
    Local Time:
    10:18 PM
    I managed to setup the email alerting as well. As I don't intend to maintain a mail server I am using Amazon SES. Here are the settings to setup Amazon SES with sendmail for linux:

    Integrating Amazon SES with Sendmail - Amazon Simple Email Service

    I suggest to follow this guide to the letter, because even though it is not hard, there are some fine details. Also keep in mind that sending the test email takes a few minutes after you send it with ctrl+d, I was impatient that I didn't do it correctly :) In case of issues check:

    Code:
    /var/mail/<username>
    Most probably the exact error will be logged there.

    After sendmail is properly setup, you need to setup netdata to send emails as well. Instructions pointing out which files you need to edit for from, to addresses, severity and sending test alert: email - Netdata Documentation

    There are many settings to tweak, I figured I'll try the defaults first and depending on the spam level and my personal feeling how many of them are false alarms I will tweak further.

    Thats it :) I feel I am happy with my setup now, my main target is to monitor the soft raid for failed drives, so everything else is extra.
     
    • Informative Informative x 2
  12. EckyBrazzz

    EckyBrazzz Active Member

    463
    95
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +177
    Local Time:
    4:18 PM
    1.17.x
    10.3.x
    @jair First I want to thank you for your effort and input here on the forum. I do hope that many other users follow you so that we really have a forum that not only depends on manly @eva2000 and a few that are active now.

    About the mailing, I had it setup on another server, worked excellent, guess I did it with mailX. But started to receive system mails from different mailing systems on the server. So have to do some testing to prevent this happening again.

    Other question. Do you mind If I use your input to update my first post? I will mention you as source and contribution for the perfect install for netdata.
     
  13. jair

    jair Member

    39
    4
    8
    Jan 8, 2017
    Ratings:
    +8
    Local Time:
    10:18 PM
    Of course no issues, especially if you want to create an easy to follow complete guide.

    It will be useful for me down the road as well, I can imagine that if I have to reinstall everything in three years a well laid out guide will be very useful for all the steps I am skipping right now in my description, but are probably important.