Linux Server Performance Monitoring with Netdata

Are you looking for a real-time Linux server performance monitoring tool? Look no further.

netdata is a real-time Linux server performance monitoring tool with a beautiful web front-end. With netdata, you can monitor CPU, RAM usage, disk I/O, network traffic, Postfix, among many others. Netdata updates system statistics per second. Written in C, netdata is super fast and resources efficient.

In this tutorial, we are going to look at how to install netdata on Debian/Ubuntu and Redhat/CentOS/Fedora servers. We will also discuss how to enable password authentication on the netdata web interface so that only authorized users can have access to it.

Compile and Install netdata on Linux Server

Install basic build tools, dependencies and git.

Debian/Ubuntu

sudo apt install gcc make autoconf autogen automake pkg-config zlib1g-dev uuid-dev libmnl-dev git

Redhat/CentOS/Fedora

sudo yum install gcc make autoconf autogen automake pkgconfig zlib-devel libuuid-devel libmnl-devel git

Nice packages to have on your system. (optional)

sudo apt install curl jq nodejs

sudo yum install curl jq nodejs

Then clone netdata from Github repository.

git clone https://github.com/firehol/netdata.git

cd into the new directory.

cd netdata

Run the installation script with root privilege. It will build and install netdata to your system.

sudo ./netdata-installer.sh

Before installation, it gives you a nice hint about where files will be installed to your system. Press Enter to start building and installation.

It will be installed at these locations:

- the daemon      at    /usr/sbin/netdata
- config files    at    /etc/netdata
- web files       at    /usr/share/netdata
- plugins         at    /usr/libexec/netdata
- cache files     at    /var/cache/netdata
- db files        at    /var/lib/netdata
- log files       at    /var/log/netdata
- pid file        at    /var/run

Once it’s installed, it should be automatically started and enabled auto start on system boot. As you can see with systemctl status.

systemctl status netdata.service

Sample output:

● netdata.service - Linux real time system monitoring, done right
   Loaded: loaded (/etc/systemd/system/netdata.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2016-06-24 11:34:20 EDT; 21min ago
  Process: 24068 ExecStart=/usr/sbin/netdata -P /var/run/netdata.pid (code=exited, status=0/SUCCESS)
 Main PID: 24070 (netdata)

If your Linux server does not have systemd yet, then start it with:

sudo /usr/sbin/netdata -P /var/run/netdata.pid

To stop netdata, just kill it, with:

sudo killall netdata

You can add the start command into the /etc/rc.local file like below so that netdata will be automatically started when system is booted up.

#!/bin/sh -e

/usr/sbin/netdata -P /var/run/netdata.pid

exit 0

Netdata by default listens on port 19999. Now enter server-ip/19999 in your browser address bar to access the netdata web interface. It doesn’t have authentication mechanism. Anyone knows your IP address can have access.

Linux server performance monitoring netdata dashboard

Netdata Dashboard

Set Up Nginx Reverse Proxy

To access the web interface through domain name instead of IP address and port number, we can set up Nginx as reverse proxy for netdata. First Install Nginx on Linux server.

Debian/Ubuntu

sudo apt install nginx

Redhat/CentOS/Fedora

sudo yum install nginx

Then create a virtual host config file for netdata under /etc/nginx/conf.d/ directory.

sudo nano /etc/nginx/conf.d/netdata.conf

Put the following text into the file. Replace the red-colored text with your actual domain name.

upstream backend {
   server 127.0.0.1:19999;
   keepalive 64;
}

server {
   listen 80;
   server_name netdata.example.com;

   location / {
     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_pass http://backend;
     proxy_http_version 1.1;
     proxy_pass_request_headers on;
     proxy_set_header Connection "keep-alive";
     proxy_store off;
   }
}

Save and close this file. Then test Nginx configuration.

sudo nginx -t

If the config test is successful, reload Nginx.

sudo service nginx reload

or

sudo systemctl reload nginx

Now point your domain name to the IP address of your Linux server in DNS. Then type your domain name in the browser address bar, you can see the netdata web interface.

It’s a good security measure to limit netdata to listen only on 127.0.0.1 or ::1. Open the netdata config file.

sudo nano /etc/netdata/netdata.conf

Scroll to the 34th line.

 # bind socket to IP = *

Remove the # sign and set its value to 127.0.0.1 or ::1

bind socket to IP = 127.0.0.1

Save and close the file. Then reload nginx.

Please note that if you set the value to the IPv6 address ::1. Then in Nginx virtual host config file. You should also specify an IPv6 address in the upstream section like below.

upstream backend {
   server [::1]:19999;
   keepalive 64;
}

Enable Password Authentication

If you installed netdata on a production Linux server, it’s important to enable access control so only authorized users can see what applications are running on your system.

Generate a password file with the following command. Replace the red-colored text with your preferred username and password. The password will created at /etc/nginx/password.

printf "yourusername:$(openssl passwd -crypt 'yourpassword')" | sudo tee -a /etc/nginx/passwords

Then edit the Nginx virtual host config file for netdata.

sudo nano /etc/nginx/conf.d/netdata.conf

Add the auth directives in server section. auth_basic enables basic password authentication. auth_basic_user_file directive specifies the password file.

server {
.....

auth_basic "Protected";
auth_basic_user_file /etc/nginx/passwords;

....

Save and close the file. Then reload Nginx. Now your browser will ask you to enter the username and password. If you are interested in encrypting your http connection. Then you can obtain a free TLS/SSL certificate from Let’s Encrypt certificate authority.

Netdata Linux Server Performance Monitoring Screenshot Tour

CPU Usage

netdata monitor CPU usage

RAM Usage

Linux server performance monitoring RAM usage

Disk I/O

Linux server performance monitoring disk io

Network Traffic

Linux server performance monitoring network traffic

Hope you like this Linux server performance monitoring tool. Comments, questions or suggestions are always welcome. If you found this post useful, 🙂 please share it with your friends on social media! Stay tuned for more Linux tutorials.

Rate this tutorial
[Total: 4 Average: 4]
  • Great tutorial, thank you!

  • FYI: If you install on a DigitalOcean lamp server, the firewall is on by default. You must allow the port using command “ufw allow 19999”