{"id":3737,"date":"2018-05-09T18:07:00","date_gmt":"2018-05-09T14:07:00","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/how-to-monitor-nginx-using-netdata-on-centos-7\/"},"modified":"2018-05-09T18:07:00","modified_gmt":"2018-05-09T14:07:00","slug":"how-to-monitor-nginx-using-netdata-on-centos-7","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-monitor-nginx-using-netdata-on-centos-7\/","title":{"rendered":"How to Monitor Nginx using Netdata on CentOS 7"},"content":{"rendered":"<p>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 &#8211; 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.<\/p>\n<p>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 &#8216;stub_status&#8217; module, and Netdata installation on CentOS 7.<\/p>\n<h2 id=\"what-we-will-do\">What we will do<\/h2>\n<ol>\n<li>Install Nginx Webserver.<\/li>\n<li>Enable Nginx &#8216;stub_status&#8217; module.<\/li>\n<li>Install Netdata on CentOS 7.<\/li>\n<li>Monitor Nginx using Netdata.<\/li>\n<li>Testing.<\/li>\n<\/ol>\n<h2 id=\"prerequisites\">Prerequisites<\/h2>\n<ul>\n<li>CentOS 7 Server<\/li>\n<li>Root privileges<\/li>\n<\/ul>\n<h2 id=\"step-install-nginx-web-server\">Step 1 &#8211; Install Nginx Web server<\/h2>\n<p>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.<\/p>\n<p>If you do not have it, you can install it using the command below.<\/p>\n<p class=\"command\">yum -y install epel-release<\/p>\n<p><a class=\"fancybox\" id=\"img-1\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_monitor_nginx_using_netdata_on_centos_7\/big\/1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7.png\" alt=\"Install Nginx Web server\" width=\"500\" height=\"148\" title=\"\"><\/a><\/p>\n<p>Next, install Nginx with the yum command below.<\/p>\n<p class=\"command\">yum -y install nginx<\/p>\n<p>And if the installation has been completed, start the service and enable it to launch automatically at system boot using the systemctl commands below.<\/p>\n<p class=\"command\">systemctl start nginx<br \/>systemctl enable nginx<\/p>\n<p>After the installation, open HTTP and HTTPS ports using the firewall-cmd command below.<\/p>\n<p class=\"command\">firewall-cmd &#8211;add-service=http &#8211;permanent<br \/>firewall-cmd &#8211;add-service=https &#8211;permanent<br \/>firewall-cmd &#8211;reload<\/p>\n<p><strong><a class=\"fancybox\" id=\"img-6\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_monitor_nginx_using_netdata_on_centos_7\/big\/6.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-1.png\" alt=\"Configure the firewall\" width=\"500\" height=\"166\" title=\"\"><\/a><br \/><\/strong><\/p>\n<p><strong>Note: <\/strong>If you do not have the firewall-cmd command, you can install the firewalld packages from the repository.<\/p>\n<p class=\"command\">yum -y install firewalld<\/p>\n<p>The Nginx web server has been installed.<\/p>\n<h2 id=\"step-enable-nginx-stubstatus-module\">Step 2 &#8211; Enable Nginx stub_status module<\/h2>\n<p>To monitor Nginx using Netdata, we must enable the &#8216;stub_status&#8217; module by editing the configuration. Make sure your Nginx version has a module named &#8216;stub_status&#8217;, check the module with the command below.<\/p>\n<p class=\"command\">nginx -V<\/p>\n<p>You should get a result similar to the following.<\/p>\n<p><a class=\"fancybox\" id=\"img-2\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_monitor_nginx_using_netdata_on_centos_7\/big\/2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-2.png\" alt=\"Enable Nginx stub_status module\" width=\"500\" height=\"128\" title=\"\"><\/a><\/p>\n<p>Make sure you have the &#8216;stub_status&#8217; module on the list.<\/p>\n<p>Next, edit the nginx configuration file &#8216;nginx.conf&#8217; to enable the &#8216;stub_status&#8217; module. Go to the &#8216;\/etc\/nginx\/&#8217; directory and edit the configuration with <a href=\"https:\/\/www.howtoforge.com\/vim-basics\" target=\"_blank\" rel=\"noopener noreferrer\">vim<\/a>.<\/p>\n<p class=\"command\">cd \/etc\/nginx\/<br \/>vim nginx.conf<\/p>\n<p>Paste the following configuration inside the &#8216;<strong>server {}<\/strong>&#8216; block.<\/p>\n<pre class=\"system\">\u00a0\u00a0\u00a0 location \/stub_status {<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 stub_status;<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # Security: Only allow access from the IP below.<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 allow 127.0.0.1;<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # Deny anyone else<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 deny all;<br\/>\u00a0\u00a0\u00a0 }<\/pre>\n<p><a class=\"fancybox\" id=\"img-3\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_monitor_nginx_using_netdata_on_centos_7\/big\/3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-3.png\" alt=\"Configure nginx\" width=\"500\" height=\"296\" title=\"\"><\/a><\/p>\n<p>Save and exit.<\/p>\n<p>Now, test the nginx configuration and make sure there is no error. Then restart nginx.<\/p>\n<p class=\"command\">nginx -t<br \/>systemctl restart nginx<\/p>\n<p><a class=\"fancybox\" id=\"img-4\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_monitor_nginx_using_netdata_on_centos_7\/big\/4.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-4.png\" alt=\"Test nginx config and restart nginx\" width=\"500\" height=\"149\" title=\"\"><\/a><\/p>\n<p>Nginx &#8216;stub_status&#8217; module has been enabled &#8211; we can check it using the curl command as shown below.<\/p>\n<p class=\"command\">curl http:\/\/127.0.0.1\/stub_status<\/p>\n<p>When it&#8217;s enabled, you can see the result as below.<\/p>\n<p><a class=\"fancybox\" id=\"img-5\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_monitor_nginx_using_netdata_on_centos_7\/big\/5.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-5.png\" alt=\"Test nginx stub status\" width=\"500\" height=\"140\" title=\"\"><\/a><\/p>\n<h2 id=\"step-install-netdata-on-centos-\">Step 3 &#8211; Install Netdata on CentOS 7<\/h2>\n<p>In this step, we will install Netdata on the CentOS 7 server. Before installing Netdata, we need to install some packages for Netdata installation.<\/p>\n<p>Install packages needed for Netdata installation using the following yum command.<\/p>\n<p class=\"command\">yum -y install zlib-devel libuuid-devel libmnl-devel gcc make git autoconf autogen automake pkgconfig curl jq nodejs<\/p>\n<p>Next, download Netdata source code using the following git command.<\/p>\n<p class=\"command\">cd ~<br \/>git clone https:\/\/github.com\/firehol\/netdata.git &#8211;depth=1<\/p>\n<p><a class=\"fancybox\" id=\"img-7\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_monitor_nginx_using_netdata_on_centos_7\/big\/7.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-6.png\" alt=\"Install Netdata on CentOS 7\" width=\"500\" height=\"169\" title=\"\"><\/a><\/p>\n<p>Go to the netdata directory and run the Netdata installer script with sudo privileges.<\/p>\n<p class=\"command\">cd netdata\/<br \/>sudo .\/netdata-installer.sh<\/p>\n<p>Press &#8216;Enter&#8217; to continue with the Nedata installation.<\/p>\n<p><a class=\"fancybox\" id=\"img-8\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_monitor_nginx_using_netdata_on_centos_7\/big\/8.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-7.png\" alt=\"Install Netdata\" width=\"500\" height=\"459\" title=\"\"><\/a><\/p>\n<p>And when the installation is complete, you will see the result as below.<\/p>\n<p><a class=\"fancybox\" id=\"img-9\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_monitor_nginx_using_netdata_on_centos_7\/big\/9.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-8.png\" alt=\"Eun netdata installer\" width=\"500\" height=\"305\" title=\"\"><\/a><\/p>\n<p>Netdata has been installation on CentOS 7, and it&#8217;s running on port &#8216;19999&#8217;.<\/p>\n<p>Open the port using the firewall-cmd command below.<\/p>\n<p class=\"command\">sudo firewall-cmd &#8211;permanent &#8211;add-port=19999\/tcp<br \/>sudo firewall-cmd &#8211;reload<\/p>\n<p>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.<\/p>\n<p class=\"command\">systemctl restart netdata<br \/>systemctl enable netdata<\/p>\n<p>Check the opened port of the server &#8211; make sure you get the port 19999 on the &#8216;LISTEN&#8217; state.<\/p>\n<p class=\"command\">netstat -plntu<\/p>\n<p><a class=\"fancybox\" id=\"img-10\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_monitor_nginx_using_netdata_on_centos_7\/big\/10.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-9.png\" alt=\"Check network port\" width=\"500\" height=\"344\" title=\"\"><\/a><\/p>\n<p>The Netdata monitoring tool has been installed on CentOS 7.<\/p>\n<h2 id=\"step-monitor-nginx-using-netdata\">Step 4 &#8211; Monitor Nginx using Netdata<\/h2>\n<p>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.<\/p>\n<p>Netdata provides modules for monitoring system applications. There are some applications like Apache, Nginx, MongoDB etc that use python modules for monitoring using Netdata.<\/p>\n<p>Go to the netdata &#8216;python.d&#8217; directory and edit the configuration file nginx.conf using vim.<\/p>\n<p class=\"command\">cd \/etc\/netdata\/python.d\/<br \/>vim nginx.conf<\/p>\n<p>Go to the bottom line and make sure you have a configuration as shown below.<\/p>\n<pre class=\"system\">localhost:<br\/>\u00a0 name : 'local'<br\/>\u00a0 url\u00a0 : 'http:\/\/localhost\/stub_status'<\/pre>\n<p><a class=\"fancybox\" id=\"img-11\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_monitor_nginx_using_netdata_on_centos_7\/big\/11.png\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-10.png\" alt=\"Configure netdata\" title=\"\"><\/a><\/p>\n<p>Save and exit.<\/p>\n<p>Now restart the netdata service using the systemctl command.<\/p>\n<p class=\"command\">systemctl restart netdata<\/p>\n<h2 id=\"step-testing\">Step 5 &#8211; Testing<\/h2>\n<p>Open your web browser and visit the server IP address with port 19999.<\/p>\n<p><em><strong>http:\/\/192.168.1.11:19999\/<\/strong><\/em><\/p>\n<p>And you will get the Netdata Dashboard.<\/p>\n<p><a class=\"fancybox\" id=\"img-12\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_monitor_nginx_using_netdata_on_centos_7\/big\/12.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-11.png\" alt=\"Netdata System Overview\" width=\"500\" height=\"284\" title=\"\"><\/a><\/p>\n<p>Click on the &#8216;nginx local&#8217; on the right, and see Nginx active connections, requests, status and the connection rate.<\/p>\n<p><a class=\"fancybox\" id=\"img-13\" href=\"https:\/\/www.howtoforge.com\/images\/how_to_monitor_nginx_using_netdata_on_centos_7\/big\/13.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-12.png\" alt=\"connections, requests, status and the connection rate\" width=\"500\" height=\"285\" title=\"\"><\/a><\/p>\n<p>Netdata has been installed on the CentOS 7 server, and the Nginx web server is being monitored using Netdata.<\/p>\n<h2 id=\"preference\">Preference<\/h2>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhow-to-monitor-nginx-using-netdata-on-centos-7%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-13.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhow-to-monitor-nginx-using-netdata-on-centos-7%2F&amp;text=How+to+Monitor+Nginx+using+Netdata+on+CentOS+7&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-14.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-15.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhow-to-monitor-nginx-using-netdata-on-centos-7%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/05\/how-to-monitor-nginx-using-netdata-on-centos-7-16.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8211; 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 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-3737","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/3737","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=3737"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/3737\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=3737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=3737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=3737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}