设为首页 收藏本站
查看: 834|回复: 0

[经验分享] How to Monitor Nginx using Netdata on CentOS 7-Arnold

[复制链接]

尚未签到

发表于 2019-2-16 06:37:12 | 显示全部楼层 |阅读模式
  Netdata is an open source monitoring system for Linux servers. It provides real-time performance and health monitoring with beautiful dashboard and analytics. Netdata should run on any Linux distribution - has been tested on Alpine Linux, Arch Linux, CentOS, Ubuntu etc. It offers real-time health monitoring tools for your servers, CPU, memory usage, IPv4 and IPv6 networks and user applications such as Nginx, fail2ban, MySQL, MongoDB etc.
  In this tutorial, I will show you how to monitor Nginx using Netdata. This tutorial will cover the Nginx web server installation, enabling of the 'stub_status' module, and Netdata installation on CentOS 7.
What we will do

  •   Install Nginx Webserver.
  •   Enable Nginx 'stub_status' module.
  •   Install Netdata on CentOS 7.
  •   Monitor Nginx using Netdata.
  •   Testing.
Prerequisites

  •   CentOS 7 Server
  •   Root privileges
Step 1 - Install Nginx Web server
  In this step, we will install the Nginx web server from the EPEL (Extra Packages for Enterprise Linux) repository. Before installing Nginx, make sure the EPEL repository has been installed on your server.
  If you do not have it, you can install it using the command below.
  yum -y install epel-release
DSC0000.png

  Next, install Nginx with the yum command below.
  yum -y install nginx
  And if the installation has been completed, start the service and enable it to launch automatically at system boot using the systemctl commands below.
  systemctl start nginx
  systemctl enable nginx
  After the installation, open HTTP and HTTPS ports using the firewall-cmd command below.
  firewall-cmd --add-service=http --permanent
  firewall-cmd --add-service=https --permanent
  firewall-cmd --reload
   DSC0001.png
  Note: If you do not have the firewall-cmd command, you can install the firewalld packages from the repository.
  yum -y install firewalld
  The Nginx web server has been installed.
Step 2 - Enable Nginx stub_status module
  To monitor Nginx using Netdata, we must enable the 'stub_status' module by editing the configuration. Make sure your Nginx version has a module named 'stub_status', check the module with the command below.
  nginx -V
  You should get a result similar to the following.
DSC0002.png

  Make sure you have the 'stub_status' module on the list.
  Next, edit the nginx configuration file 'nginx.conf' to enable the 'stub_status' module. Go to the '/etc/nginx/' directory and edit the configuration with vim.
  cd /etc/nginx/
  vim nginx.conf
  Paste the following configuration inside the 'server {}' block.
    location /stub_status {  
         stub_status;
  
         # Security: Only allow access from the IP below.
  
         allow 127.0.0.1;
  
         # Deny anyone else
  
         deny all;
  
     }
DSC0003.png

  Save and exit.
  Now, test the nginx configuration and make sure there is no error. Then restart nginx.
  nginx -t
  systemctl restart nginx
DSC0004.png

  Nginx 'stub_status' module has been enabled - we can check it using the curl command as shown below.
  curl http://127.0.0.1/stub_status
  When it's enabled, you can see the result as below.
DSC0005.png

Step 3 - Install Netdata on CentOS 7
  In this step, we will install Netdata on the CentOS 7 server. Before installing Netdata, we need to install some packages for Netdata installation.
  Install packages needed for Netdata installation using the following yum command.
  yum -y install zlib-devel libuuid-devel libmnl-devel gcc make git autoconf autogen automake pkgconfig curl jq nodejs
  Next, download Netdata source code using the following git command.
  cd ~
  git clone https://github.com/firehol/netdata.git --depth=1
DSC0006.png

  Go to the netdata directory and run the Netdata installer script with sudo privileges.
  cd netdata/
  sudo ./netdata-installer.sh
  Press 'Enter' to continue with the Nedata installation.
DSC0007.png

  And when the installation is complete, you will see the result as below.
DSC0008.png

  Netdata has been installation on CentOS 7, and it's running on port '19999'.
  Open the port using the firewall-cmd command below.
  sudo firewall-cmd --permanent --add-port=19999/tcp
  sudo firewall-cmd --reload
  Netdata provides a systemd services script, so you can manage Netdata using the systemctl command. Restart netdata and enable it to launch automatically every time at system boot.
  systemctl restart netdata
  systemctl enable netdata
  Check the opened port of the server - make sure you get the port 19999 on the 'LISTEN' state.
  netstat -plntu
DSC0009.png

  The Netdata monitoring tool has been installed on CentOS 7.
Step 4 - Monitor Nginx using Netdata
  At this stage, Nginx has been installed, the stub_status module has been enabled, and the Netdata installation has been completed. In this step, we want to monitor the nginx web server using Netdata. Monitoring for requests, active connection, and the status.
  Netdata provides modules for monitoring system applications. There are some applications like Apache, Nginx, MongoDB etc that use python modules for monitoring using Netdata.
  Go to the netdata 'python.d' directory and edit the configuration file nginx.conf using vim.
  cd /etc/netdata/python.d/
  vim nginx.conf
  Go to the bottom line and make sure you have a configuration as shown below.
localhost:  
   name : 'local'
  
   url  : 'http://localhost/stub_status'
DSC00010.png

  Save and exit.
  Now restart the netdata service using the systemctl command.
  systemctl restart netdata
Step 5 - Testing
  Open your web browser and visit the server IP address with port 19999.
  http://192.168.1.11:19999/
  And you will get the Netdata Dashboard.
DSC00011.png

  Click on the 'nginx local' on the right, and see Nginx active connections, requests, status and the connection rate.
DSC00012.png

  Netdata has been installed on the CentOS 7 server, and the Nginx web server is being monitored using Netdata.
Preference

  •   https://github.com/firehol/netdata/wiki/



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-672800-1-1.html 上篇帖子: How to Install a Kubernetes Docker Cluster Centos7-Arnold 下篇帖子: How to Monitor Nginx using Netdata on CentOS 7-Arnold
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表