netdata
| Introduction | |
| Installation in CentOS/RedHat Linux | |
| Stop / Launch netdata | |
| API requests |
Introduction
Netdata is an open source tool designed to to collect real-time indicators such as:
- processor
- disk-activity
- bandwidth
- website-visit
and so on, and then display them in easily interpreted
diagrams updated in real time.
The tool is designed to visualize activities
as detailed as possible, allowing the user to
A general idea of what is happening and what has just happened
in its system or application.
I started using netdata as a more advanced alternative.
self-script
Monitoring CPU and RAM consumption
Review
Netdata consists of a demon that, when executed, is responsible for collecting
and display information in real time.
It's a lightweight instrument, mostly written on
C
,
Python
and
JavaScript
which uses minimal resources: about 2%
single-processor system.
It can be run in any GNU kernel. Linux
monitor any system or application and is capable of
Work on PCs, servers, and embedded Linux devices.
Features
Netdata is designed to be installed in the system without interrupting any of the
applications running on it.
It works in accordance with the memory requirements specified
the user, using only the idle cycles of the processor.
Once the application starts, it will not run disk.
Input and output, except for the journal.
The tool is stored on the disk at the end of its execution and
It restarts at launch.
By default, it contains certain plugins that are collected.
Key system metrics, but its behavior expands with
Plugin API.
Netdata can work on almost any device that uses
The Linux kernel, and its graphics can be embedded in web pages.
It has an interface with customizable themes and can be customized
User manually using simple HTML.
There is no dependency here, as it works like its own.
Web server with static web files.
Starting with v1.12, Netdata collects anonymity by default.
information about the use and send it to Google Analytics,
A function that can be disabled by manual settings.
Development
Netdata is currently supported by nearly 400 members.
They help (at various levels) to serve thousands of people.
Users and companies using this tool.
The user with the largest contribution is
Costa Tsaousis, CEO and founder of Netdata
With over 600,000 additions to the code.
The second most active user is Ilya Mashchenko.
The most popular addition to Netdata appears to be the addition
support data collection from Vnstat, pull request Noah Troy
200 individual comments (more than any other pull request)
The most popular feature request of all time seems to be
Supports the launch of several freeipmi tasks
The same Netdata.
Installation
Before installing, make sure you have curl and other utilities.
The netdata will alert you to update the system.
>> IMPORTANT <<
Please make sure your system is up to date
by running: yum update
I suggest you do it in advance.
At .rpm Linux.
If you install netdata on
CentOS
or RedHat:
As an option, set the following in advance:
sudo yum upadte
sudo yum install epel-release
sudo yum install zlib-devel libuuid-devel libmnl-devel gcc make git autoconf autogen automake pkgconfig
sudo yum install autoconf-archive cmake elfutils-libelf-devel json-c-devel libuv-devel lz4-devel openssl-devel
sudo yum install curl jq nodejs
Now you can use the script from the official website. I chose to only get stable. Update and shut down the telemetry.
bash <(curl -Ss https://my-netdata.io/kickstart.sh) --stable-channel --disable-telemetry
Dependencies Resolved ================================================================================================================= Package Arch Version Repository Size ================================================================================================================= Installing: autoconf-archive noarch 2017.03.21-1.el7 base 612 k cmake x86_64 2.8.12.2-2.el7 base 7.1 M elfutils-libelf-devel x86_64 0.176-5.el7 base 40 k json-c-devel x86_64 0.11-4.el7_0 base 20 k libuv-devel x86_64 1:1.40.0-1.el7 epel 36 k lz4-devel x86_64 1.8.3-1.el7 base 26 k openssl-devel x86_64 1:1.0.2k-21.el7_ updates 1.5 M Installing for dependencies: keyutils-libs-devel x86_64 1.5.8-3.el7 base 37 k krb5-devel x86_64 1.15.1-50.el7 base 273 k libcom_err-devel x86_64 1.42.9-19.el7 base 32 k libselinux-devel x86_64 2.5-15.el7 base 187 k libsepol-devel x86_64 2.5-10.el7 base 77 k libverto-devel x86_64 0.2.5-4.el7 base 12 k pcre-devel x86_64 8.32-17.el7 base 480 k Transaction Summary ================================================================================================================= Install 7 Packages (+7 Dependent packages) Total download size: 10 M Installed size: 35 M
If you got a mistake.
bash: /dev/fd/63: No such file or directory
Make sure you run command without sudo. Do not do sudo
During the installation process, you will need to press ENTER a couple of times and enter a password for
sudo. If you do not follow the installation, there is a chance to miss this one.
Then it will end with a fae.
The installation process is quite long.
virtual
CentOS 7
It took me over 20 minutes with 4 GB RAM.
After successful installation, a message will appear:
--- We are done! --- ^ |.-. .-. .-. .-. .-. . netdata .-. .- | '-' '-' '-' '-' '-' is installed and running now! -' '-' +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->
In the browser, enter 127.0.0. 1:19999
Files with netdata settings appear in
/etc/netdata
sudo ls -la /etc/netdata
total 288 drwxr-xr-x. 10 root root 244 Feb 15 17:10 . drwxr-xr-x. 85 root root 8192 Feb 15 17:10 .. drwxr-xr-x. 2 root root 6 Feb 15 16:57 charts.d drwxr-xr-x. 2 root root 6 Feb 15 16:57 custom-plugins.d -rwxr-xr-x. 1 root root 2045 Feb 15 16:57 edit-config -rw-r--r--. 1 root root 511 Feb 15 17:10 .environment drwxr-xr-x. 2 root root 6 Feb 15 16:57 go.d drwxr-xr-x. 2 root root 6 Feb 15 16:57 health.d -rw-r--r--. 1 root root 273592 Feb 15 17:10 netdata.conf drwxr-xr-x. 2 root root 6 Feb 15 16:57 node.d -rw-rw-r--. 1 root root 0 Feb 15 17:10 .opt-out-from-anonymous-statistics lrwxrwxrwx. 1 root root 23 Feb 15 17:10 orig -> /usr/lib/netdata/conf.d drwxr-xr-x. 2 root root 6 Feb 15 16:57 python.d drwxr-xr-x. 2 root root 6 Feb 15 16:57 ssl drwxr-xr-x. 2 root root 6 Feb 15 16:57 statsd.d
netdata.conf
File.
netdata.conf
With current settings, you can also learn through the web interface.
In the browser, enter
localhost:19999/netdata.conf
Stop netdata
service netdata stop
systemctl stop netdata
/etc/init.d/netdata stop
Launch netdata
systemctl start netdata
systemctl start netdata
/etc/init.d/netdata start
Restart the netdata
systemctl restart netdata
systemctl restart netdata
/etc/init.d/netdata restart
Access from a remote computer
Let’s say you have netdata on 192.168.56. 104
You want to monitor it from 192.168.56. 1st
Open port 19999.
?
Instructions for CentOS/RedHat
)
Enter the host 192.168.56.1 in the browser
http://192.168.56.104:19999
Make sure it is http and not https otherwise it may not connect. i
API requests
The documentation lies in github
Example of request for
Python
Let's look at the script.
sys_monitor.py
import urllib.request
import json
def main():
r = urllib.request.urlopen('http://10.1.102.209:19999/api/v1/data?chart=system.cpu&points=5&after=-10&options=seconds')
rr = r.read()
rj = json.loads(rr)
print(json.dumps(rj))
if __name__ == '__main__':
main()
Let's take this example.
Requests can be made to one of two resources:
- /api/v1/data
- /api/v1/badge.svg
I did it on /api/v1/data. EndPoint looks like
http://10.1.102.209:19999/api/v1/data + parameters
| chart=system.cpu | interested in |
| points=5 | You need five values for the selected period |
| after=-10 | Selected period - last 10 seconds |
| options=seconds |
At its core, this request is simply an appeal to a database of data already collected.
Read more about all requests in the chapter
request
You can start the script command
python3 sys_monitor.py
{ "labels": ["time", "guest_nice", "guest", "steal", "softirq", "irq", "user", "system", "nice", "iowait"], "data": [ [1614181358, 0, 0, 0, 0.0625782, 0, 1.1285306, 1.5675215, 0, 0], [1614181356, 0, 0, 0, 0.1888379, 0, 2.6453165, 2.0154335, 0, 0.377993], [1614181354, 0, 0, 0, 0.0625, 0, 0.9391468, 1.3775879, 0, 0], [1614181352, 0, 0, 0, 0.0628141, 0, 1.0044735, 1.2554933, 0, 0], [1614181350, 0, 0, 0, 0.1254707, 0, 0.941109, 1.4426771, 0, 0] ] }
time: Received five points, as indicated in points time given in
Epoch Time format
"guest nice," "guest," "steal" are empty.
softirq:
"irq" is empty.
user: shows the CPU consumed by the user
system: shows the CPU consumed by the system
"nice" is empty
iowait: shows the CPU consumed by iowait
| Title | Mandatory | Description |
|---|---|---|
| chart | yes | The schedule to which the request is made. |
| points | no | The number of points to be returned. Netdata can reduce the number of points using grouping. The default result will be contain the same number of points as the database (although this also depends on the parameter) gtime). |
| before | no | The absolute time stamp or relative time to which the data is selected. By default, equates to the last (newest) time stamp in the database. |
| after | no | Absolute time stamp or relative (from before) from which the data are selected. Default equates The first (oldest) time stamp in the database. |
| group | no | The method of grouping, by which you need to reduce the number of points (compared to the full number of points in the database). By default. used average. |
| gtime | no | Resampling time with which you can change the metric units (e.g. setting a value) 60 converts per second into per minute. Default equates to the degree of detail (granularity) base. |
| options | no | A bitmap of options that can affect the operation of the query. Only 2 options are used by the query engine: unaligned and percentage. All the other options are used by the output formatters. The default is to return aligned data. |
| dimensions | no | A simple pattern to filter the dimensions to be queried. The default is to return all the dimensions of the chart. |
Article author: Andrei Olegovich