用 Netdata 监控 Linux
Netdata 监控
![](/data/attachment/album/201607/14/222943cr2e9qqbliqz2z0r.png)


Netdata 是一个实时的资源监控工具，它拥有基于 web 的友好界面，由 [FireHQL](https://firehol.org/) 开发和维护。通过这个工具，你可以通过图表来了解 CPU，RAM，硬盘，网络，Apache， Postfix 等软硬件的资源使用情况。它很像 Nagios 等别的监控软件；但是，Netdata 仅仅支持通过 Web 界面进行实时监控。


### 了解 Netdata


目前 Netdata 还没有验证机制，如果你担心别人能从你的电脑上获取相关信息的话，你应该设置防火墙规则来限制访问。UI 很简单，所以任何人看懂图形并理解他们看到的结果，至少你会对它的快速安装印象深刻。


它的 web 前端响应很快，而且不需要 Flash 插件。 UI 很整洁，保持着 Netdata 应有的特性。第一眼看上去，你能够看到很多图表，幸运的是绝大多数常用的图表数据（像 CPU，RAM，网络和硬盘）都在顶部。如果你想深入了解图形化数据，你只需要下滑滚动条，或者点击在右边菜单的项目。通过每个图表的右下方的按钮， Netdata 还能让你控制图表的显示，重置，缩放。


![](/data/attachment/album/201607/14/222954f8vhjbozachsvcqj.png)


*Netdata 图表控制*


Netdata 并不会占用多少系统资源，它占用的内存不会超过 40MB。因为这个软件是作者用 C 语言写的。


![](/data/attachment/album/201607/14/222956p2is8n6o6gin8xxk.png)


*Netdata 显示的内存使用情况*


### 下载 Netdata


要下载这个软件，你可以访问 [Netdata 的 GitHub 页面](https://github.com/firehol/netdata)，然后点击页面左边绿色的 "Clone or download" 按钮 。你应该能看到以下两个选项：


#### 通过 ZIP 文件下载


一种方法是下载 ZIP 文件。它包含仓库里的所有东西。但是如果仓库更新了，你需要重新下载 ZIP 文件。下载完 ZIP 文件后，你要用 `unzip` 命令行工具来解压文件。运行下面的命令能把 ZIP 文件的内容解压到 `netdata` 文件夹。



```
$ cd ~/Downloads
$ unzip netdata-master.zip

```

![](/data/attachment/album/201607/14/223007wi34xl9l4njsigns.png)


*解压 Netdata*


没必要在 unzip 命令后加上 `-d` 选项，因为文件都是放在 ZIP 文件的根文件夹里面。如果没有那个文件夹， unzip 会把所有东西都解压到当前目录下面（这会让文件非常混乱）。


#### 通过 Git 下载


还有一种方式是通过 git 下载整个仓库。当然，你的系统需要安装 git。Git 在 Fedora 系统是默认安装的。如果没有安装，你可以用下面的命令在命令行里安装 git。



```
$ sudo dnf install git

```

安装好 git 后，你要把仓库 “clone” 到你的系统里。运行下面的命令。



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

```

这个命令会在当前工作目录克隆（或者说复制一份）仓库。


### 安装 Netdata


有些软件包是你成功构造 Netdata 时候需要的。 还好，一行命令就可以安装你所需要的东西（[这写在它的安装文档中](https://github.com/firehol/netdata/wiki/Installation)）。在命令行运行下面的命令就能满足安装 Netdata 需要的所有依赖关系。



```
$ dnf install zlib-devel libuuid-devel libmnl-devel gcc make git autoconf autogen automake pkgconfig

```

当所有需要的软件包都安装好了，你就 cd 到 netdata/ 目录，运行 netdata-installer.sh 脚本。



```
$ sudo ./netdata-installer.sh

```

然后就会提示你按回车键，开始安装程序。如果要继续的话，就按下回车吧。


![](/data/attachment/album/201607/14/223009aus5zbeeo5kg7bss.png)


*Netdata 的安装*


如果一切顺利，你的系统上就已经安装并且运行了 Netdata。安装脚本还会在相应的文件夹里添加一个卸载脚本，叫做 `netdata-uninstaller.sh`。如果你以后不想使用 Netdata，运行这个脚本可以从你的系统里面卸载掉 Netdata。


你可以通过 systemctl 查看它的运行状态。



```
$ sudo systemctl status netdata

```

### 使用 Netdata


既然我们已经安装并且运行了 Netdata，你就能够通过 19999 端口来访问 web 界面。下面的截图是我在一个测试机器上运行的 Netdata。


![](/data/attachment/album/201607/14/223010g9wzwkk5jzx6ow94.png)


*关于 Netdata 运行时的概览*


恭喜！你已经成功安装并且能够看到漂亮的外观和图形，以及你的机器性能的高级统计数据。无论是否是你个人的机器，你都可以向你的朋友们炫耀，因为你能够深入的了解你的服务器性能，Netdata 在任何机器上的性能报告都非常出色。




---


via: <https://fedoramagazine.org/monitor-linux-netdata/>


作者：[Martino Jones](https://fedoramagazine.org/monitor-linux-netdata/) 译者：[GitFuture](https://github.com/GitFuture) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
Netdata is a real-time resource monitoring tool with a friendly web front-end developed and maintained by [FireHOL](https://firehol.org/). With this tool, you can read charts representing resource utilization of things like CPUs, RAM, disks, network, Apache, Postfix and more. It is similar to other monitoring software like Nagios; however, Netdata is only for real-time monitoring via a web interface.


## Understanding Netdata

There’s currently no authentication, so if you’re concerned about someone getting information about the applications you’re running on your system, you should restrict who has access via a firewall policy. The UI is simplified in a way anyone could look at the graphs and understand what they’re seeing, or at least be impressed by your flashy setup.

The web front-end is very responsive and requires no Flash plugin. The UI doesn’t clutter things up with unneeded features, but sticks to what it does. At first glance, it may seem a bit much with the hundreds of charts you have access to, but luckily the most commonly needed charts (i.e. CPU, RAM, network, and disk) are at the top. If you wish to drill deeper into the graphical data, all you have to do is scroll down or click on the item in the menu to the right. Netdata even allows you to control the chart with play, reset, zoom and resize with the controls on the bottom right of each chart.

When it comes down to system resources, the software doesn’t need too much either. The creators choose to write the software in C. Netdata doesn’t use much more than ~40MB of RAM.

## Download Netdata

To download this software, you can head over to [Netdata GitHub](https://github.com/firehol/netdata) page. Then click the “*Clone or download*” green button on the left of the page. You should then be presented with two options.

#### Via the ZIP file

One option is to download the ZIP file. This will include everything in the repository; however, if the repository is updated then you will need to download the ZIP file again. Once you download the ZIP file, you can use the

tool in the command line to extract the contents. Running the following command will extract the contents of the ZIP file into a ”

” folder.

$ cd ~/Downloads $ unzip netdata-master.zip

You don’t need to add the

option in

because their content is inside a folder at the root of the ZIP file. If they didn’t have that folder at the root,

would have extracted the contents in the current directory (which can be messy).

#### Via git

The next option is to download the repository via

. You will, of course, need git installed on your system. This is usually installed by default on Fedora. If not, you can install git from the command line with the following command.

$ sudo dnf install git

After installing

, you will need to “clone” the repository to your system. To do this, run the following command.

$ git clone[https://github.com/firehol/netdata.git]

This will then clone (or make a copy of) the repository in the current working directory.

## Install Netdata

There are some packages you will need to build Netdata successfully. Luckily, it’s a single line to install the things you need ([as stated in their installation guide](https://github.com/firehol/netdata/wiki/Installation)). Running the following command in the terminal will install all of the dependencies you need to use Netdata.

$ dnf install zlib-devel libuuid-devel libmnl-devel gcc make git autoconf autogen automake pkgconfig

Once the required packages are installed, you will need to

into the

directory and run the

script.

$ sudo ./netdata-installer.sh

You will then be prompted to press enter to build and install the program. If you wish to continue, press enter to be on your way!

If all goes well, you will have Netdata built, installed, and running on your system. The installer will also add an uninstall script in the same folder as the installer called

. If you change your mind later, running this script will remove it from your system.

You can see it running by checking its status via

.

$ sudo systemctl status netdata

## Accessing Netdata

Now that we have Netdata installed and running, you can access the web interface via port 19999. I have it running on a test machine, as shown in the screenshot below.

Congratulations! You now have successfully installed and have access to beautiful displays, graphs, and advanced statistics on the performance of your machine. Whether it’s for a personal machine so you can show it off to your friends or for getting deeper insight into the performance of your server, Netdata delivers on performance reporting for any system you choose.

*Image courtesy Mitchel Boot – originally posted to *

**Unsplash**here.

## Kiara Navarro

This is a really wonderful tool and I recommend to use it cause it’s worthy.

Thanks for share,

## Frank Ch. Eigler

“The web front-end is very responsive and requires no plugins like Flash or even JavaScript. ”

Might want to double-check on that. I only see a richly javascripty UI on the my-netdata.io demo pages.

## Paul W. Frields

@Frank: Thanks, I’ve edited that statement.

## Travis Mattila

The guide worked 99.99% for me, when i ran (sudo ./netdata-installed.sh) i got error messages (yes i have sudo enabled) to make it work i had to do su and then ran the .sh and it loaded.

Thanks for the guide, it was very clear and easy.

## Aaron Rumbold

There’s a typo in the installer line:

$ sudo ./netdata-installed.sh

## Edward

why not just systemctl enable cockpit

## Paul W. Frields

@Edward: Cockpit is also a great way to monitor system resources. The Magazine isn’t about only giving you one way to do things. We know there are many tools and utilities for some jobs, and try to show you more than one way to peel a potato.

## mosquito

Fast install netdata:

$ sudo dnf copr enable mosquito/netdata

$ sudo dnf install netdata

$ sudo systemctl start netdata.service

Visit http://localhost:19999

This Copr repository has supported el6, el7, fc22-25. Please see https://copr.fedorainfracloud.org/coprs/mosquito/netdata/

## Rafael Reuber

Hey mosquito, your repository is awesome! Its already have the last version of netdata.

Thank you for share!

## Tony Tyson

This is absolutely gorgeous.

## Tom Bates

Can’t access from my PC…. URL = http://192.168.0.19:19999/

I can access Cockpit… URL = https://192.168.0.19:9090/

I tried with https, no go….

Ideas?

## Paul W. Frields

Try these commands: