netdata for IoT

netdata is a very efficient server performance monitoring solution. When running in server hardware, it can collect thousands of system and application metrics per second with just 1% CPU utilization of a single core. Its web server responds to most data requests in about half a millisecond making its web dashboards spontaneous, amazingly fast!

netdata can also be a very efficient real-time monitoring solution for IoT devices (RPIs, routers, media players, wifi access points, industrial controllers and sensors of all kinds). Netdata will generally run everywhere a Linux kernel runs (and it is glibc and musl-libc friendly).

You can use it as both a data collection agent (where you pull data using its API), for embedding its charts on other web pages / consoles, but also for accessing it directly with your browser to view its dashboard.

The netdata web API already provides reduce functions allowing it to report average and max for any timeframe. It can also respond in many formats including JSON, JSONP, CSV, HTML. Its API is also a google charts provider so it can directly be used by google sheets, google charts, google widgets.

Although netdata has been significantly optimized to lower the CPU and RAM resources it consumes, the plethora of data collection plugins may be inappropriate for weak IoT devices.

keep in mind that netdata on RPi 2 and 3 does not require any tuning. The default settings will be good. The following tunables apply only when running netdata on RPi 1 or other very weak IoT devices.

Here are a few tricks to control the resources consumed by netdata:

1. Disable External plugins

External plugins can consume more system resources than the netdata server. Disable the ones you don't need.

3. Disable logs

Normally, you will not need them. To disable them, set:

[global]
debug log = none
error log = none
access log = none

4. Set memory mode to RAM

Setting the memory mode to ram will disable loading and saving the round robin database. This will not affect anything while running netdata, but it might be required if you have very limited storage available.

[global]
memory mode = ram

5. CPU utilization

If after disabling the plugins you don't need, netdata still uses a lot of CPU without any clients accessing the dashboard, try lowering its data collection frequency. Going from "once per second" to "once every two seconds" will not have a significant difference on the user experience, but it will cut the CPU resources required in half.

To set the update frequency, edit /etc/netdata/netdata.conf and set:

[global]
update every = 2

You may have to increase this to 5 or 10 if the CPU of the device is weak.

Keep in mind this will also force dashboard chart refreshes to happen at the same rate. So increasing this number actually lowers data collection frequency but also lowers dashboard chart refreshes frequency.

This is a dashboard on a device with [global].update every = 5 (this device is a media player and is now playing a movie):

6. Lower memory requirements

You can set the default size of the round robin database for all charts, using:

[global]
history = 600

The units for history is [global].update every seconds. So if [global].update every = 6 and [global].history = 600, you will have an hour of data ( 6 x 600 = 3.600 ), which will store 600 points per dimension, one every 6 seconds.

Check also Memory Requirements for directions on calculating the size of the round robin database.

7. Disable gzip compression of responses

Gzip compression of the web responses is using more CPU that the rest of netdata. You can lower the compression level or disable gzip compression completely. You can disable it, like this:

[web]
enable gzip compression = no

To lower the compression level, do this:

[web]
enable gzip compression = yes
gzip compression level = 1

Finally, if no web server is installed on your device, you can use port tcp/80 for netdata:

[global]
port = 80

8. Monitoring RPi temperature

The python version of the sensors plugin uses lm-sensors. Unfortunately the temperature reading of RPi are not supported by lm-sensors.

netdata also has a bash version of the sensors plugin that can read RPi temperatures. It is disabled by default to avoid the conflicts with the python version.

To enable it, edit /etc/netdata/charts.d.conf and uncomment this line: