IT基础设施:使用netdata监控CentOS7性能

背景

作为一个Linux狗,必须要掌握一个专门的系统监控工具,能随时了解系统资源的占用情况,如应用的内存使用规律,应用的网络峰值时段,CPU使用情况等信息,对优化应用性能,保证服务器健康运行有着极为重要的作用。

工具

netdata

Netdata是一款秒级数据收集与可视化呈现的Linux服务器性能监测工具,他具有这样一些特性:

  • 高实时性:Netdata是用纯C编写的,关键系统插件也是用C语言编写的。 它的速度只能与本机控制台系统管理工具进行比较。当netdata在现代计算机上运行时(即使在CELERON处理器上),大多数图表查询都会在不到3毫秒的时间内得到回复!
  • 不占用系统IO:除了日志系统外,netdata将不会使用任何磁盘的IO资源,您也可以通过配置文件禁用掉日志系统。
  • 不需要root权限
  • 自带Web服务系统
  • 开箱即用,上手不需要写任何配置
  • 可视化的QOS
  • 安装便捷,根据安装文档指示,有些系统可以直接从软件库中安装,树莓派上我通过克隆安装成功,CentOS上有一键安装脚本
  • 告警系统,通过配置文件,我们可以配置netdata在某些指标达到阀值的时候进行告警。

nginx

鼎鼎大名的代理服务器,不用多说。

过程

本次安装的机器是CentOS7 64位,我们选择64位的安装脚本

bash <(curl -Ss https://my-netdata.io/kickstart-static64.sh) 

接下来它会自动下载安装包

 --- Checking the latest version of static build... --- 
[/home]# /usr/bin/curl https://raw.githubusercontent.com/firehol/binary-packages/master/netdata-latest.gz.run 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    59  100    59    0     0     51      0  0:00:01  0:00:01 --:--:--    51
 OK   

 --- Downloading static netdata binary: netdata-v1.10.0-531-g8f851356-x86_64-20180727-042835.gz.run --- 
[/home]# /usr/bin/curl https://raw.githubusercontent.com/firehol/binary-packages/master/netdata-v1.10.0-531-g8f851356-x86_64-20180727-042835.gz.run 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 5602k  100 5602k    0     0  19712      0  0:04:51  0:04:51 --:--:-- 32001
 OK   

 --- Installing netdata --- 
[/home]# sh /tmp/netdata-v1.10.0-531-g8f851356-x86_64-20180727-042835.gz.run 

  ^
  |.-.   .-.   .-.   .-.   .  netdata                                        
  |   '-'   '-'   '-'   '-'   real-time performance monitoring, done right!  
  +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->

  (C) Copyright 2017, Costa Tsaousis
  All rights reserved
  Released under GPL v3+

  You are about to install netdata to this system.
  netdata will be installed at:

                    /opt/netdata

  The following changes will be made to your system:

  # USERS / GROUPS
  User 'netdata' and group 'netdata' will be added, if not present.

  # LOGROTATE
  This file will be installed if logrotate is present.

   - /etc/logrotate.d/netdata

  # SYSTEM INIT
  This file will be installed if this system runs with systemd:

   - /etc/systemd/system/netdata.service 

   or, for older Centos, Debian/Ubuntu or OpenRC Gentoo:

   - /etc/init.d/netdata         will be created

  
  This package can also update a netdata installation that has been
  created with another version of it.

  Your netdata configuration will be retained.
  After installation, netdata will be (re-)started.

  netdata re-distributes a lot of open source software components.
  Check its full license at:
  https://github.com/firehol/netdata/blob/master/LICENSE.md
Please type y to accept, n otherwise: 

输入y确认安装,下面列出了详细的安装过程。

Creating directory /opt/netdata
Verifying archive integrity...  100%   All good.
Uncompressing netdata, the real-time performance and health monitoring system  100%  
 --- Checking new configuration files --- 
[/opt/netdata]# mkdir -p etc/netdata 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d.conf etc/netdata/node.d.conf 
 OK   

[/opt/netdata]# mkdir -p etc/netdata/health.d 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/nginx.conf etc/netdata/health.d/nginx.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/tcp_listen.conf etc/netdata/health.d/tcp_listen.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/zfs.conf etc/netdata/health.d/zfs.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/apache.conf etc/netdata/health.d/apache.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/named.conf etc/netdata/health.d/named.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/nginx_plus.conf etc/netdata/health.d/nginx_plus.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/squid.conf etc/netdata/health.d/squid.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/udp_errors.conf etc/netdata/health.d/udp_errors.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/tcp_resets.conf etc/netdata/health.d/tcp_resets.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/portcheck.conf etc/netdata/health.d/portcheck.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/elasticsearch.conf etc/netdata/health.d/elasticsearch.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/ceph.conf etc/netdata/health.d/ceph.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/isc_dhcpd.conf etc/netdata/health.d/isc_dhcpd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/bcache.conf etc/netdata/health.d/bcache.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/qos.conf etc/netdata/health.d/qos.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/stiebeleltron.conf etc/netdata/health.d/stiebeleltron.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/retroshare.conf etc/netdata/health.d/retroshare.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/mysql.conf etc/netdata/health.d/mysql.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/beanstalkd.conf etc/netdata/health.d/beanstalkd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/postgres.conf etc/netdata/health.d/postgres.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/tcp_orphans.conf etc/netdata/health.d/tcp_orphans.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/haproxy.conf etc/netdata/health.d/haproxy.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/entropy.conf etc/netdata/health.d/entropy.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/cpu.conf etc/netdata/health.d/cpu.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/ipfs.conf etc/netdata/health.d/ipfs.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/varnish.conf etc/netdata/health.d/varnish.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/disks.conf etc/netdata/health.d/disks.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/tcp_conn.conf etc/netdata/health.d/tcp_conn.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/btrfs.conf etc/netdata/health.d/btrfs.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/lighttpd.conf etc/netdata/health.d/lighttpd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/net.conf etc/netdata/health.d/net.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/softnet.conf etc/netdata/health.d/softnet.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/redis.conf etc/netdata/health.d/redis.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/web_log.conf etc/netdata/health.d/web_log.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/memory.conf etc/netdata/health.d/memory.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/ipmi.conf etc/netdata/health.d/ipmi.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/ram.conf etc/netdata/health.d/ram.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/netfilter.conf etc/netdata/health.d/netfilter.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/tcp_mem.conf etc/netdata/health.d/tcp_mem.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/mongodb.conf etc/netdata/health.d/mongodb.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/boinc.conf etc/netdata/health.d/boinc.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/swap.conf etc/netdata/health.d/swap.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/backend.conf etc/netdata/health.d/backend.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/ipc.conf etc/netdata/health.d/ipc.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/fronius.conf etc/netdata/health.d/fronius.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/apcupsd.conf etc/netdata/health.d/apcupsd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/mdstat.conf etc/netdata/health.d/mdstat.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/couchdb.conf etc/netdata/health.d/couchdb.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/memcached.conf etc/netdata/health.d/memcached.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/megacli.conf etc/netdata/health.d/megacli.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/fping.conf etc/netdata/health.d/fping.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/httpcheck.conf etc/netdata/health.d/httpcheck.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health.d/bind_rndc.conf etc/netdata/health.d/bind_rndc.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d.conf etc/netdata/python.d.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health_alarm_notify.conf etc/netdata/health_alarm_notify.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/health_email_recipients.conf etc/netdata/health_email_recipients.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/apps_groups.conf etc/netdata/apps_groups.conf 
 OK   

[/opt/netdata]# mkdir -p etc/netdata/python.d 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/nginx.conf etc/netdata/python.d/nginx.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/dovecot.conf etc/netdata/python.d/dovecot.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/apache.conf etc/netdata/python.d/apache.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/exim.conf etc/netdata/python.d/exim.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/rabbitmq.conf etc/netdata/python.d/rabbitmq.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/spigotmc.conf etc/netdata/python.d/spigotmc.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/nginx_plus.conf etc/netdata/python.d/nginx_plus.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/squid.conf etc/netdata/python.d/squid.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/w1sensor.conf etc/netdata/python.d/w1sensor.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/tomcat.conf etc/netdata/python.d/tomcat.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/fail2ban.conf etc/netdata/python.d/fail2ban.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/postfix.conf etc/netdata/python.d/postfix.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/powerdns.conf etc/netdata/python.d/powerdns.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/ntpd.conf etc/netdata/python.d/ntpd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/portcheck.conf etc/netdata/python.d/portcheck.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/dns_query_time.conf etc/netdata/python.d/dns_query_time.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/elasticsearch.conf etc/netdata/python.d/elasticsearch.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/freeradius.conf etc/netdata/python.d/freeradius.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/ceph.conf etc/netdata/python.d/ceph.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/isc_dhcpd.conf etc/netdata/python.d/isc_dhcpd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/nsd.conf etc/netdata/python.d/nsd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/logind.conf etc/netdata/python.d/logind.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/samba.conf etc/netdata/python.d/samba.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/retroshare.conf etc/netdata/python.d/retroshare.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/phpfpm.conf etc/netdata/python.d/phpfpm.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/mysql.conf etc/netdata/python.d/mysql.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/smartd_log.conf etc/netdata/python.d/smartd_log.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/postgres.conf etc/netdata/python.d/postgres.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/haproxy.conf etc/netdata/python.d/haproxy.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/cpufreq.conf etc/netdata/python.d/cpufreq.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/ipfs.conf etc/netdata/python.d/ipfs.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/varnish.conf etc/netdata/python.d/varnish.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/hddtemp.conf etc/netdata/python.d/hddtemp.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/puppet.conf etc/netdata/python.d/puppet.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/unbound.conf etc/netdata/python.d/unbound.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/redis.conf etc/netdata/python.d/redis.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/web_log.conf etc/netdata/python.d/web_log.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/dnsdist.conf etc/netdata/python.d/dnsdist.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/mongodb.conf etc/netdata/python.d/mongodb.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/boinc.conf etc/netdata/python.d/boinc.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/springboot.conf etc/netdata/python.d/springboot.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/litespeed.conf etc/netdata/python.d/litespeed.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/icecast.conf etc/netdata/python.d/icecast.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/example.conf etc/netdata/python.d/example.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/mdstat.conf etc/netdata/python.d/mdstat.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/couchdb.conf etc/netdata/python.d/couchdb.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/chrony.conf etc/netdata/python.d/chrony.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/memcached.conf etc/netdata/python.d/memcached.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/megacli.conf etc/netdata/python.d/megacli.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/traefik.conf etc/netdata/python.d/traefik.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/httpcheck.conf etc/netdata/python.d/httpcheck.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/ovpn_status_log.conf etc/netdata/python.d/ovpn_status_log.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/sensors.conf etc/netdata/python.d/sensors.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/bind_rndc.conf etc/netdata/python.d/bind_rndc.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/go_expvar.conf etc/netdata/python.d/go_expvar.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/python.d/beanstalk.conf etc/netdata/python.d/beanstalk.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d.conf etc/netdata/charts.d.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/stream.conf etc/netdata/stream.conf 
 OK   

[/opt/netdata]# mkdir -p etc/netdata/statsd.d 
 OK   

[/opt/netdata]# cp etc.new/netdata/statsd.d/example.conf etc/netdata/statsd.d/example.conf 
 OK   

[/opt/netdata]# mkdir -p etc/netdata/node.d 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d/named.conf.md etc/netdata/node.d/named.conf.md 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d/README.md etc/netdata/node.d/README.md 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d/sma_webbox.conf.md etc/netdata/node.d/sma_webbox.conf.md 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d/stiebeleltron.conf.md etc/netdata/node.d/stiebeleltron.conf.md 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d/snmp.conf.md etc/netdata/node.d/snmp.conf.md 
 OK   

[/opt/netdata]# cp etc.new/netdata/node.d/fronius.conf.md etc/netdata/node.d/fronius.conf.md 
 OK   

[/opt/netdata]# mkdir -p etc/netdata/charts.d 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/nginx.conf etc/netdata/charts.d/nginx.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/nut.conf etc/netdata/charts.d/nut.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/libreswan.conf etc/netdata/charts.d/libreswan.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/apache.conf etc/netdata/charts.d/apache.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/exim.conf etc/netdata/charts.d/exim.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/squid.conf etc/netdata/charts.d/squid.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/tomcat.conf etc/netdata/charts.d/tomcat.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/postfix.conf etc/netdata/charts.d/postfix.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/phpfpm.conf etc/netdata/charts.d/phpfpm.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/mysql.conf etc/netdata/charts.d/mysql.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/cpufreq.conf etc/netdata/charts.d/cpufreq.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/hddtemp.conf etc/netdata/charts.d/hddtemp.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/cpu_apps.conf etc/netdata/charts.d/cpu_apps.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/load_average.conf etc/netdata/charts.d/load_average.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/opensips.conf etc/netdata/charts.d/opensips.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/apcupsd.conf etc/netdata/charts.d/apcupsd.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/example.conf etc/netdata/charts.d/example.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/mem_apps.conf etc/netdata/charts.d/mem_apps.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/ap.conf etc/netdata/charts.d/ap.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/charts.d/sensors.conf etc/netdata/charts.d/sensors.conf 
 OK   

[/opt/netdata]# cp etc.new/netdata/fping.conf etc/netdata/fping.conf 
 OK   

[/opt/netdata]# rm -rf etc.new 
 OK   

 --- Add user netdata to required user groups --- 
Adding netdata user group ...
[/opt/netdata]# groupadd -r netdata 
 OK   

Adding netdata user account with home /opt/netdata ...
[/opt/netdata]# useradd -r -g netdata -c netdata -s /usr/sbin/nologin --no-create-home -d /opt/netdata netdata 
 OK   

Group 'docker' does not exist.
Adding netdata user to the nginx group ...
[/opt/netdata]# usermod -a -G nginx netdata 
 OK   

Group 'varnish' does not exist.
Group 'haproxy' does not exist.
Adding netdata user to the adm group ...
[/opt/netdata]# usermod -a -G adm netdata 
 OK   

Group 'nsd' does not exist.
Group 'proxy' does not exist.
Group 'squid' does not exist.
Group 'ceph' does not exist.
Adding netdata user to the nobody group ...
[/opt/netdata]# usermod -a -G nobody netdata 
 OK   

 --- Check SSL certificates paths --- 
Creating /opt/netdata/.curlrc with cacert=/etc/ssl/certs/ca-bundle.crt
 --- Install logrotate configuration for netdata --- 
[/opt/netdata]# cp system/netdata.logrotate /etc/logrotate.d/netdata 
 OK   

[/opt/netdata]# chmod 644 /etc/logrotate.d/netdata 
 OK   

 --- Install netdata at system init --- 
Installing systemd service...
[/opt/netdata]# cp system/netdata.service /etc/systemd/system/netdata.service 
 OK   

[/opt/netdata]# systemctl daemon-reload 
 OK   

[/opt/netdata]# systemctl enable netdata 
Created symlink from /etc/systemd/system/multi-user.target.wants/netdata.service to /etc/systemd/system/netdata.service.
 OK   

 --- creating quick links --- 
[/opt/netdata]# ln -s bin sbin 
 OK   

[/opt/netdata/usr]# ln -s ../bin bin 
 OK   

[/opt/netdata/usr]# ln -s ../bin sbin 
 OK   

[/opt/netdata/usr]# ln -s . local 
 OK   

[/opt/netdata]# ln -s etc/netdata netdata-configs 
 OK   

[/opt/netdata]# ln -s usr/share/netdata/web netdata-web-files 
 OK   

[/opt/netdata]# ln -s usr/libexec/netdata netdata-plugins 
 OK   

[/opt/netdata]# ln -s var/lib/netdata netdata-dbs 
 OK   

[/opt/netdata]# ln -s var/cache/netdata netdata-metrics 
 OK   

[/opt/netdata]# ln -s var/log/netdata netdata-logs 
 OK   

 --- fix permissions --- 
[/opt/netdata]# chmod g+rx\,o+rx /opt 
 OK   

[/opt/netdata]# chown -R netdata:netdata /opt/netdata 
 OK   

 --- fix plugin permissions --- 
[/opt/netdata]# chown root:netdata usr/libexec/netdata/plugins.d/apps.plugin 
 OK   

[/opt/netdata]# chmod 4750 usr/libexec/netdata/plugins.d/apps.plugin 
 OK   

[/opt/netdata]# chown root:netdata usr/libexec/netdata/plugins.d/cgroup-network 
 OK   

[/opt/netdata]# chmod 4750 usr/libexec/netdata/plugins.d/cgroup-network 
 OK   

[/opt/netdata]# chown root:netdata bin/fping 
 OK   

[/opt/netdata]# chmod 4750 bin/fping 
 OK   

 --- starting netdata --- 
 --- Start netdata --- 
[/opt/netdata]# /usr/bin/systemctl stop netdata 
 OK   

[/opt/netdata]# /usr/bin/systemctl restart netdata 
 OK   


-------------------------------------------------------------------------------

Downloading default configuration from netdata...
[/opt/netdata]# curl -s -o /opt/netdata/etc/netdata/netdata.conf.new http://localhost:19999/netdata.conf 
 OK   

[/opt/netdata]# mv /opt/netdata/etc/netdata/netdata.conf.new /opt/netdata/etc/netdata/netdata.conf 
 OK   

 OK  New configuration saved for you to edit at /opt/netdata/etc/netdata/netdata.conf 

[/opt/netdata]# chown netdata:netdata /opt/netdata/etc/netdata/netdata.conf 
 OK   

[/opt/netdata]# chmod 0664 /opt/netdata/etc/netdata/netdata.conf 
 OK   


  ^
  |.-.   .-.   .-.   .-.   .-.   .  netdata                          .-.   .-
  |   '-'   '-'   '-'   '-'   '-'   is installed and running now!  -'   '-'  
  +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->

 OK   


安装后默认是通过http://xxx:19999/访问

由于netdata没有帐号密码体系,为保护服务器隐私,我们要使用nginx反代,通过域名访问,并使用账号密码授权。

首先,我们安装apache工具集,我们需要其中的htpasswd为我们生成用户信息(PS:网上找到的资料是apache2-utils,但我们在CentOS7的源中已经搜索不到这个包)。

yum install httpd-tools -y

安装过程如下:

Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-80.el7.centos.1 will be installed
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-tools-2.4.6-80.el7.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-tools-2.4.6-80.el7.centos.1.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================
 Package                              Arch                            Version                                        Repository                        Size
============================================================================================================================================================
Installing:
 httpd-tools                          x86_64                          2.4.6-80.el7.centos.1                          updates                           90 k
Installing for dependencies:
 apr                                  x86_64                          1.4.8-3.el7_4.1                                os                               103 k
 apr-util                             x86_64                          1.5.2-6.el7                                    os                                92 k

Transaction Summary
============================================================================================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 285 k
Installed size: 584 k
Is this ok [y/d/N]: y
Downloading packages:
(1/3): apr-util-1.5.2-6.el7.x86_64.rpm                                                                                               |  92 kB  00:00:00     
(2/3): apr-1.4.8-3.el7_4.1.x86_64.rpm                                                                                                | 103 kB  00:00:00     
(3/3): httpd-tools-2.4.6-80.el7.centos.1.x86_64.rpm                                                                                  |  90 kB  00:00:00     
------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                       1.7 MB/s | 285 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7_4.1.x86_64                                                                                                               1/3 
  Installing : apr-util-1.5.2-6.el7.x86_64                                                                                                              2/3 
  Installing : httpd-tools-2.4.6-80.el7.centos.1.x86_64                                                                                                 3/3 
  Verifying  : httpd-tools-2.4.6-80.el7.centos.1.x86_64                                                                                                 1/3 
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                                                                                              2/3 
  Verifying  : apr-1.4.8-3.el7_4.1.x86_64                                                                                                               3/3 

Installed:
  httpd-tools.x86_64 0:2.4.6-80.el7.centos.1                                                                                                                

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7_4.1                                                 apr-util.x86_64 0:1.5.2-6.el7                                                

Complete!

接下来创建目录,创建账号


mkdir /usr/local/nginx
htpasswd -c /usr/local/nginx/passwd.db username
pwd
re-type pwd

添加一个nginx的配置vim /etc/nginx/conf.d/netdata.conf,内容如下

upstream netdatahttp
{
        server 127.0.0.1:19999;
}

server {

  listen *:80;
  server_name netdata.xxx.com;
  auth_basic "netdata";
  auth_basic_user_file /usr/local/nginx/passwd.db;

  location /
  {
        proxy_pass http://netdatahttp;

        proxy_redirect off;
        proxy_set_header        Host $host;
        proxy_set_header        X-Real_IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

打开域名测试一下效果

要求输入账号密码

输入密码后

总览
应用的内存使用情况

引用

1.netdata官方安装指南
2.Running behind nginx(通过 nginx 保护 netdata)
3.netdata开源地址

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,324评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,303评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,192评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,555评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,569评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,566评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,927评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,583评论 0 257
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,827评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,590评论 2 320
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,669评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,365评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,941评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,928评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,159评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,880评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,399评论 2 342