Learn about Centmin Mod LEMP Stack today
Register Now

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

    747
    149
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +274
    Local Time:
    7:44 PM
    1.17.x Cluster
    10.3.x Cluster & Redis
    I just got Nginx monitoring working on the installation. See First post for update!
     
    • Like Like x 3
  2. EckyBrazzz

    EckyBrazzz Active Member

    747
    149
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +274
    Local Time:
    7:44 PM
    1.17.x Cluster
    10.3.x Cluster & Redis
    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

    48
    7
    8
    Jan 8, 2017
    Ratings:
    +17
    Local Time:
    11:44 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
  4. EckyBrazzz

    EckyBrazzz Active Member

    747
    149
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +274
    Local Time:
    7:44 PM
    1.17.x Cluster
    10.3.x Cluster & Redis
    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

    48
    7
    8
    Jan 8, 2017
    Ratings:
    +17
    Local Time:
    11:44 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

    48
    7
    8
    Jan 8, 2017
    Ratings:
    +17
    Local Time:
    11:44 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

    48
    7
    8
    Jan 8, 2017
    Ratings:
    +17
    Local Time:
    11:44 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

    747
    149
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +274
    Local Time:
    7:44 PM
    1.17.x Cluster
    10.3.x Cluster & Redis
    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

    48
    7
    8
    Jan 8, 2017
    Ratings:
    +17
    Local Time:
    11:44 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

    747
    149
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +274
    Local Time:
    7:44 PM
    1.17.x Cluster
    10.3.x Cluster & Redis
    Correct, I the hurry I typed in the wrong file:rolleyes:
     
  11. jair

    jair Member

    48
    7
    8
    Jan 8, 2017
    Ratings:
    +17
    Local Time:
    11:44 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

    747
    149
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +274
    Local Time:
    7:44 PM
    1.17.x Cluster
    10.3.x Cluster & Redis
    @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

    48
    7
    8
    Jan 8, 2017
    Ratings:
    +17
    Local Time:
    11:44 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.
     
  14. jair

    jair Member

    48
    7
    8
    Jan 8, 2017
    Ratings:
    +17
    Local Time:
    11:44 PM
    Another fairly easy to enable plugin is elastic search. You only need elasticsearch.conf in /etc/netdata/python.d with the following contents:

    Code (Text):
    local:
      host               : 'localhost'    # Elasticsearch server ip address or hostname
      port               : '9200'         # Port on which elasticsearch listens
    


    localhost and 9200 are the default address and port.

    Overall, I've read that dealing with netdata custom plugins can be tricky, but at least for the ones I am using it is as simple as it can get.
     
    • Informative Informative x 2
  15. EckyBrazzz

    EckyBrazzz Active Member

    747
    149
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +274
    Local Time:
    7:44 PM
    1.17.x Cluster
    10.3.x Cluster & Redis
    Updated first post with extra functions (thanks to @jair)
     
    • Like Like x 2
  16. EckyBrazzz

    EckyBrazzz Active Member

    747
    149
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +274
    Local Time:
    7:44 PM
    1.17.x Cluster
    10.3.x Cluster & Redis
    UPDATE: NETDATA v1.17.0 has been released 1 hour ago.

    netdata/netdata

    Tested my own install, but it was up to date nightly build v1.16.xx :( Guess I have to wait a bit
     
    • Informative Informative x 1
  17. mrkip

    mrkip New Member

    9
    7
    3
    Jan 29, 2019
    Ratings:
    +7
    Local Time:
    9:44 PM
    • Like Like x 2
  18. EckyBrazzz

    EckyBrazzz Active Member

    747
    149
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +274
    Local Time:
    7:44 PM
    1.17.x Cluster
    10.3.x Cluster & Redis
    Do they exist? You managed to fix it:) Keep reading the forum (RTFM)....It's a source that you won't regret.
    I never had any trouble with the CSF before, maybe it is due the new release (https also). Guess it's time to look at some severs if I still can access netdata....(cloud sign up --> Easy switch)
     
  19. EckyBrazzz

    EckyBrazzz Active Member

    747
    149
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +274
    Local Time:
    7:44 PM
    1.17.x Cluster
    10.3.x Cluster & Redis
    Corrected small typo in manual
     
    • Like Like x 1