Netdata 介绍

它是 Linux 系统实时性能监测工具,以 web 的可视化方式展示系统及应用程序的实时运行状态(包括 cpu、内存、硬盘输入/输出、网络等 linux 性能的数据)。Netdata 的 web 前端响应很快,而且不需要 Flash 插件。 UI 很整洁,保持着 Netdata 应有的特性。第一眼看上去,你能够看到很多图表,幸运的是绝大多数常用的图表数据(像 CPU,RAM,网络和硬盘)都在顶部。如果你想深入了解图形化数据,你只需要下滑滚动条,或者点击在右边菜单的项目。通过每个图表的右下方的按钮,Netdata 还能控制图表的显示,重置,缩放。

Netdata 用可视化的手段,将被监测者最细微的细节,展现了出来。这样便可以清晰地了解 linux 系统和应用程序此时的状况。
监测内容:下面是 Netdata 目前检测的内容(大多数都不需要进行配置,安装后即可开始监测)

安装配置

[sks@localhost ~]$ sudo yum -y install wget
[sks@localhost /]$ sudo yum install autoconf automake curl gcc git libmnl-devel libuuid-devel lm_sensors make MySQL-python nc pkgconfig python python-psycopg2 PyYAML zlib-devel
[sks@localhost /]$ cd /usr/local/src/
[sks@localhost src]$ sudo wget https://github.com/netdata/netdata/releases/download/v1.10.0/netdata-1.10.0.tar.gz
[sks@localhost src]$ sudo tar zxvf netdata-1.10.0.tar.gz
[sks@localhost src]$ cd netdata-1.10.0
[sks@localhost netdata-1.10.0]$ sudo ./netdata-installer.sh

资源监控


监控 MYSQL 服务

[sks@localhost ~]$ systemctl start netdata
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: sks
Password:
==== AUTHENTICATION COMPLETE ===
[sks@localhost ~]$ systemctl start netdata
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: sks
Password:
==== AUTHENTICATION COMPLETE ===
[sks@localhost ~]$ sudo yum install mariadb-server mariadb
[sudo] sks 的密码:
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 mariadb.x86_64.1.5.5.60-1.el7_5 将被 安装
---> 软件包 mariadb-server.x86_64.1.5.5.60-1.el7_5 将被 安装
--> 正在处理依赖关系 perl-DBI,它被软件包 1:mariadb-server-5.5.60-1.el7_5.x86_64 需要
--> 正在处理依赖关系 perl-DBD-MySQL,它被软件包 1:mariadb-server-5.5.60-1.el7_5.x86_64 需要
--> 正在处理依赖关系 perl(DBI),它被软件包 1:mariadb-server-5.5.60-1.el7_5.x86_64 需要
--> 正在检查事务
---> 软件包 perl-DBD-MySQL.x86_64.0.4.023-6.el7 将被 安装
---> 软件包 perl-DBI.x86_64.0.1.627-4.el7 将被 安装
--> 正在处理依赖关系 perl(RPC::PlServer) >= 0.2001,它被软件包 perl-DBI-1.627-4.el7.x86_64 需要
--> 正在处理依赖关系 perl(RPC::PlClient) >= 0.2000,它被软件包 perl-DBI-1.627-4.el7.x86_64 需要
--> 正在检查事务
---> 软件包 perl-PlRPC.noarch.0.0.2020-14.el7 将被 安装
--> 正在处理依赖关系 perl(Net::Daemon) >= 0.13,它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Net::Daemon::Test),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Net::Daemon::Log),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Compress::Zlib),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在检查事务
---> 软件包 perl-IO-Compress.noarch.0.2.061-2.el7 将被 安装
--> 正在处理依赖关系 perl(Compress::Raw::Zlib) >= 2.061,它被软件包 perl-IO-Compress-2.061-2.el7.noarch 需要
--> 正在处理依赖关系 perl(Compress::Raw::Bzip2) >= 2.061,它被软件包 perl-IO-Compress-2.061-2.el7.noarch 需要
---> 软件包 perl-Net-Daemon.noarch.0.0.48-5.el7 将被 安装
--> 正在检查事务
---> 软件包 perl-Compress-Raw-Bzip2.x86_64.0.2.061-3.el7 将被 安装
---> 软件包 perl-Compress-Raw-Zlib.x86_64.1.2.061-4.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================================================================================================
 Package                                         架构                           版本                                      源                               大小
================================================================================================================================================================
正在安装:
 mariadb                                         x86_64                         1:5.5.60-1.el7_5                          updates                         8.9 M
 mariadb-server                                  x86_64                         1:5.5.60-1.el7_5                          updates                          11 M
为依赖而安装:
 perl-Compress-Raw-Bzip2                         x86_64                         2.061-3.el7                               base                             32 k
 perl-Compress-Raw-Zlib                          x86_64                         1:2.061-4.el7                             base                             57 k
 perl-DBD-MySQL                                  x86_64                         4.023-6.el7                               base                            140 k
 perl-DBI                                        x86_64                         1.627-4.el7                               base                            802 k
 perl-IO-Compress                                noarch                         2.061-2.el7                               base                            260 k
 perl-Net-Daemon                                 noarch                         0.48-5.el7                                base                             51 k
 perl-PlRPC                                      noarch                         0.2020-14.el7                             base                             36 k

事务概要
================================================================================================================================================================
安装  2 软件包 (+7 依赖软件包)

总下载量:21 M
安装大小:110 M
Is this ok [y/d/N]: y
Downloading packages:
(1/9): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm                                                                                    |  32 kB  00:00:00
(2/9): perl-DBD-MySQL-4.023-6.el7.x86_64.rpm                                                                                             | 140 kB  00:00:00
(3/9): perl-IO-Compress-2.061-2.el7.noarch.rpm                                                                                           | 260 kB  00:00:00
(4/9): perl-Net-Daemon-0.48-5.el7.noarch.rpm                                                                                             |  51 kB  00:00:00
(5/9): perl-PlRPC-0.2020-14.el7.noarch.rpm                                                                                               |  36 kB  00:00:00
(6/9): perl-DBI-1.627-4.el7.x86_64.rpm                                                                                                   | 802 kB  00:00:00
(7/9): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm                                                                                     |  57 kB  00:00:09
(8/9): mariadb-5.5.60-1.el7_5.x86_64.rpm                                                                                                 | 8.9 MB  00:00:11
(9/9): mariadb-server-5.5.60-1.el7_5.x86_64.rpm                                                                                          |  11 MB  00:00:12
----------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                            1.7 MB/s |  21 MB  00:00:12
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                  1/9
  正在安装    : 1:mariadb-5.5.60-1.el7_5.x86_64                                                                                                             2/9
  正在安装    : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                 3/9
  正在安装    : perl-IO-Compress-2.061-2.el7.noarch                                                                                                         4/9
  正在安装    : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                           5/9
  正在安装    : perl-PlRPC-0.2020-14.el7.noarch                                                                                                             6/9
  正在安装    : perl-DBI-1.627-4.el7.x86_64                                                                                                                 7/9
  正在安装    : perl-DBD-MySQL-4.023-6.el7.x86_64                                                                                                           8/9
  正在安装    : 1:mariadb-server-5.5.60-1.el7_5.x86_64                                                                                                      9/9
  验证中      : 1:mariadb-server-5.5.60-1.el7_5.x86_64                                                                                                      1/9
  验证中      : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                           2/9
  验证中      : perl-DBD-MySQL-4.023-6.el7.x86_64                                                                                                           3/9
  验证中      : perl-IO-Compress-2.061-2.el7.noarch                                                                                                         4/9
  验证中      : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                 5/9
  验证中      : 1:mariadb-5.5.60-1.el7_5.x86_64                                                                                                             6/9
  验证中      : perl-DBI-1.627-4.el7.x86_64                                                                                                                 7/9
  验证中      : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                  8/9
  验证中      : perl-PlRPC-0.2020-14.el7.noarch                                                                                                             9/9

已安装:
  mariadb.x86_64 1:5.5.60-1.el7_5                                             mariadb-server.x86_64 1:5.5.60-1.el7_5

作为依赖被安装:
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7  perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7  perl-DBD-MySQL.x86_64 0:4.023-6.el7  perl-DBI.x86_64 0:1.627-4.el7
  perl-IO-Compress.noarch 0:2.061-2.el7         perl-Net-Daemon.noarch 0:0.48-5.el7          perl-PlRPC.noarch 0:0.2020-14.el7

完毕!

[sks@localhost ~]$ rpm -qa|grep mariadb
mariadb-5.5.60-1.el7_5.x86_64
mariadb-libs-5.5.60-1.el7_5.x86_64
mariadb-server-5.5.60-1.el7_5.x86_64
[sks@localhost ~]$ systemctl start mariadb
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: sks
Password:
==== AUTHENTICATION COMPLETE ===
[sks@localhost ~]$ ps -ef |grep mysql
mysql      4925      1  0 16:53 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql      5086   4925  0 16:53 ?        00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/                                                var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
sks        5414   5260  0 17:00 pts/1    00:00:00 grep --color=auto mysql
[sks@localhost ~]$ mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> exit;
Bye

[sks@localhost ~]$ systemctl restart netdata
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: sks
Password:
==== AUTHENTICATION COMPLETE ===
[sks@localhost ~]$

参考资料

https://github.com/netdata/netdata/wiki/Installation

环境依赖

Prepare your system

# Debian / Ubuntu
apt-get install zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autoconf-archive autogen automake pkg-config curl

# Fedora
dnf install zlib-devel libuuid-devel libmnl-devel gcc make git autoconf autoconf-archive autogen automake pkgconfig curl findutils

# CentOS / Red Hat Enterprise Linux
yum install autoconf automake curl gcc git libmnl-devel libuuid-devel lm_sensors make MySQL-python nc pkgconfig python python-psycopg2 PyYAML zlib-devel

Install netdata

# download it - the directory 'netdata' will be created
git clone https://github.com/netdata/netdata.git --depth=1
cd netdata

# run script with root privileges to build, install, start netdata
./netdata-installer.sh

starting netdata at boot

In the system directory you can find scripts and configurations for the various distros.

systemd
# stop netdata
killall netdata

# copy netdata.service to systemd
cp system/netdata.service /etc/systemd/system/

# let systemd know there is a new service
systemctl daemon-reload

# enable netdata at boot
systemctl enable netdata

# start netdata
systemctl start netdata

CentOS / Red Hat Enterprise Linux

For older versions of RHEL/CentOS that don't have systemd, an init script is included in the system directory. This can be installed by running the following commands as root.

# copy the netdata startup file to /etc/init.d
cp system/netdata-init-d /etc/init.d/netdata

# make sure it is executable
chmod +x /etc/init.d/netdata

# enable it
chkconfig --add netdata

补充另一个小工具:Grafana

Grafana 是一个开源的度量分析与可视化套件。经常被用作基础设施的时间序列数据和应用程序分析的可视化,它在其他领域也被广泛的使用包括工业传感器、家庭自动化、天气和过程控制等。
Grafana 支持许多不同的数据源。每个数据源都有一个特定的查询编辑器,该编辑器定制的特性和功能是公开的特定数据来源。

链接地址

http://docs.grafana.org/installation/

参数说明

安装配置

可以直接使用 Yum 安装 Grafana

[sks@localhost ~]$ sudo yum install https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.1.4-1.x86_64.rpm

启动服务器(init.d 服务)
可以通过运行来启动 Grafana:

[sks@localhost ~]$ sudo service grafana-server start

这将以包安装期间创建 grafana-server 的 grafana 用户身份启动进程。默认 HTTP 端口是 3000,默认用户和组是 admin。
默认登录名和密码 admin/admin

要将 Grafana 服务器配置为在引导时启动:

[sks@localhost ~]$ sudo /sbin/chkconfig --add grafana-server

启动与关闭服务器(通过 systemd)

[sks@localhost /]$ sudo systemctl daemon-reload
[sks@localhost /]$ sudo systemctl start grafana-server
[sks@localhost /]$ sudo systemctl stop grafana-server
[sks@localhost /]$ sudo systemctl status grafana-server

启用 systemd 服务以启动时启动

[sks@localhost ~]$sudo systemctl enable grafana-server.service

运行结果




↙↙↙阅读原文可查看相关链接,并与作者交流