netdata became a great tool for admins to monitor in real time their servers!
At first it was just an additional not mandatory tool to check what’s going on with the servers for the last hour or so, but it evolved to really handy and informative monitoring server tracking every seconds what is going on with the server and server’s most used services like database, web, application service.
Today in version 1.9 (this installation howto is for netdata 1.9) it could track activity at least of this services:
apache hddtemp postgres beanstalk haproxy rabbitmq ceph isc_dhcpd retroshare bind_rndc ipfs redis couchdb memcached sensors chrony mdstat samba cpufreq mongodb squid dns_query_time nginx springboot dnsdist mysql smartd_log elasticsearch nsd tomcat dovecot nginx_plus web_log exim ovpn_status_log varnish example ntpd fronius freeradius postfix named fail2ban phpfpm snmp go_expvar powerdns stiebeleltron
And some of these plugins support multiple programs and services, for example web_log supports the access/error logs of the major web servers at the moment.
The installation is really simple netdata includes a script to facilitate the installation process.
Here are the minimal steps to install this great software:
STEP 1) Install dependencies, because will pull it from the official repository we also need git command
yum install -y git gcc make autoconf automake pkgconfig zlib-devel libuuid-devel curl nodejs freeipmi freeipmi-devel elfutils-libelf cmake openssl-devel libuv-devel
As you can see there is a nodejs packet, which depends on additional repository (you could skip this, just the modules, which depends on nodejs won’t work, as if now only the plugins using nodejs are located in “/etc/netdata/node.d/” and they are not so many).
yum -y install epel-release yum -y install nodejs
STEP 2) Clone the netdata repository
cd git clone https://github.com/firehol/netdata
STEP 3) Instal netdata
cd netdata CFLAGS="-march=native -O2 -msse3 -fomit-frame-pointer -pipe" ./netdata-installer.sh --install /usr/local/netdata
Install the netdata software in a separate directory and if you clean the system, just delete this directory. The example above uses
/usr/local/netdata
all files will be installed there.
As you can see the installation output the path of your files
- the daemon at /usr/local/netdata/netdata/usr/sbin/netdata - config files in /usr/local/netdata/netdata/etc/netdata - web files in /usr/local/netdata/netdata/usr/share/netdata - plugins in /usr/local/netdata/netdata/usr/libexec/netdata - cache files in /usr/local/netdata/netdata/var/cache/netdata - db files in /usr/local/netdata/netdata/var/lib/netdata - log files in /usr/local/netdata/netdata/var/log/netdata - pid file at /usr/local/netdata/netdata/var/run/netdata.pid - logrotate file at /etc/logrotate.d/netdata
STEP 4) USE firewall and open the port 19999 of your server to check e able to load the monitoring page
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="<YOURIP>" port protocol="tcp" port="19999" accept" firewall-cmd --add-rich-rule="rule family="ipv4" source address="<YOURIP>" port protocol="tcp" port="19999" accept"
Because firewalld is the default firewall under CentOS 7 we used it ot show you how to let your IP access netdata web – replace
* The installation process creates start/stop unit files for systemd and tells you how to update it (even you can run it automatically in a cron job)
To stop netdata run: systemctl stop netdata To start netdata run: systemctl start netdata Uninstall script generated: ./netdata-uninstaller.sh Update script generated : ./netdata-updater.sh netdata-updater.sh can work from cron. It will trigger an email from cron only if it fails (it does not print anything when it can update netdata). Run this to automatically check and install netdata updates once per day: sudo ln -s /root/netdata/netdata-updater.sh /etc/cron.daily/netdata-updater
* Here is the output of an installation help menu – it also hints the dependencies it may need:
[root@srv.local netdata]# ./netdata-installer.sh --help ^ |.-. .-. .-. .-. .-. . netdata .-. .- | '-' '-' '-' '-' '-' installer command line options ' '-' +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+---> ./netdata-installer.sh <installer options> Valid <installer options> are: --install /PATH/TO/INSTALL If you give: --install /opt netdata will be installed in /opt/netdata --dont-start-it Do not (re)start netdata. Just install it. --dont-wait Do not wait for the user to press ENTER. Start immediately building it. --auto-update | -u Install netdata-updater to cron, to update netdata automatically once per day (can only be done for installations from git) --enable-plugin-freeipmi --disable-plugin-freeipmi Enable/disable the FreeIPMI plugin. Default: enable it when libipmimonitoring is available. --enable-plugin-nfacct --disable-plugin-nfacct Enable/disable the nfacct plugin. Default: enable it when libmnl and libnetfilter_acct are available. --enable-lto --disable-lto Enable/disable Link-Time-Optimization Default: enabled --zlib-is-really-here --libs-are-really-here If you get errors about missing zlib, or libuuid but you know it is available, you have a broken pkg-config. Use this option to allow it continue without checking pkg-config. Netdata will by default be compiled with gcc optimization -O2 If you need to pass different CFLAGS, use something like this: CFLAGS="<gcc options>" ./netdata-installer.sh <installer options> For the installer to complete successfully, you will need these packages installed: gcc make autoconf automake pkg-config zlib1g-dev (or zlib-devel) uuid-dev (or libuuid-devel) For the plugins, you will at least need: curl, bash v4+, python v2 or v3, node.js
* netdata in action
* And here is the output of an installation process:
[root@lsrv3 netdata]# CFLAGS="-march=native -O2 -msse3 -fomit-frame-pointer -pipe" ./netdata-installer.sh --install /usr/local/netdata ^ |.-. .-. .-. .-. . netdata | '-' '-' '-' '-' real-time performance monitoring, done right! +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+---> You are about to build and install netdata to your system. It will be installed at these locations: - the daemon at /usr/local/netdata/netdata/usr/sbin/netdata - config files in /usr/local/netdata/netdata/etc/netdata - web files in /usr/local/netdata/netdata/usr/share/netdata - plugins in /usr/local/netdata/netdata/usr/libexec/netdata - cache files in /usr/local/netdata/netdata/var/cache/netdata - db files in /usr/local/netdata/netdata/var/lib/netdata - log files in /usr/local/netdata/netdata/var/log/netdata - pid file at /usr/local/netdata/netdata/var/run/netdata.pid - logrotate file at /etc/logrotate.d/netdata This installer allows you to change the installation path. Press Control-C and run the same command with --help for help. Press ENTER to build and install netdata to '/usr/local/netdata/netdata' > --- Run autotools to configure the build environment --- [/root/netdata]# ./autogen.sh autoreconf: Entering directory `.' autoreconf: configure.ac: not using Gettext autoreconf: running: aclocal --force -I m4 autoreconf: configure.ac: tracing autoreconf: configure.ac: not using Libtool autoreconf: running: /usr/bin/autoconf --force autoreconf: running: /usr/bin/autoheader --force autoreconf: running: automake --add-missing --copy --force-missing autoreconf: Leaving directory `.' OK [/root/netdata]# ./configure --prefix=/usr/local/netdata/netdata/usr --sysconfdir=/usr/local/netdata/netdata/etc --localstatedir=/usr/local/netdata/netdata/var --with-zlib --with-math --with-user=netdata CFLAGS=-march=native\ -O2\ -msse3\ -fomit-frame-pointer\ -pipe checking whether to enable maintainer-specific portions of Makefiles... no checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking how to create a pax tar archive... gnutar checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking minix/config.h usability... no checking minix/config.h presence... no checking for minix/config.h... no checking whether it is safe to define __EXTENSIONS__... yes checking for __attribute__((returns_nonnull))... no checking for __attribute__((malloc))... yes checking for __attribute__((noreturn))... yes checking for __attribute__((noinline))... yes checking for __attribute__((format))... yes checking for __attribute__((warn_unused_result))... yes checking for struct timespec... yes checking for clockid_t... yes checking for library containing clock_gettime... none required checking for clock_gettime... yes checking for sched_setscheduler... yes checking for sched_get_priority_min... yes checking for sched_get_priority_max... yes checking for nice... yes checking for recvmmsg... yes checking for int8_t... yes checking for int16_t... yes checking for int32_t... yes checking for int64_t... yes checking for uint8_t... yes checking for uint16_t... yes checking for uint32_t... yes checking for uint64_t... yes checking for inline... inline checking whether strerror_r is declared... yes checking for strerror_r... yes checking whether strerror_r returns char *... yes checking for _Generic... no checking for __atomic... yes checking size of void *... 8 checking whether sys/types.h defines makedev... yes checking for sys/types.h... (cached) yes checking for netinet/in.h... yes checking for arpa/nameser.h... yes checking for netdb.h... yes checking for resolv.h... yes checking for sys/prctl.h... yes checking for linux/netfilter/nfnetlink_conntrack.h... yes checking for accept4... yes checking operating system... linux checking if compiler needs -Werror to reject unknown flags... no checking for the pthreads library -lpthreads... no checking whether pthreads work without any flags... no checking whether pthreads work with -Kthread... no checking whether pthreads work with -kthread... no checking for the pthreads library -llthread... no checking whether pthreads work with -pthread... yes checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE checking if more special flags are required for pthreads... no checking for PTHREAD_PRIO_INHERIT... yes checking for sin in -lm... yes checking if libm should be used... yes checking for ZLIB... yes checking if zlib should be used... yes checking for UUID... yes checking for memory allocator... system checking for mallopt... yes checking for mallinfo... yes checking for LIBCAP... no checking if libcap should be used... no checking if apps.plugin should be enabled... yes checking for IPMIMONITORING... yes checking for ipmi_monitoring_sensor_readings_by_record_id, ipmi_monitoring_sensor_readings_by_sensor_type, ipmi_monitoring_sensor_read_sensor_number, ipmi_monitoring_sensor_read_sensor_name, ipmi_monitoring_sensor_read_sensor_state, ipmi_monitoring_sensor_read_sensor_units, ipmi_monitoring_sensor_iterator_next, ipmi_monitoring_ctx_sensor_config_file, ipmi_monitoring_ctx_sdr_cache_directory, ipmi_monitoring_ctx_errormsg, ipmi_monitoring_ctx_create in -lipmimonitoring... yes checking ipmi_monitoring.h usability... yes checking ipmi_monitoring.h presence... yes checking for ipmi_monitoring.h... yes checking ipmi_monitoring_bitmasks.h usability... yes checking ipmi_monitoring_bitmasks.h presence... yes checking for ipmi_monitoring_bitmasks.h... yes checking if freeipmi.plugin should be enabled... yes checking for NFACCT... no checking for LIBMNL... no checking if nfacct.plugin should be enabled... no checking for setns... yes checking if cgroup-network can be enabled... yes checking whether C compiler accepts -flto... yes checking if -flto builds executables... yes checking if LTO should be enabled... yes checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating charts.d/Makefile config.status: creating conf.d/Makefile config.status: creating netdata.spec config.status: creating python.d/Makefile config.status: creating node.d/Makefile config.status: creating plugins.d/Makefile config.status: creating src/Makefile config.status: creating system/Makefile config.status: creating web/Makefile config.status: creating diagrams/Makefile config.status: creating makeself/Makefile config.status: creating contrib/Makefile config.status: creating tests/Makefile config.status: creating config.h config.status: config.h is unchanged config.status: executing depfiles commands OK --- Cleanup compilation directory --- --- Compile netdata --- [/root/netdata]# make -j8 make all-recursive make[1]: Entering directory `/root/netdata' Making all in charts.d make[2]: Entering directory `/root/netdata/charts.d' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/root/netdata/charts.d' Making all in conf.d make[2]: Entering directory `/root/netdata/conf.d' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/root/netdata/conf.d' Making all in diagrams make[2]: Entering directory `/root/netdata/diagrams' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/root/netdata/diagrams' Making all in makeself make[2]: Entering directory `/root/netdata/makeself' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/root/netdata/makeself' Making all in node.d make[2]: Entering directory `/root/netdata/node.d' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/root/netdata/node.d' Making all in plugins.d make[2]: Entering directory `/root/netdata/plugins.d' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/root/netdata/plugins.d' Making all in python.d make[2]: Entering directory `/root/netdata/python.d' if sed \ -e 's#[@]localstatedir_POST@#/usr/local/netdata/netdata/var#g' \ -e 's#[@]sbindir_POST@#/usr/local/netdata/netdata/usr/sbin#g' \ -e 's#[@]sysconfdir_POST@#/usr/local/netdata/netdata/etc#g' \ -e 's#[@]pythondir_POST@#/usr/local/netdata/netdata/usr/libexec/netdata/python.d#g' \ python-modules-installer.sh.in > python-modules-installer.sh.tmp; then \ mv "python-modules-installer.sh.tmp" "python-modules-installer.sh"; \ else \ rm -f "python-modules-installer.sh.tmp"; \ false; \ fi make[2]: Leaving directory `/root/netdata/python.d' Making all in src make[2]: Entering directory `/root/netdata/src' gcc -DHAVE_CONFIG_H -I. -I.. -DVARLIB_DIR="\"/usr/local/netdata/netdata/var/lib/netdata\"" -DCACHE_DIR="\"/usr/local/netdata/netdata/var/cache/netdata\"" -DCONFIG_DIR="\"/usr/local/netdata/netdata/etc/netdata\"" -DLOG_DIR="\"/usr/local/netdata/netdata/var/log/netdata\"" -DPLUGINS_DIR="\"/usr/local/netdata/netdata/usr/libexec/netdata/plugins.d\"" -DRUN_DIR="\"/usr/local/netdata/netdata/var/run/netdata\"" -DWEB_DIR="\"/usr/local/netdata/netdata/usr/share/netdata/web\"" -march=native -O2 -msse3 -fomit-frame-pointer -pipe -pthread -flto -MT apps_plugin.o -MD -MP -MF .deps/apps_plugin.Tpo -c -o apps_plugin.o apps_plugin.c make[2]: Leaving directory `/root/netdata' make[1]: Leaving directory `/root/netdata' OK --- Restore user edited netdata configuration files --- --- Fix generated files permissions --- [/root/netdata]# find ./system/ -type f -a \! -name \*.in -a \! -name Makefile\* -a \! -name \*.conf -a \! -name \*.service -a \! -name \*.logrotate -exec chmod 755 \{\} \; OK --- Add user netdata to required user groups --- Adding netdata user group ... [/root/netdata]# groupadd -r netdata OK Adding netdata user account with home /usr/local/netdata/netdata ... [/root/netdata]# useradd -r -g netdata -c netdata -s /usr/sbin/nologin --no-create-home -d /usr/local/netdata/netdata netdata OK Group 'docker' does not exist. Adding netdata user to the nginx group ... [/root/netdata]# usermod -a -G nginx netdata OK Group 'varnish' does not exist. Adding netdata user to the haproxy group ... [/root/netdata]# usermod -a -G haproxy netdata OK Adding netdata user to the adm group ... [/root/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. --- Install logrotate configuration for netdata --- [/root/netdata]# cp system/netdata.logrotate /etc/logrotate.d/netdata OK [/root/netdata]# chmod 644 /etc/logrotate.d/netdata OK --- Read installation options from netdata.conf --- Permissions - netdata user : netdata - netdata group : netdata - web files user : netdata - web files group : netdata - root user : root Directories - netdata conf dir : /usr/local/netdata/netdata/etc/netdata - netdata log dir : /usr/local/netdata/netdata/var/log/netdata - netdata run dir : /usr/local/netdata/netdata/var/run - netdata lib dir : /usr/local/netdata/netdata/var/lib/netdata - netdata web dir : /usr/local/netdata/netdata/usr/share/netdata/web - netdata cache dir: /usr/local/netdata/netdata/var/cache/netdata Other - netdata port : 19999 --- Fix permissions of netdata directories (using user 'netdata') --- [/root/netdata]# mkdir -p /usr/local/netdata/netdata/var/run OK [/root/netdata]# chown -R root:netdata /usr/local/netdata/netdata/etc/netdata OK [/root/netdata]# find /usr/local/netdata/netdata/etc/netdata -type f -exec chmod 0640 \{\} \; OK [/root/netdata]# find /usr/local/netdata/netdata/etc/netdata -type d -exec chmod 0755 \{\} \; OK [/root/netdata]# chown -R netdata:netdata /usr/local/netdata/netdata/usr/share/netdata/web OK [/root/netdata]# find /usr/local/netdata/netdata/usr/share/netdata/web -type f -exec chmod 0664 \{\} \; OK [/root/netdata]# find /usr/local/netdata/netdata/usr/share/netdata/web -type d -exec chmod 0775 \{\} \; OK [/root/netdata]# chown -R netdata:netdata /usr/local/netdata/netdata/var/lib/netdata OK [/root/netdata]# chown -R netdata:netdata /usr/local/netdata/netdata/var/cache/netdata OK [/root/netdata]# chown -R netdata:netdata /usr/local/netdata/netdata/var/log/netdata OK [/root/netdata]# chmod 755 /usr/local/netdata/netdata/var/log/netdata OK [/root/netdata]# chown netdata:root /usr/local/netdata/netdata/var/log/netdata OK [/root/netdata]# chown -R root /usr/local/netdata/netdata/usr/libexec/netdata OK [/root/netdata]# find /usr/local/netdata/netdata/usr/libexec/netdata -type d -exec chmod 0755 \{\} \; OK [/root/netdata]# find /usr/local/netdata/netdata/usr/libexec/netdata -type f -exec chmod 0644 \{\} \; OK [/root/netdata]# find /usr/local/netdata/netdata/usr/libexec/netdata -type f -a -name \*.plugin -exec chmod 0755 \{\} \; OK [/root/netdata]# find /usr/local/netdata/netdata/usr/libexec/netdata -type f -a -name \*.sh -exec chmod 0755 \{\} \; OK [/root/netdata]# chown root:netdata /usr/local/netdata/netdata/usr/libexec/netdata/plugins.d/apps.plugin OK [/root/netdata]# chmod 0750 /usr/local/netdata/netdata/usr/libexec/netdata/plugins.d/apps.plugin OK [/root/netdata]# setcap cap_dac_read_search\,cap_sys_ptrace+ep /usr/local/netdata/netdata/usr/libexec/netdata/plugins.d/apps.plugin OK [/root/netdata]# chown root:netdata /usr/local/netdata/netdata/usr/libexec/netdata/plugins.d/freeipmi.plugin OK [/root/netdata]# chmod 4750 /usr/local/netdata/netdata/usr/libexec/netdata/plugins.d/freeipmi.plugin OK [/root/netdata]# chown root:netdata /usr/local/netdata/netdata/usr/libexec/netdata/plugins.d/cgroup-network OK [/root/netdata]# chmod 4750 /usr/local/netdata/netdata/usr/libexec/netdata/plugins.d/cgroup-network OK [/root/netdata]# chown root /usr/local/netdata/netdata/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh OK [/root/netdata]# chmod 0550 /usr/local/netdata/netdata/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh OK [/root/netdata]# chmod a+rX /usr/local/netdata/netdata/usr/libexec OK [/root/netdata]# chmod a+rX /usr/local/netdata/netdata/usr/share/netdata OK --- Install netdata at system init --- Installing systemd service... [/root/netdata]# cp system/netdata.service /etc/systemd/system/netdata.service OK [/root/netdata]# systemctl daemon-reload OK [/root/netdata]# systemctl enable netdata Created symlink from /etc/systemd/system/multi-user.target.wants/netdata.service to /etc/systemd/system/netdata.service. OK --- Start netdata --- [/root/netdata]# /usr/bin/systemctl stop netdata OK [/root/netdata]# /usr/bin/systemctl restart netdata OK OK. NetData Started! ------------------------------------------------------------------------------- Downloading default configuration from netdata... [/root/netdata]# curl -s -o /usr/local/netdata/netdata/etc/netdata/netdata.conf.new http://localhost:19999/netdata.conf OK [/root/netdata]# mv /usr/local/netdata/netdata/etc/netdata/netdata.conf.new /usr/local/netdata/netdata/etc/netdata/netdata.conf OK OK New configuration saved for you to edit at /usr/local/netdata/netdata/etc/netdata/netdata.conf [/root/netdata]# chown netdata /usr/local/netdata/netdata/etc/netdata/netdata.conf OK [/root/netdata]# chmod 0664 /usr/local/netdata/netdata/etc/netdata/netdata.conf OK --- Check KSM (kernel memory deduper) --- --- Check version.txt --- --- Check apps.plugin --- --- Generate netdata-uninstaller.sh --- --- Basic netdata instructions --- netdata by default listens on all IPs on port 19999, so you can access it with: http://this.machine.ip:19999/ To stop netdata run: systemctl stop netdata To start netdata run: systemctl start netdata Uninstall script generated: ./netdata-uninstaller.sh Update script generated : ./netdata-updater.sh netdata-updater.sh can work from cron. It will trigger an email from cron only if it fails (it does not print anything when it can update netdata). Run this to automatically check and install netdata updates once per day: sudo ln -s /root/netdata/netdata-updater.sh /etc/cron.daily/netdata-updater --- We are done! --- ^ |.-. .-. .-. .-. .-. . netdata .-. .- | '-' '-' '-' '-' '-' is installed and running now! -' '-' +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+---> enjoy real-time performance and health monitoring...
One thought on “Install netdata monitoring in CentOS 7”