From 112b5b91647c3dea45cc1c9bc364df526c8012f1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 26 Jan 2022 19:05:15 +0100 Subject: Merging upstream version 1.33.0. Signed-off-by: Daniel Baumann --- collectors/COLLECTORS.md | 12 +- collectors/QUICKSTART.md | 125 ---------------- collectors/REFERENCE.md | 8 +- collectors/all.h | 12 -- collectors/apps.plugin/apps_plugin.c | 32 +--- collectors/cgroups.plugin/cgroup-network.c | 35 +---- collectors/cgroups.plugin/sys_fs_cgroup.h | 21 --- collectors/charts.d.plugin/example/README.md | 2 +- collectors/checks.plugin/plugin_checks.c | 6 +- collectors/checks.plugin/plugin_checks.h | 29 ---- collectors/cups.plugin/cups_plugin.c | 31 +--- collectors/diskspace.plugin/plugin_diskspace.c | 2 +- collectors/diskspace.plugin/plugin_diskspace.h | 34 ----- collectors/ebpf.plugin/README.md | 2 +- collectors/ebpf.plugin/ebpf.c | 163 +++++++++++++-------- collectors/ebpf.plugin/ebpf.d.conf | 2 +- collectors/ebpf.plugin/ebpf.h | 13 +- collectors/ebpf.plugin/ebpf_cachestat.c | 8 +- collectors/ebpf.plugin/ebpf_cachestat.h | 2 +- collectors/ebpf.plugin/ebpf_dcstat.c | 8 +- collectors/ebpf.plugin/ebpf_disk.c | 11 +- collectors/ebpf.plugin/ebpf_fd.c | 7 +- collectors/ebpf.plugin/ebpf_filesystem.c | 30 +++- collectors/ebpf.plugin/ebpf_filesystem.h | 1 + collectors/ebpf.plugin/ebpf_hardirq.c | 7 +- collectors/ebpf.plugin/ebpf_mdflush.c | 14 +- collectors/ebpf.plugin/ebpf_mount.c | 7 +- collectors/ebpf.plugin/ebpf_oomkill.c | 10 +- collectors/ebpf.plugin/ebpf_process.c | 111 +++++++++++++- collectors/ebpf.plugin/ebpf_process.h | 15 ++ collectors/ebpf.plugin/ebpf_shm.c | 7 +- collectors/ebpf.plugin/ebpf_socket.c | 9 +- collectors/ebpf.plugin/ebpf_softirq.c | 7 +- collectors/ebpf.plugin/ebpf_swap.c | 7 +- collectors/ebpf.plugin/ebpf_sync.c | 8 +- collectors/ebpf.plugin/ebpf_sync.h | 2 +- collectors/ebpf.plugin/ebpf_vfs.c | 7 +- collectors/freebsd.plugin/plugin_freebsd.h | 22 --- collectors/freeipmi.plugin/freeipmi_plugin.c | 34 +---- collectors/idlejitter.plugin/README.md | 18 ++- collectors/idlejitter.plugin/plugin_idlejitter.c | 2 +- collectors/idlejitter.plugin/plugin_idlejitter.h | 21 --- collectors/macos.plugin/plugin_macos.h | 31 ---- collectors/nfacct.plugin/plugin_nfacct.c | 42 ++---- collectors/node.d.plugin/sma_webbox/README.md | 2 +- collectors/node.d.plugin/snmp/README.md | 23 ++- collectors/perf.plugin/perf_plugin.c | 32 +--- collectors/plugins.d/plugins_d.h | 14 -- collectors/proc.plugin/plugin_proc.h | 23 --- collectors/proc.plugin/sys_class_infiniband.c | 10 +- collectors/python.d.plugin/anomalies/README.md | 3 +- collectors/python.d.plugin/example/README.md | 7 +- collectors/python.d.plugin/fail2ban/README.md | 59 ++++++-- .../python.d.plugin/fail2ban/fail2ban.chart.py | 57 ++++--- collectors/python.d.plugin/mongodb/README.md | 2 +- .../python.d.plugin/nvidia_smi/nvidia_smi.chart.py | 33 ++++- .../python.d.plugin/postgres/postgres.chart.py | 10 +- collectors/python.d.plugin/python.d.plugin.in | 2 +- .../bases/FrameworkServices/ExecutableService.py | 2 +- .../python.d.plugin/spigotmc/spigotmc.chart.py | 21 ++- collectors/python.d.plugin/web_log/README.md | 4 +- collectors/slabinfo.plugin/slabinfo.c | 35 +---- collectors/statsd.plugin/README.md | 6 +- collectors/statsd.plugin/statsd.c | 5 +- collectors/statsd.plugin/statsd.h | 25 ---- collectors/tc.plugin/plugin_tc.c | 2 +- collectors/tc.plugin/plugin_tc.h | 31 ---- collectors/tc.plugin/tc-qos-helper.sh.in | 6 +- collectors/timex.plugin/plugin_timex.c | 2 +- collectors/timex.plugin/plugin_timex.h | 29 ---- collectors/xenstat.plugin/xenstat_plugin.c | 30 +--- 71 files changed, 598 insertions(+), 854 deletions(-) delete mode 100644 collectors/QUICKSTART.md delete mode 100644 collectors/checks.plugin/plugin_checks.h delete mode 100644 collectors/diskspace.plugin/plugin_diskspace.h delete mode 100644 collectors/idlejitter.plugin/plugin_idlejitter.h delete mode 100644 collectors/statsd.plugin/statsd.h delete mode 100644 collectors/tc.plugin/plugin_tc.h delete mode 100644 collectors/timex.plugin/plugin_timex.h (limited to 'collectors') diff --git a/collectors/COLLECTORS.md b/collectors/COLLECTORS.md index 5f37dfc34..19790c424 100644 --- a/collectors/COLLECTORS.md +++ b/collectors/COLLECTORS.md @@ -129,7 +129,7 @@ configure any of these collectors according to your setup and infrastructure. metrics. - [Redis (Go)](https://learn.netdata.cloud/docs/agent/collectors/go.d.plugin/modules/redis/): Monitor status from any number of database instances by reading the server's response to the `INFO ALL` command. -- [Redis (Python)](/collectors/python.d.plugin/redis/): Monitor database status by reading the server's response to +- [Redis (Python)](/collectors/python.d.plugin/redis/README.md): Monitor database status by reading the server's response to the `INFO` command. - [RethinkDB](/collectors/python.d.plugin/rethinkdbs/README.md): Collect database server and cluster statistics. - [Riak KV](/collectors/python.d.plugin/riakkv/README.md): Collect database stats from the `/stats` endpoint. @@ -169,14 +169,14 @@ configure any of these collectors according to your setup and infrastructure. plugins metrics from an endpoint provided by `in_monitor plugin`. - [Logstash](https://learn.netdata.cloud/docs/agent/collectors/go.d.plugin/modules/logstash/): Monitor JVM threads, memory usage, garbage collection statistics, and more. -- [OpenVPN status logs](/collectors/python.d.plugin/ovpn_status_log/): Parse server log files and provide summary +- [OpenVPN status logs](/collectors/python.d.plugin/ovpn_status_log/README.md): Parse server log files and provide summary (client, traffic) metrics. - [Squid web server logs](https://learn.netdata.cloud/docs/agent/collectors/go.d.plugin/modules/squidlog/): Tail Squid access logs to return the volume of requests, types of requests, bandwidth, and much more. - [Web server logs (Go version for Apache, NGINX)](https://learn.netdata.cloud/docs/agent/collectors/go.d.plugin/modules/weblog/): Tail access logs and provide very detailed web server performance statistics. This module is able to parse 200k+ rows in less than half a second. -- [Web server logs (Python version for Apache, NGINX, Squid)](/collectors/python.d.plugin/web_log/): Tail access log +- [Web server logs (Python version for Apache, NGINX, Squid)](/collectors/python.d.plugin/web_log/README.md): Tail access log file and collect web server/caching proxy metrics. ### Messaging @@ -217,7 +217,7 @@ configure any of these collectors according to your setup and infrastructure. server authentication and accounting statistics from the `status server`. - [Freeradius (Python)](/collectors/python.d.plugin/freeradius/README.md): Collect server authentication and accounting statistics from the `status server` using the `radclient` tool. -- [Libreswan](/collectors/charts.d.plugin/libreswan/): Collect bytes-in, bytes-out, and uptime metrics. +- [Libreswan](/collectors/charts.d.plugin/libreswan/README.md): Collect bytes-in, bytes-out, and uptime metrics. - [Icecast](/collectors/python.d.plugin/icecast/README.md): Monitor the number of listeners for active sources. - [ISC BIND](/collectors/node.d.plugin/named/README.md): Collect nameserver summary performance statistics via a web interface (`statistics-channels` feature). @@ -267,7 +267,7 @@ configure any of these collectors according to your setup and infrastructure. blockchain indexes, memory usage, network usage, and transactions of wallet instances. - [Energi Core (Python)](/collectors/python.d.plugin/energid/README.md): Monitor blockchain, memory, network, and unspent transactions statistics. -- [Fronius Symo](/collectors/node.d.plugin/fronius/): Collect power, consumption, autonomy, energy, and inverter +- [Fronius Symo](/collectors/node.d.plugin/fronius/README.md): Collect power, consumption, autonomy, energy, and inverter statistics. - [UPS/PDU](/collectors/charts.d.plugin/nut/README.md): Read the status of UPS/PDU devices using the `upsc` tool. - [SMA Sunny WebBox](/collectors/node.d.plugin/sma_webbox/README.md): Collect power statistics. @@ -338,7 +338,7 @@ configure any of these collectors according to your setup and infrastructure. statistics using information provided by `ngx_http_reqstat_module`. - [Tomcat](/collectors/python.d.plugin/tomcat/README.md): Collect web server performance metrics from the Manager App (`/manager/status?XML=true`). -- [Traefik](/collectors/python.d.plugin/traefik/README.md): Uses Trafik's Health API to provide statistics. +- [Traefik](/collectors/python.d.plugin/traefik/README.md): Uses Traefik's Health API to provide statistics. - [Varnish](/collectors/python.d.plugin/varnish/README.md): Provides HTTP accelerator global, backends (VBE), and disks (SMF) statistics using the `varnishstat` tool. - [x509 check](https://learn.netdata.cloud/docs/agent/collectors/go.d.plugin/modules/x509check/): Monitor certificate diff --git a/collectors/QUICKSTART.md b/collectors/QUICKSTART.md deleted file mode 100644 index 809ec18af..000000000 --- a/collectors/QUICKSTART.md +++ /dev/null @@ -1,125 +0,0 @@ - - -# Collectors quickstart - -In this quickstart guide, you'll learn how to enable collectors so you can get metrics from your favorite applications -and services. - -This guide will not cover advanced collector features, such as enabling/disabling entire plugins, - -## What's in this quickstart guide - -- [Find the collector for your application or service](#find-the-collector-for-your-application-or-service) -- [Configure your application or service for monitoring](#configure-your-application-or-service-for-monitoring) -- [Edit the collector's configuration file](#edit-the-collectors-configuration-file) -- [Enable the collector](#enable-the-collector) - -## Find the collector for your application or service - -Netdata has _pre-installed_ collectors for hundreds of popular applications and services. You don't need to install -anything to collect metrics from many popular services, like Nginx web servers, MySQL/MariaDB databases, and much more. - -To find whether Netdata has a pre-installed collector for your favorite app/service, check out our [collector support -list](COLLECTORS.md). The only exception is the [third-party collectors](COLLECTORS.md#third-party-plugins), which -you do need to install yourself. However, this quickstart guide will focus on pre-installed collectors. - -When you find a collector you're interested in, take note of its orchestrator. These are in the headings above each -table, and there are four: Bash, Go, Node, and Python. They go by their respective names: `charts.d`, `go.d`, `node.d`, -and `python.d`. - -> If there is a collector written in both Go and Python, it's better to choose the Go-based version, as we will -> eventually deprecate most Python-based collectors. - -From here on out, this quickstart guide will use the [Nginx -collector](https://learn.netdata.cloud/docs/agent/collectors/go.d.plugin/modules/nginx) as an example to showcase the -process of configuring and enabling one of Netdata's pre-installed collectors. - -## Configure your application or service for monitoring - -Every collector's documentation comes with instructions on how to configure your app/service to make it available to -Netdata's collector. Our [collector support list](COLLECTORS.md) contains links to each collector's documentation page -so you can learn more. - -For example, the [Nginx collector -documentation](https://learn.netdata.cloud/docs/agent/collectors/go.d.plugin/modules/nginx) states that your Nginx -installation must have the `stub_status` module configured correctly, in addition to an active `stub_status/` page, for -Netdata to monitor it. You can confirm whether you have the module enabled with the following command: - -```bash -nginx -V 2>&1 | grep -o with-http_stub_status_module -``` - -If this command returns nothing, you'll need to [enable the `stub_status` -module](https://www.nginx.com/blog/monitoring-nginx/). - -Next, edit your `/etc/nginx/sites-enabled/default` file to include a `location` block with the following, which enables -the `stub_status` page: - -```conf -server { - ... - - location /nginx_status { - stub_status; - } -} -``` - -At this point, your Nginx installation is fully configured and ready for Netdata to monitor it. Next, you'll configure -your collector. - -## Edit the collector's configuration file - -This step may not be required based on how you configured your app/service, as each collector comes with a few -pre-configured jobs that look for the app/service in common and expected locations. For example, the Nginx collector -looks for a `stub_status` page at `http://localhost/stub_status` and `http://127.0.0.1/stub_status`, which allows it to -auto-detect almost all local Nginx web servers. - -Despite Netdata's auto-detection capabilities, it's important to know how to edit collector configuration files. - -You should always edit configuration files with the `edit-config` script that comes with every installation of Netdata. -To edit a collector configuration file, navigate to your [Netdata configuration directory](/docs/configure/nodes.md). -Launch `edit-config` with the path to the collector's configuration file. - -How do you find that path to the collector's configuration file? Look under the **Configuration** heading in the -collector's documentation. Each file contains a short code block with the relevant command. - -For example, the [Nginx collector](https://learn.netdata.cloud/docs/agent/collectors/go.d.plugin/modules/nginx) has its -configuration file at `go.d/nginx.conf`. - -```bash -cd /etc/netdata # Replace this path with your Netdata config directory -sudo ./edit-config go.d/nginx.conf -``` - -This file contains all of the possible job parameters to help you monitor Nginx in all sorts of complex deployments. At -the bottom of the file is a `[JOB]` section, which contains the two default jobs. Configure these as needed, using those -parameters as a reference, to configure the collector. - -## Enable the collector - -Most collectors are enabled and will auto-detect their app/service without manual configuration. However, you need to -restart Netdata to trigger the auto-detection process. - -To restart Netdata on most systems, use `sudo systemctl restart netdata`, or the [appropriate -method](/docs/configure/start-stop-restart.md) for your system. - -Open Netdata's dashboard in your browser, or refresh the page if you already have it open. You should now see a new -entry in the menu and new interactive charts! - -## What's next? - -Collector not working? Learn about collector troubleshooting in our [collector -reference](REFERENCE.md#troubleshoot-a-collector). - -View our [collectors guides](/collectors/README.md#guides) to get specific instructions on enabling new and -popular collectors. - -Finally, learn more advanced collector features, such as disabling plugins or developing a custom collector, in our -[internal plugin API](/collectors/REFERENCE.md#internal-plugins-api) or our [external plugin -docs](/collectors/plugins.d/README.md). - -[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2FQUICKSTART&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]() diff --git a/collectors/REFERENCE.md b/collectors/REFERENCE.md index 4922ff9a9..e5c52115e 100644 --- a/collectors/REFERENCE.md +++ b/collectors/REFERENCE.md @@ -81,7 +81,7 @@ field contains `go.d`, that collector uses the Go orchestrator. The output from the relevant command will provide valuable troubleshooting information. If you can't figure out how to enable the collector using the details from this output, feel free to [create an issue on our -GitHub](https://github.com/netdata/netdata/issues/new?labels=bug%2C+needs+triage&template=bug_report.md) to get some +GitHub](https://github.com/netdata/netdata/issues/new?assignees=&labels=bug%2Cneeds+triage&template=BUG_REPORT.yml) to get some help from our collectors experts. ## Enable and disable plugins @@ -116,7 +116,7 @@ This section features a list of Netdata's plugins, with a boolean setting to ena By default, most plugins are enabled, so you don't need to enable them explicitly to use their collectors. To enable or disable any specific plugin, remove the comment (`#`) and change the boolean setting to `yes` or `no`. -All **external plugins** are managed by [plugins.d](plugins.d/), which provides additional management options. +All **external plugins** are managed by [plugins.d](plugins.d/README.md), which provides additional management options. ## Internal plugins @@ -178,10 +178,10 @@ through this, is to examine what other similar plugins do. ## External Plugins -**External plugins** use the API and are managed by [plugins.d](plugins.d/). +**External plugins** use the API and are managed by [plugins.d](plugins.d/README.md). ## Write a custom collector -You can add custom collectors by following the [external plugins documentation](../collectors/plugins.d/). +You can add custom collectors by following the [external plugins documentation](/collectors/plugins.d/README.md). [![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2REFERENCE&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]() diff --git a/collectors/all.h b/collectors/all.h index 647ee9774..100a6b090 100644 --- a/collectors/all.h +++ b/collectors/all.h @@ -7,20 +7,8 @@ // netdata internal data collection plugins -#include "checks.plugin/plugin_checks.h" -#include "freebsd.plugin/plugin_freebsd.h" -#include "idlejitter.plugin/plugin_idlejitter.h" -#include "cgroups.plugin/sys_fs_cgroup.h" -#include "diskspace.plugin/plugin_diskspace.h" -#include "timex.plugin/plugin_timex.h" -#include "proc.plugin/plugin_proc.h" -#include "tc.plugin/plugin_tc.h" -#include "macos.plugin/plugin_macos.h" -#include "statsd.plugin/statsd.h" - #include "plugins.d/plugins_d.h" - // ---------------------------------------------------------------------------- // netdata chart priorities diff --git a/collectors/apps.plugin/apps_plugin.c b/collectors/apps.plugin/apps_plugin.c index 3bed4bb6b..5555f157b 100644 --- a/collectors/apps.plugin/apps_plugin.c +++ b/collectors/apps.plugin/apps_plugin.c @@ -7,37 +7,7 @@ */ #include "libnetdata/libnetdata.h" - -// ---------------------------------------------------------------------------- - -// callback required by fatal() -void netdata_cleanup_and_exit(int ret) { - exit(ret); -} - -void send_statistics( const char *action, const char *action_result, const char *action_data) { - (void) action; - (void) action_result; - (void) action_data; - return; -} -// callbacks required by popen() -void signals_block(void) {}; -void signals_unblock(void) {}; -void signals_reset(void) {}; - -// callback required by eval() -int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *rc, calculated_number *result) { - (void)variable; - (void)hash; - (void)rc; - (void)result; - return 0; -}; - -// required by get_system_cpus() -char *netdata_configured_host_prefix = ""; - +#include "libnetdata/required_dummies.h" // ---------------------------------------------------------------------------- // debugging diff --git a/collectors/cgroups.plugin/cgroup-network.c b/collectors/cgroups.plugin/cgroup-network.c index 562d30663..6465c91e7 100644 --- a/collectors/cgroups.plugin/cgroup-network.c +++ b/collectors/cgroups.plugin/cgroup-network.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "libnetdata/libnetdata.h" +#include "libnetdata/required_dummies.h" #ifdef HAVE_SETNS #ifndef _GNU_SOURCE @@ -16,40 +17,6 @@ char *environment[] = { NULL }; - -// ---------------------------------------------------------------------------- - -// callback required by fatal() -void netdata_cleanup_and_exit(int ret) { - exit(ret); -} - -void send_statistics( const char *action, const char *action_result, const char *action_data) { - (void) action; - (void) action_result; - (void) action_data; - return; -} - -// callbacks required by popen() -void signals_block(void) {}; -void signals_unblock(void) {}; -void signals_reset(void) {}; - -// callback required by eval() -int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *rc, calculated_number *result) { - (void)variable; - (void)hash; - (void)rc; - (void)result; - return 0; -}; - -// required by get_system_cpus() -char *netdata_configured_host_prefix = ""; - -// ---------------------------------------------------------------------------- - struct iface { const char *device; uint32_t hash; diff --git a/collectors/cgroups.plugin/sys_fs_cgroup.h b/collectors/cgroups.plugin/sys_fs_cgroup.h index 017aa8fb5..85968a4da 100644 --- a/collectors/cgroups.plugin/sys_fs_cgroup.h +++ b/collectors/cgroups.plugin/sys_fs_cgroup.h @@ -5,21 +5,6 @@ #include "daemon/common.h" -#if (TARGET_OS == OS_LINUX) - -#define NETDATA_PLUGIN_HOOK_LINUX_CGROUPS \ - { \ - .name = "PLUGIN[cgroups]", \ - .config_section = CONFIG_SECTION_PLUGINS, \ - .config_name = "cgroups", \ - .enabled = 1, \ - .thread = NULL, \ - .init_routine = NULL, \ - .start_routine = cgroups_main \ - }, - -extern void *cgroups_main(void *ptr); - #define CGROUP_OPTIONS_DISABLED_DUPLICATE 0x00000001 #define CGROUP_OPTIONS_SYSTEM_SLICE_SERVICE 0x00000002 #define CGROUP_OPTIONS_IS_UNIFIED 0x00000004 @@ -54,12 +39,6 @@ typedef struct netdata_ebpf_cgroup_shm { #include "../proc.plugin/plugin_proc.h" -#else // (TARGET_OS == OS_LINUX) - -#define NETDATA_PLUGIN_HOOK_LINUX_CGROUPS - -#endif // (TARGET_OS == OS_LINUX) - extern char *parse_k8s_data(struct label **labels, char *data); #endif //NETDATA_SYS_FS_CGROUP_H diff --git a/collectors/charts.d.plugin/example/README.md b/collectors/charts.d.plugin/example/README.md index de21f6ad6..c3dfd2c00 100644 --- a/collectors/charts.d.plugin/example/README.md +++ b/collectors/charts.d.plugin/example/README.md @@ -5,6 +5,6 @@ custom_edit_url: https://github.com/netdata/netdata/edit/master/collectors/chart # Example -This is just an example charts.d data collector. +If you want to understand how charts.d data collector functions, check out the [charts.d example](https://raw.githubusercontent.com/netdata/netdata/master/collectors/charts.d.plugin/example/example.chart.sh). [![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fcharts.d.plugin%2Fexample%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>) diff --git a/collectors/checks.plugin/plugin_checks.c b/collectors/checks.plugin/plugin_checks.c index 1bd053b8c..312515115 100644 --- a/collectors/checks.plugin/plugin_checks.c +++ b/collectors/checks.plugin/plugin_checks.c @@ -1,8 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -#include "plugin_checks.h" - -#ifdef NETDATA_INTERNAL_CHECKS +#include "daemon/common.h" static void checks_main_cleanup(void *ptr) { struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr; @@ -125,5 +123,3 @@ void *checks_main(void *ptr) { netdata_thread_cleanup_pop(1); return NULL; } - -#endif // NETDATA_INTERNAL_CHECKS diff --git a/collectors/checks.plugin/plugin_checks.h b/collectors/checks.plugin/plugin_checks.h deleted file mode 100644 index c8057253c..000000000 --- a/collectors/checks.plugin/plugin_checks.h +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef NETDATA_PLUGIN_CHECKS_H -#define NETDATA_PLUGIN_CHECKS_H 1 - -#include "daemon/common.h" - -#ifdef NETDATA_INTERNAL_CHECKS - -#define NETDATA_PLUGIN_HOOK_CHECKS \ - { \ - .name = "PLUGIN[check]", \ - .config_section = CONFIG_SECTION_PLUGINS, \ - .config_name = "checks", \ - .enabled = 0, \ - .thread = NULL, \ - .init_routine = NULL, \ - .start_routine = checks_main \ - }, - -extern void *checks_main(void *ptr); - -#else // !NETDATA_INTERNAL_CHECKS - -#define NETDATA_PLUGIN_HOOK_CHECKS - -#endif // NETDATA_INTERNAL_CHECKS - -#endif // NETDATA_PLUGIN_CHECKS_H diff --git a/collectors/cups.plugin/cups_plugin.c b/collectors/cups.plugin/cups_plugin.c index 1d493619e..a4c94d1d6 100644 --- a/collectors/cups.plugin/cups_plugin.c +++ b/collectors/cups.plugin/cups_plugin.c @@ -7,38 +7,11 @@ */ #include "libnetdata/libnetdata.h" +#include "libnetdata/required_dummies.h" + #include #include -// callback required by fatal() -void netdata_cleanup_and_exit(int ret) { - exit(ret); -} - -void send_statistics( const char *action, const char *action_result, const char *action_data) { - (void) action; - (void) action_result; - (void) action_data; - return; -} - -// callbacks required by popen() -void signals_block(void) {}; -void signals_unblock(void) {}; -void signals_reset(void) {}; - -// callback required by eval() -int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *rc, calculated_number *result) { - (void)variable; - (void)hash; - (void)rc; - (void)result; - return 0; -}; - -// required by get_system_cpus() -char *netdata_configured_host_prefix = ""; - // Variables static int debug = 0; diff --git a/collectors/diskspace.plugin/plugin_diskspace.c b/collectors/diskspace.plugin/plugin_diskspace.c index 2e7d18909..c148e415a 100644 --- a/collectors/diskspace.plugin/plugin_diskspace.c +++ b/collectors/diskspace.plugin/plugin_diskspace.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -#include "plugin_diskspace.h" +#include "../proc.plugin/plugin_proc.h" #define PLUGIN_DISKSPACE_NAME "diskspace.plugin" diff --git a/collectors/diskspace.plugin/plugin_diskspace.h b/collectors/diskspace.plugin/plugin_diskspace.h deleted file mode 100644 index 1f9670879..000000000 --- a/collectors/diskspace.plugin/plugin_diskspace.h +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef NETDATA_PLUGIN_PROC_DISKSPACE_H -#define NETDATA_PLUGIN_PROC_DISKSPACE_H - -#include "daemon/common.h" - - -#if (TARGET_OS == OS_LINUX) - -#define NETDATA_PLUGIN_HOOK_LINUX_DISKSPACE \ - { \ - .name = "PLUGIN[diskspace]", \ - .config_section = CONFIG_SECTION_PLUGINS, \ - .config_name = "diskspace", \ - .enabled = 1, \ - .thread = NULL, \ - .init_routine = NULL, \ - .start_routine = diskspace_main \ - }, - -extern void *diskspace_main(void *ptr); - -#include "../proc.plugin/plugin_proc.h" - -#else // (TARGET_OS == OS_LINUX) - -#define NETDATA_PLUGIN_HOOK_LINUX_DISKSPACE - -#endif // (TARGET_OS == OS_LINUX) - - - -#endif //NETDATA_PLUGIN_PROC_DISKSPACE_H diff --git a/collectors/ebpf.plugin/README.md b/collectors/ebpf.plugin/README.md index 60f1fd742..8fc6809e2 100644 --- a/collectors/ebpf.plugin/README.md +++ b/collectors/ebpf.plugin/README.md @@ -605,7 +605,7 @@ The eBPF collector enables and runs the following eBPF programs by default: - `fd` : This eBPF program creates charts that show information about calls to open files. - `mount`: This eBPF program creates charts that show calls to syscalls mount(2) and umount(2). - `shm`: This eBPF program creates charts that show calls to syscalls shmget(2), shmat(2), shmdt(2) and shmctl(2). -- `sync`: Montitor calls to syscalls sync(2), fsync(2), fdatasync(2), syncfs(2), msync(2), and sync_file_range(2). +- `sync`: Monitor calls to syscalls sync(2), fsync(2), fdatasync(2), syncfs(2), msync(2), and sync_file_range(2). - `network viewer`: This eBPF program creates charts with information about `TCP` and `UDP` functions, including the bandwidth consumed by each. - `vfs`: This eBPF program creates charts that show information about VFS (Virtual File System) functions. diff --git a/collectors/ebpf.plugin/ebpf.c b/collectors/ebpf.plugin/ebpf.c index 71a13e84f..d51d378bd 100644 --- a/collectors/ebpf.plugin/ebpf.c +++ b/collectors/ebpf.plugin/ebpf.c @@ -6,45 +6,8 @@ #include "ebpf.h" #include "ebpf_socket.h" +#include "libnetdata/required_dummies.h" -/***************************************************************** - * - * FUNCTIONS USED BY NETDATA - * - *****************************************************************/ - -// callback required by eval() -int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *rc, calculated_number *result) -{ - UNUSED(variable); - UNUSED(hash); - UNUSED(rc); - UNUSED(result); - return 0; -}; - -void send_statistics(const char *action, const char *action_result, const char *action_data) -{ - UNUSED(action); - UNUSED(action_result); - UNUSED(action_data); -} - -// callbacks required by popen() -void signals_block(void){}; -void signals_unblock(void){}; -void signals_reset(void){}; - -// required by get_system_cpus() -char *netdata_configured_host_prefix = ""; - -// callback required by fatal() -void netdata_cleanup_and_exit(int ret) -{ - exit(ret); -} - -// ---------------------------------------------------------------------- /***************************************************************** * * GLOBAL VARIABLES @@ -64,7 +27,6 @@ struct config collector_config = { .first_section = NULL, .rwlock = AVL_LOCK_INITIALIZER } }; int running_on_kernel = 0; -char kernel_string[64]; int ebpf_nprocs; int isrh = 0; uint32_t finalized_threads = 1; @@ -79,94 +41,127 @@ ebpf_module_t ebpf_modules[] = { .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = ebpf_process_create_apps_charts, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &process_config, - .config_file = NETDATA_PROCESS_CONFIG_FILE}, + .config_file = NETDATA_PROCESS_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4 | NETDATA_V5_10, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "socket", .config_name = "socket", .enabled = 0, .start_routine = ebpf_socket_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = ebpf_socket_create_apps_charts, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &socket_config, - .config_file = NETDATA_NETWORK_CONFIG_FILE}, + .config_file = NETDATA_NETWORK_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "cachestat", .config_name = "cachestat", .enabled = 0, .start_routine = ebpf_cachestat_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = ebpf_cachestat_create_apps_charts, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &cachestat_config, - .config_file = NETDATA_CACHESTAT_CONFIG_FILE}, + .config_file = NETDATA_CACHESTAT_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4 | NETDATA_V5_15, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "sync", .config_name = "sync", .enabled = 0, .start_routine = ebpf_sync_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = NULL, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &sync_config, - .config_file = NETDATA_SYNC_CONFIG_FILE}, + .config_file = NETDATA_SYNC_CONFIG_FILE, + // All syscalls have the same kernels + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "dc", .config_name = "dc", .enabled = 0, .start_routine = ebpf_dcstat_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = ebpf_dcstat_create_apps_charts, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &dcstat_config, - .config_file = NETDATA_DIRECTORY_DCSTAT_CONFIG_FILE}, + .config_file = NETDATA_DIRECTORY_DCSTAT_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "swap", .config_name = "swap", .enabled = 0, .start_routine = ebpf_swap_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = ebpf_swap_create_apps_charts, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &swap_config, - .config_file = NETDATA_DIRECTORY_SWAP_CONFIG_FILE}, + .config_file = NETDATA_DIRECTORY_SWAP_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "vfs", .config_name = "vfs", .enabled = 0, .start_routine = ebpf_vfs_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = ebpf_vfs_create_apps_charts, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &vfs_config, - .config_file = NETDATA_DIRECTORY_VFS_CONFIG_FILE }, + .config_file = NETDATA_DIRECTORY_VFS_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "filesystem", .config_name = "filesystem", .enabled = 0, .start_routine = ebpf_filesystem_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = NULL, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &fs_config, - .config_file = NETDATA_FILESYSTEM_CONFIG_FILE}, + .config_file = NETDATA_FILESYSTEM_CONFIG_FILE, + //We are setting kernels as zero, because we load eBPF programs according the kernel running. + .kernels = 0, .load = EBPF_LOAD_LEGACY, .targets = NULL }, { .thread_name = "disk", .config_name = "disk", .enabled = 0, .start_routine = ebpf_disk_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = NULL, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &disk_config, - .config_file = NETDATA_DISK_CONFIG_FILE}, + .config_file = NETDATA_DISK_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "mount", .config_name = "mount", .enabled = 0, .start_routine = ebpf_mount_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = NULL, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &mount_config, - .config_file = NETDATA_MOUNT_CONFIG_FILE}, + .config_file = NETDATA_MOUNT_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "fd", .config_name = "fd", .enabled = 0, .start_routine = ebpf_fd_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = ebpf_fd_create_apps_charts, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &fd_config, - .config_file = NETDATA_FD_CONFIG_FILE}, + .config_file = NETDATA_FD_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4 | NETDATA_V5_11, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "hardirq", .config_name = "hardirq", .enabled = 0, .start_routine = ebpf_hardirq_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = NULL, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &hardirq_config, - .config_file = NETDATA_HARDIRQ_CONFIG_FILE}, + .config_file = NETDATA_HARDIRQ_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "softirq", .config_name = "softirq", .enabled = 0, .start_routine = ebpf_softirq_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = NULL, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &softirq_config, - .config_file = NETDATA_SOFTIRQ_CONFIG_FILE}, + .config_file = NETDATA_SOFTIRQ_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "oomkill", .config_name = "oomkill", .enabled = 0, .start_routine = ebpf_oomkill_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = ebpf_oomkill_create_apps_charts, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &oomkill_config, - .config_file = NETDATA_OOMKILL_CONFIG_FILE}, + .config_file = NETDATA_OOMKILL_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "shm", .config_name = "shm", .enabled = 0, .start_routine = ebpf_shm_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = ebpf_shm_create_apps_charts, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &shm_config, - .config_file = NETDATA_DIRECTORY_SHM_CONFIG_FILE}, + .config_file = NETDATA_DIRECTORY_SHM_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, { .thread_name = "mdflush", .config_name = "mdflush", .enabled = 0, .start_routine = ebpf_mdflush_thread, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 1, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = NULL, .maps = NULL, .pid_map_size = ND_EBPF_DEFAULT_PID_SIZE, .names = NULL, .cfg = &mdflush_config, - .config_file = NETDATA_DIRECTORY_MDFLUSH_CONFIG_FILE}, - { .thread_name = NULL, .enabled = 0, .start_routine = NULL, .update_every = EBPF_DEFAULT_UPDATE_EVERY, + .config_file = NETDATA_DIRECTORY_MDFLUSH_CONFIG_FILE, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4, + .load = EBPF_LOAD_LEGACY, .targets = NULL}, + { .thread_name = NULL, .enabled = 0, .start_routine = NULL, .update_every = EBPF_DEFAULT_UPDATE_EVERY, .global_charts = 0, .apps_charts = CONFIG_BOOLEAN_NO, .cgroup_charts = CONFIG_BOOLEAN_NO, .mode = MODE_ENTRY, .optional = 0, .apps_routine = NULL, .maps = NULL, .pid_map_size = 0, .names = NULL, - .cfg = NULL, .config_name = NULL}, + .cfg = NULL, .config_name = NULL, .kernels = 0, .load = EBPF_LOAD_LEGACY, .targets = NULL}, }; // Link with apps.plugin @@ -181,6 +176,10 @@ pthread_mutex_t mutex_cgroup_shm; //Network viewer ebpf_network_viewer_options_t network_viewer_opt; +// Statistic +ebpf_plugin_stats_t plugin_statistics = {.core = 0, .legacy = 0, .running = 0, .threads = 0, .tracepoints = 0, + .probes = 0, .retprobes = 0, .trampolines = 0}; + /***************************************************************** * * FUNCTIONS USED TO CLEAN MEMORY AND OPERATE SYSTEM FILES @@ -763,6 +762,20 @@ static inline void ebpf_disable_cgroups() } } +/** + * Update Disabled Plugins + * + * This function calls ebpf_update_stats to update statistics for collector. + * + * @param em a pointer to `struct ebpf_module` + */ +void ebpf_update_disabled_plugin_stats(ebpf_module_t *em) +{ + pthread_mutex_lock(&lock); + ebpf_update_stats(&plugin_statistics, em); + pthread_mutex_unlock(&lock); +} + /** * Print help on standard error for user knows how to use the collector. */ @@ -829,6 +842,10 @@ void ebpf_print_help() " [-]-swap Enable chart related to swap run time.\n" "\n" " [-]-vfs Enable chart related to vfs run time.\n" + "\n" + " [-]-legacy Load legacy eBPF programs.\n" + "\n" + " [-]-core Use CO-RE when available(Working in progress).\n" "\n", VERSION, (year >= 116) ? year + 1900 : 2020); @@ -1339,7 +1356,6 @@ void set_global_variables() isrh = get_redhat_release(); pid_max = get_system_pid_max(); running_on_kernel = ebpf_get_kernel_version(); - ebpf_update_kernel(kernel_string, 63, isrh, running_on_kernel); } /** @@ -1355,6 +1371,19 @@ static inline void ebpf_load_thread_config() } } +/** + * Set Load mode + * + * @param load default load mode. + */ +static inline void ebpf_set_load_mode(netdata_ebpf_load_mode_t load) +{ + int i; + for (i = 0; ebpf_modules[i].thread_name; i++) { + ebpf_modules[i].load = load; + } +} + /** * Parse arguments given from user. * @@ -1391,6 +1420,8 @@ static void ebpf_parse_args(int argc, char **argv) {"help", no_argument, 0, 0 }, {"global", no_argument, 0, 0 }, {"return", no_argument, 0, 0 }, + {"legacy", no_argument, 0, 0 }, + {"core", no_argument, 0, 0 }, {0, 0, 0, 0} }; @@ -1564,6 +1595,20 @@ static void ebpf_parse_args(int argc, char **argv) ebpf_set_thread_mode(MODE_RETURN); #ifdef NETDATA_INTERNAL_CHECKS info("EBPF running in \"RETURN\" mode, because it was started with the option \"[-]-return\"."); +#endif + break; + } + case EBPF_OPTION_LEGACY: { + ebpf_set_load_mode(EBPF_LOAD_LEGACY); +#ifdef NETDATA_INTERNAL_CHECKS + info("EBPF running with \"LEGACY\" code, because it was started with the option \"[-]-legacy\"."); +#endif + break; + } + case EBPF_OPTION_CORE: { + ebpf_set_load_mode(EBPF_LOAD_CORE); +#ifdef NETDATA_INTERNAL_CHECKS + info("EBPF running with \"CO-RE\" code, because it was started with the option \"[-]-core\"."); #endif break; } @@ -1579,8 +1624,6 @@ static void ebpf_parse_args(int argc, char **argv) if (disable_cgroups) ebpf_disable_cgroups(); - - ebpf_enable_all_charts(disable_apps, disable_cgroups); } if (select_threads) { diff --git a/collectors/ebpf.plugin/ebpf.d.conf b/collectors/ebpf.plugin/ebpf.d.conf index 845b711c9..633c53791 100644 --- a/collectors/ebpf.plugin/ebpf.d.conf +++ b/collectors/ebpf.plugin/ebpf.d.conf @@ -41,7 +41,7 @@ # `socket` : This eBPF program creates charts with information about `TCP` and `UDP` functions, including the # bandwidth consumed by each. # `softirq` : Monitor latency of serving software interrupt requests (soft IRQs). -# `sync` : Montitor calls for syscall sync(2). +# `sync` : Monitor calls for syscall sync(2). # `swap` : Monitor calls for internal swap functions. # `vfs` : This eBPF program creates charts that show information about process VFS IO, VFS file manipulation and # files removed. diff --git a/collectors/ebpf.plugin/ebpf.h b/collectors/ebpf.plugin/ebpf.h index a59bad031..165a6bf36 100644 --- a/collectors/ebpf.plugin/ebpf.h +++ b/collectors/ebpf.plugin/ebpf.h @@ -27,6 +27,7 @@ #include "libnetdata/config/appconfig.h" #include "libnetdata/ebpf/ebpf.h" #include "libnetdata/procfile/procfile.h" +#include "collectors/cgroups.plugin/sys_fs_cgroup.h" #include "daemon/main.h" #include "ebpf_apps.h" @@ -96,7 +97,9 @@ enum ebpf_main_index { EBPF_OPTION_VERSION, EBPF_OPTION_HELP, EBPF_OPTION_GLOBAL_CHART, - EBPF_OPTION_RETURN_MODE + EBPF_OPTION_RETURN_MODE, + EBPF_OPTION_LEGACY, + EBPF_OPTION_CORE }; typedef struct ebpf_tracepoint { @@ -126,6 +129,11 @@ typedef struct ebpf_tracepoint { #define NETDATA_SYSTEM_SWAP_SUBMENU "swap" #define NETDATA_SYSTEM_CGROUP_SWAP_SUBMENU "swap (eBPF)" #define NETDATA_SYSTEM_IPC_SHM_SUBMENU "ipc shared memory" +#define NETDATA_MONITORING_FAMILY "netdata" + +// Statistics charts +#define NETDATA_EBPF_THREADS "ebpf_threads" +#define NETDATA_EBPF_LOAD_METHOD "ebpf_load_methods" // Log file #define NETDATA_DEVELOPER_LOG_FILE "developer.log" @@ -159,7 +167,6 @@ extern int ebpf_nprocs; extern int running_on_kernel; extern int isrh; extern char *ebpf_plugin_dir; -extern char kernel_string[64]; extern pthread_mutex_t collect_data_mutex; extern pthread_cond_t collect_data_cond_var; @@ -256,6 +263,7 @@ extern sem_t *shm_sem_ebpf_cgroup; extern pthread_mutex_t mutex_cgroup_shm; extern size_t all_pids_count; extern uint32_t finalized_threads; +extern ebpf_plugin_stats_t plugin_statistics; // Socket functions and variables // Common functions @@ -268,6 +276,7 @@ extern void ebpf_update_pid_table(ebpf_local_maps_t *pid, ebpf_module_t *em); extern void ebpf_write_chart_obsolete(char *type, char *id, char *title, char *units, char *family, char *charttype, char *context, int order, int update_every); extern void write_histogram_chart(char *family, char *name, const netdata_idx_t *hist, char **dimensions, uint32_t end); +void ebpf_update_disabled_plugin_stats(ebpf_module_t *em); #define EBPF_MAX_SYNCHRONIZATION_TIME 300 diff --git a/collectors/ebpf.plugin/ebpf_cachestat.c b/collectors/ebpf.plugin/ebpf_cachestat.c index 7ba8c01ae..0cc16234b 100644 --- a/collectors/ebpf.plugin/ebpf_cachestat.c +++ b/collectors/ebpf.plugin/ebpf_cachestat.c @@ -985,12 +985,15 @@ void *ebpf_cachestat_thread(void *ptr) pthread_mutex_lock(&lock); ebpf_cachestat_allocate_global_vectors(em->apps_charts); - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { pthread_mutex_unlock(&lock); + em->enabled = CONFIG_BOOLEAN_NO; goto endcachestat; } + ebpf_update_stats(&plugin_statistics, em); + int algorithms[NETDATA_CACHESTAT_END] = { NETDATA_EBPF_ABSOLUTE_IDX, NETDATA_EBPF_INCREMENTAL_IDX, NETDATA_EBPF_ABSOLUTE_IDX, NETDATA_EBPF_ABSOLUTE_IDX }; @@ -1006,6 +1009,9 @@ void *ebpf_cachestat_thread(void *ptr) cachestat_collector(em); endcachestat: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; } diff --git a/collectors/ebpf.plugin/ebpf_cachestat.h b/collectors/ebpf.plugin/ebpf_cachestat.h index 7904c8113..8c56d2417 100644 --- a/collectors/ebpf.plugin/ebpf_cachestat.h +++ b/collectors/ebpf.plugin/ebpf_cachestat.h @@ -52,7 +52,7 @@ enum cachestat_indexes { NETDATA_CACHESTAT_IDX_MISS }; -enum cachesta_tables { +enum cachestat_tables { NETDATA_CACHESTAT_GLOBAL_STATS, NETDATA_CACHESTAT_PID_STATS }; diff --git a/collectors/ebpf.plugin/ebpf_dcstat.c b/collectors/ebpf.plugin/ebpf_dcstat.c index 7ae821889..820e24e39 100644 --- a/collectors/ebpf.plugin/ebpf_dcstat.c +++ b/collectors/ebpf.plugin/ebpf_dcstat.c @@ -964,9 +964,10 @@ void *ebpf_dcstat_thread(void *ptr) pthread_mutex_lock(&lock); - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { pthread_mutex_unlock(&lock); + em->enabled = CONFIG_BOOLEAN_NO; goto enddcstat; } @@ -980,11 +981,16 @@ void *ebpf_dcstat_thread(void *ptr) algorithms, NETDATA_DCSTAT_IDX_END); ebpf_create_filesystem_charts(em->update_every); + ebpf_update_stats(&plugin_statistics, em); + pthread_mutex_unlock(&lock); dcstat_collector(em); enddcstat: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; } diff --git a/collectors/ebpf.plugin/ebpf_disk.c b/collectors/ebpf.plugin/ebpf_disk.c index 6e139ec9f..3ddf50b93 100644 --- a/collectors/ebpf.plugin/ebpf_disk.c +++ b/collectors/ebpf.plugin/ebpf_disk.c @@ -817,12 +817,14 @@ void *ebpf_disk_thread(void *ptr) } if (pthread_mutex_init(&plot_mutex, NULL)) { + em->enabled = 0; error("Cannot initialize local mutex"); goto enddisk; } - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { + em->enabled = 0; goto enddisk; } @@ -833,9 +835,16 @@ void *ebpf_disk_thread(void *ptr) ebpf_global_labels(disk_aggregated_data, disk_publish_aggregated, dimensions, dimensions, algorithms, NETDATA_EBPF_HIST_MAX_BINS); + pthread_mutex_lock(&lock); + ebpf_update_stats(&plugin_statistics, em); + pthread_mutex_unlock(&lock); + disk_collector(em); enddisk: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; diff --git a/collectors/ebpf.plugin/ebpf_fd.c b/collectors/ebpf.plugin/ebpf_fd.c index 6eecf5847..10a50c4eb 100644 --- a/collectors/ebpf.plugin/ebpf_fd.c +++ b/collectors/ebpf.plugin/ebpf_fd.c @@ -841,8 +841,9 @@ void *ebpf_fd_thread(void *ptr) ebpf_fd_allocate_global_vectors(em->apps_charts); - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { + em->enabled = CONFIG_BOOLEAN_NO; goto endfd; } @@ -855,11 +856,15 @@ void *ebpf_fd_thread(void *ptr) pthread_mutex_lock(&lock); ebpf_create_fd_global_charts(em); + ebpf_update_stats(&plugin_statistics, em); pthread_mutex_unlock(&lock); fd_collector(em); endfd: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; } diff --git a/collectors/ebpf.plugin/ebpf_filesystem.c b/collectors/ebpf.plugin/ebpf_filesystem.c index ad2c9eff0..415a42dbc 100644 --- a/collectors/ebpf.plugin/ebpf_filesystem.c +++ b/collectors/ebpf.plugin/ebpf_filesystem.c @@ -38,7 +38,8 @@ ebpf_filesystem_partitions_t localfs[] = .probe_links = NULL, .flags = NETDATA_FILESYSTEM_FLAG_NO_PARTITION, .enabled = CONFIG_BOOLEAN_YES, - .addresses = {.function = NULL, .addr = 0}}, + .addresses = {.function = NULL, .addr = 0}, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4}, {.filesystem = "xfs", .optional_filesystem = NULL, .family = "xfs", @@ -46,7 +47,8 @@ ebpf_filesystem_partitions_t localfs[] = .probe_links = NULL, .flags = NETDATA_FILESYSTEM_FLAG_NO_PARTITION, .enabled = CONFIG_BOOLEAN_YES, - .addresses = {.function = NULL, .addr = 0}}, + .addresses = {.function = NULL, .addr = 0}, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4}, {.filesystem = "nfs", .optional_filesystem = "nfs4", .family = "nfs", @@ -54,7 +56,8 @@ ebpf_filesystem_partitions_t localfs[] = .probe_links = NULL, .flags = NETDATA_FILESYSTEM_ATTR_CHARTS, .enabled = CONFIG_BOOLEAN_YES, - .addresses = {.function = NULL, .addr = 0}}, + .addresses = {.function = NULL, .addr = 0}, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4}, {.filesystem = "zfs", .optional_filesystem = NULL, .family = "zfs", @@ -62,7 +65,8 @@ ebpf_filesystem_partitions_t localfs[] = .probe_links = NULL, .flags = NETDATA_FILESYSTEM_FLAG_NO_PARTITION, .enabled = CONFIG_BOOLEAN_YES, - .addresses = {.function = NULL, .addr = 0}}, + .addresses = {.function = NULL, .addr = 0}, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4}, {.filesystem = "btrfs", .optional_filesystem = NULL, .family = "btrfs", @@ -70,7 +74,8 @@ ebpf_filesystem_partitions_t localfs[] = .probe_links = NULL, .flags = NETDATA_FILESYSTEM_FILL_ADDRESS_TABLE, .enabled = CONFIG_BOOLEAN_YES, - .addresses = {.function = "btrfs_file_operations", .addr = 0}}, + .addresses = {.function = "btrfs_file_operations", .addr = 0}, + .kernels = NETDATA_V3_10 | NETDATA_V4_14 | NETDATA_V4_16 | NETDATA_V4_18 | NETDATA_V5_4 | NETDATA_V5_10}, {.filesystem = NULL, .optional_filesystem = NULL, .family = NULL, @@ -78,7 +83,8 @@ ebpf_filesystem_partitions_t localfs[] = .probe_links = NULL, .flags = NETDATA_FILESYSTEM_FLAG_NO_PARTITION, .enabled = CONFIG_BOOLEAN_YES, - .addresses = {.function = NULL, .addr = 0}}}; + .addresses = {.function = NULL, .addr = 0}, + .kernels = 0}}; struct netdata_static_thread filesystem_threads = {"EBPF FS READ", NULL, NULL, 1, NULL, @@ -224,13 +230,16 @@ int ebpf_filesystem_initialize_ebpf_data(ebpf_module_t *em) { int i; const char *saved_name = em->thread_name; + uint64_t kernels = em->kernels; for (i = 0; localfs[i].filesystem; i++) { ebpf_filesystem_partitions_t *efp = &localfs[i]; if (!efp->probe_links && efp->flags & NETDATA_FILESYSTEM_LOAD_EBPF_PROGRAM) { em->thread_name = efp->filesystem; - efp->probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &efp->objects); + em->kernels = efp->kernels; + efp->probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &efp->objects); if (!efp->probe_links) { em->thread_name = saved_name; + em->kernels = kernels; return -1; } efp->flags |= NETDATA_FILESYSTEM_FLAG_HAS_PARTITION; @@ -243,6 +252,7 @@ int ebpf_filesystem_initialize_ebpf_data(ebpf_module_t *em) efp->flags &= ~NETDATA_FILESYSTEM_LOAD_EBPF_PROGRAM; } em->thread_name = saved_name; + em->kernels = kernels; if (!dimensions) { dimensions = ebpf_fill_histogram_dimension(NETDATA_EBPF_HIST_MAX_BINS); @@ -640,7 +650,7 @@ void *ebpf_filesystem_thread(void *ptr) if (em->optional) info("Netdata cannot monitor the filesystems used on this host."); - em->enabled = 0; + em->enabled = CONFIG_BOOLEAN_NO; goto endfilesystem; } @@ -651,11 +661,15 @@ void *ebpf_filesystem_thread(void *ptr) pthread_mutex_lock(&lock); ebpf_create_fs_charts(em->update_every); + ebpf_update_stats(&plugin_statistics, em); pthread_mutex_unlock(&lock); filesystem_collector(em); endfilesystem: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; } diff --git a/collectors/ebpf.plugin/ebpf_filesystem.h b/collectors/ebpf.plugin/ebpf_filesystem.h index 295eec205..8b7c54c58 100644 --- a/collectors/ebpf.plugin/ebpf_filesystem.h +++ b/collectors/ebpf.plugin/ebpf_filesystem.h @@ -60,6 +60,7 @@ typedef struct ebpf_filesystem_partitions { uint32_t enabled; ebpf_addresses_t addresses; + uint64_t kernels; } ebpf_filesystem_partitions_t; extern void *ebpf_filesystem_thread(void *ptr); diff --git a/collectors/ebpf.plugin/ebpf_hardirq.c b/collectors/ebpf.plugin/ebpf_hardirq.c index ff649e9cd..25b2a0ec6 100644 --- a/collectors/ebpf.plugin/ebpf_hardirq.c +++ b/collectors/ebpf.plugin/ebpf_hardirq.c @@ -428,6 +428,7 @@ static void hardirq_collector(ebpf_module_t *em) pthread_mutex_lock(&lock); hardirq_create_charts(em->update_every); hardirq_create_static_dims(); + ebpf_update_stats(&plugin_statistics, em); pthread_mutex_unlock(&lock); // loop and read from published data until ebpf plugin is closed. @@ -480,14 +481,18 @@ void *ebpf_hardirq_thread(void *ptr) goto endhardirq; } - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { + em->enabled = CONFIG_BOOLEAN_NO; goto endhardirq; } hardirq_collector(em); endhardirq: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; diff --git a/collectors/ebpf.plugin/ebpf_mdflush.c b/collectors/ebpf.plugin/ebpf_mdflush.c index e2420ec8e..9f75543d7 100644 --- a/collectors/ebpf.plugin/ebpf_mdflush.c +++ b/collectors/ebpf.plugin/ebpf_mdflush.c @@ -256,6 +256,7 @@ static void mdflush_collector(ebpf_module_t *em) // create chart and static dims. pthread_mutex_lock(&lock); mdflush_create_charts(em->update_every); + ebpf_update_stats(&plugin_statistics, em); pthread_mutex_unlock(&lock); // loop and read from published data until ebpf plugin is closed. @@ -294,18 +295,29 @@ void *ebpf_mdflush_thread(void *ptr) ebpf_module_t *em = (ebpf_module_t *)ptr; em->maps = mdflush_maps; + char *md_flush_request = ebpf_find_symbol("md_flush_request"); + if (!md_flush_request) { + em->enabled = CONFIG_BOOLEAN_NO; + error("Cannot monitor MD devices, because md is not loaded."); + } + freez(md_flush_request); + if (!em->enabled) { goto endmdflush; } - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { + em->enabled = CONFIG_BOOLEAN_NO; goto endmdflush; } mdflush_collector(em); endmdflush: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; diff --git a/collectors/ebpf.plugin/ebpf_mount.c b/collectors/ebpf.plugin/ebpf_mount.c index 46f323471..666936d86 100644 --- a/collectors/ebpf.plugin/ebpf_mount.c +++ b/collectors/ebpf.plugin/ebpf_mount.c @@ -238,8 +238,9 @@ void *ebpf_mount_thread(void *ptr) if (!em->enabled) goto endmount; - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { + em->enabled = CONFIG_BOOLEAN_NO; goto endmount; } @@ -250,11 +251,15 @@ void *ebpf_mount_thread(void *ptr) pthread_mutex_lock(&lock); ebpf_create_mount_charts(em->update_every); + ebpf_update_stats(&plugin_statistics, em); pthread_mutex_unlock(&lock); mount_collector(em); endmount: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; } diff --git a/collectors/ebpf.plugin/ebpf_oomkill.c b/collectors/ebpf.plugin/ebpf_oomkill.c index 7f7df36f9..434fc7fd3 100644 --- a/collectors/ebpf.plugin/ebpf_oomkill.c +++ b/collectors/ebpf.plugin/ebpf_oomkill.c @@ -386,14 +386,22 @@ void *ebpf_oomkill_thread(void *ptr) goto endoomkill; } - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { + em->enabled = CONFIG_BOOLEAN_NO; goto endoomkill; } + pthread_mutex_lock(&lock); + ebpf_update_stats(&plugin_statistics, em); + pthread_mutex_unlock(&lock); + oomkill_collector(em); endoomkill: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; diff --git a/collectors/ebpf.plugin/ebpf_process.c b/collectors/ebpf.plugin/ebpf_process.c index a4a6709e8..d61bdf66c 100644 --- a/collectors/ebpf.plugin/ebpf_process.c +++ b/collectors/ebpf.plugin/ebpf_process.c @@ -58,6 +58,10 @@ struct config process_config = { .first_section = NULL, static struct netdata_static_thread cgroup_thread = {"EBPF CGROUP", NULL, NULL, 1, NULL, NULL, NULL}; + +static char *threads_stat[NETDATA_EBPF_THREAD_STAT_END] = {"total", "running"}; +static char *load_event_stat[NETDATA_EBPF_LOAD_STAT_END] = {"legacy", "co-re"}; + /***************************************************************** * * PROCESS DATA AND SEND TO NETDATA @@ -434,6 +438,78 @@ static void ebpf_create_global_charts(ebpf_module_t *em) } } +/** + * Create chart for Statistic Thread + * + * Write to standard output current values for threads. + * + * @param em a pointer to the structure with the default values. + */ +static inline void ebpf_create_statistic_thread_chart(ebpf_module_t *em) +{ + ebpf_write_chart_cmd(NETDATA_MONITORING_FAMILY, + NETDATA_EBPF_THREADS, + "Threads info.", + "threads", + NETDATA_EBPF_FAMILY, + NETDATA_EBPF_CHART_TYPE_LINE, + NULL, + 140000, + em->update_every, + NETDATA_EBPF_MODULE_NAME_PROCESS); + + ebpf_write_global_dimension(threads_stat[NETDATA_EBPF_THREAD_STAT_TOTAL], + threads_stat[NETDATA_EBPF_THREAD_STAT_TOTAL], + ebpf_algorithms[NETDATA_EBPF_ABSOLUTE_IDX]); + + ebpf_write_global_dimension(threads_stat[NETDATA_EBPF_THREAD_STAT_RUNNING], + threads_stat[NETDATA_EBPF_THREAD_STAT_RUNNING], + ebpf_algorithms[NETDATA_EBPF_ABSOLUTE_IDX]); +} + +/** + * Create chart for Load Thread + * + * Write to standard output current values for load mode. + * + * @param em a pointer to the structure with the default values. + */ +static inline void ebpf_create_statistic_load_chart(ebpf_module_t *em) +{ + ebpf_write_chart_cmd(NETDATA_MONITORING_FAMILY, + NETDATA_EBPF_LOAD_METHOD, + "Load info.", + "methods", + NETDATA_EBPF_FAMILY, + NETDATA_EBPF_CHART_TYPE_LINE, + NULL, + 140001, + em->update_every, + NETDATA_EBPF_MODULE_NAME_PROCESS); + + ebpf_write_global_dimension(load_event_stat[NETDATA_EBPF_LOAD_STAT_LEGACY], + load_event_stat[NETDATA_EBPF_LOAD_STAT_LEGACY], + ebpf_algorithms[NETDATA_EBPF_ABSOLUTE_IDX]); + + ebpf_write_global_dimension(load_event_stat[NETDATA_EBPF_LOAD_STAT_CORE], + load_event_stat[NETDATA_EBPF_LOAD_STAT_CORE], + ebpf_algorithms[NETDATA_EBPF_ABSOLUTE_IDX]); +} + +/** + * Create Statistics Charts + * + * Create charts that will show statistics related to eBPF plugin. + * + * @param em a pointer to the structure with the default values. + */ +static void ebpf_create_statistic_charts(ebpf_module_t *em) +{ + ebpf_create_statistic_thread_chart(em); + + ebpf_create_statistic_load_chart(em); +} + /** * Create process apps charts * @@ -912,6 +988,24 @@ void ebpf_process_update_cgroup_algorithm() } } +/** + * Send Statistic Data + * + * Send statistic information to netdata. + */ +void ebpf_send_statistic_data() +{ + write_begin_chart(NETDATA_MONITORING_FAMILY, NETDATA_EBPF_THREADS); + write_chart_dimension(threads_stat[NETDATA_EBPF_THREAD_STAT_TOTAL], (long long)plugin_statistics.threads); + write_chart_dimension(threads_stat[NETDATA_EBPF_THREAD_STAT_RUNNING], (long long)plugin_statistics.running); + write_end_chart(); + + write_begin_chart(NETDATA_MONITORING_FAMILY, NETDATA_EBPF_LOAD_METHOD); + write_chart_dimension(load_event_stat[NETDATA_EBPF_LOAD_STAT_LEGACY], (long long)plugin_statistics.legacy); + write_chart_dimension(load_event_stat[NETDATA_EBPF_LOAD_STAT_CORE], (long long)plugin_statistics.core); + write_end_chart(); +} + /** * Main loop for this collector. * @@ -967,8 +1061,10 @@ static void process_collector(ebpf_module_t *em) } } + pthread_mutex_lock(&lock); + ebpf_send_statistic_data(); + if (thread_enabled) { - pthread_mutex_lock(&lock); if (publish_global) { ebpf_process_send_data(em); } @@ -980,12 +1076,10 @@ static void process_collector(ebpf_module_t *em) if (cgroups) { ebpf_process_send_cgroup_data(em); } - pthread_mutex_unlock(&lock); } + pthread_mutex_unlock(&lock); } - pthread_mutex_unlock(&lock); - fflush(stdout); } } @@ -1212,8 +1306,9 @@ void *ebpf_process_thread(void *ptr) ebpf_update_pid_table(&process_maps[0], em); set_local_pointers(); - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { + em->enabled = CONFIG_BOOLEAN_NO; pthread_mutex_unlock(&lock); goto endprocess; } @@ -1230,11 +1325,17 @@ void *ebpf_process_thread(void *ptr) ebpf_create_global_charts(em); } + ebpf_update_stats(&plugin_statistics, em); + ebpf_create_statistic_charts(em); + pthread_mutex_unlock(&lock); process_collector(em); endprocess: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + wait_for_all_threads_die(); netdata_thread_cleanup_pop(1); return NULL; diff --git a/collectors/ebpf.plugin/ebpf_process.h b/collectors/ebpf.plugin/ebpf_process.h index 73421049e..b0377b5db 100644 --- a/collectors/ebpf.plugin/ebpf_process.h +++ b/collectors/ebpf.plugin/ebpf_process.h @@ -39,6 +39,21 @@ #define NETDATA_SYSTEMD_PROCESS_EXIT_CONTEXT "services.task_exit" #define NETDATA_SYSTEMD_PROCESS_ERROR_CONTEXT "services.task_error" +// Statistical information +enum netdata_ebpf_thread_stats{ + NETDATA_EBPF_THREAD_STAT_TOTAL, + NETDATA_EBPF_THREAD_STAT_RUNNING, + + NETDATA_EBPF_THREAD_STAT_END +}; + +enum netdata_ebpf_load_mode_stats{ + NETDATA_EBPF_LOAD_STAT_LEGACY, + NETDATA_EBPF_LOAD_STAT_CORE, + + NETDATA_EBPF_LOAD_STAT_END +}; + // Index from kernel typedef enum ebpf_process_index { NETDATA_KEY_CALLS_DO_EXIT, diff --git a/collectors/ebpf.plugin/ebpf_shm.c b/collectors/ebpf.plugin/ebpf_shm.c index 156ae9aa5..0cfb3abdc 100644 --- a/collectors/ebpf.plugin/ebpf_shm.c +++ b/collectors/ebpf.plugin/ebpf_shm.c @@ -821,8 +821,9 @@ void *ebpf_shm_thread(void *ptr) goto endshm; } - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { + em->enabled = CONFIG_BOOLEAN_NO; goto endshm; } @@ -845,11 +846,15 @@ void *ebpf_shm_thread(void *ptr) pthread_mutex_lock(&lock); ebpf_create_shm_charts(em->update_every); + ebpf_update_stats(&plugin_statistics, em); pthread_mutex_unlock(&lock); shm_collector(em); endshm: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; } diff --git a/collectors/ebpf.plugin/ebpf_socket.c b/collectors/ebpf.plugin/ebpf_socket.c index f7710ff22..b59367f58 100644 --- a/collectors/ebpf.plugin/ebpf_socket.c +++ b/collectors/ebpf.plugin/ebpf_socket.c @@ -3363,6 +3363,7 @@ void *ebpf_socket_thread(void *ptr) goto endsocket; if (pthread_mutex_init(&nv_mutex, NULL)) { + em->enabled = CONFIG_BOOLEAN_NO; error("Cannot initialize local mutex"); goto endsocket; } @@ -3374,8 +3375,9 @@ void *ebpf_socket_thread(void *ptr) if (running_on_kernel < NETDATA_EBPF_KERNEL_5_0) em->mode = MODE_ENTRY; - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { + em->enabled = CONFIG_BOOLEAN_NO; pthread_mutex_unlock(&lock); goto endsocket; } @@ -3390,12 +3392,17 @@ void *ebpf_socket_thread(void *ptr) ebpf_create_global_charts(em); + ebpf_update_stats(&plugin_statistics, em); + finalized_threads = 0; pthread_mutex_unlock(&lock); socket_collector((usec_t)(em->update_every * USEC_PER_SEC), em); endsocket: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; } diff --git a/collectors/ebpf.plugin/ebpf_softirq.c b/collectors/ebpf.plugin/ebpf_softirq.c index 119c1222a..f5e79279f 100644 --- a/collectors/ebpf.plugin/ebpf_softirq.c +++ b/collectors/ebpf.plugin/ebpf_softirq.c @@ -209,6 +209,7 @@ static void softirq_collector(ebpf_module_t *em) pthread_mutex_lock(&lock); softirq_create_charts(em->update_every); softirq_create_dims(); + ebpf_update_stats(&plugin_statistics, em); pthread_mutex_unlock(&lock); // loop and read from published data until ebpf plugin is closed. @@ -259,14 +260,18 @@ void *ebpf_softirq_thread(void *ptr) goto endsoftirq; } - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { + em->enabled = CONFIG_BOOLEAN_NO; goto endsoftirq; } softirq_collector(em); endsoftirq: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; diff --git a/collectors/ebpf.plugin/ebpf_swap.c b/collectors/ebpf.plugin/ebpf_swap.c index 34750c79d..82eb9db88 100644 --- a/collectors/ebpf.plugin/ebpf_swap.c +++ b/collectors/ebpf.plugin/ebpf_swap.c @@ -675,8 +675,9 @@ void *ebpf_swap_thread(void *ptr) if (!em->enabled) goto endswap; - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { + em->enabled = CONFIG_BOOLEAN_NO; goto endswap; } @@ -688,11 +689,15 @@ void *ebpf_swap_thread(void *ptr) pthread_mutex_lock(&lock); ebpf_create_swap_charts(em->update_every); + ebpf_update_stats(&plugin_statistics, em); pthread_mutex_unlock(&lock); swap_collector(em); endswap: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; } diff --git a/collectors/ebpf.plugin/ebpf_sync.c b/collectors/ebpf.plugin/ebpf_sync.c index 4bd62bcae..b3f1b6524 100644 --- a/collectors/ebpf.plugin/ebpf_sync.c +++ b/collectors/ebpf.plugin/ebpf_sync.c @@ -74,7 +74,7 @@ static int ebpf_sync_initialize_syscall(ebpf_module_t *em) ebpf_sync_syscalls_t *w = &local_syscalls[i]; if (!w->probe_links && w->enabled) { em->thread_name = w->syscall; - w->probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &w->objects); + w->probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &w->objects); if (!w->probe_links) { em->thread_name = saved_name; return -1; @@ -387,7 +387,7 @@ void *ebpf_sync_thread(void *ptr) goto endsync; if (ebpf_sync_initialize_syscall(em)) { - pthread_mutex_unlock(&lock); + em->enabled = CONFIG_BOOLEAN_NO; goto endsync; } @@ -400,11 +400,15 @@ void *ebpf_sync_thread(void *ptr) pthread_mutex_lock(&lock); ebpf_create_sync_charts(em->update_every); + ebpf_update_stats(&plugin_statistics, em); pthread_mutex_unlock(&lock); sync_collector(em); endsync: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; } diff --git a/collectors/ebpf.plugin/ebpf_sync.h b/collectors/ebpf.plugin/ebpf_sync.h index 1f811d341..e40c77a3f 100644 --- a/collectors/ebpf.plugin/ebpf_sync.h +++ b/collectors/ebpf.plugin/ebpf_sync.h @@ -47,7 +47,7 @@ enum netdata_sync_charts { }; enum netdata_sync_table { - NETDATA_SYNC_GLOBLAL_TABLE + NETDATA_SYNC_GLOBAL_TABLE }; extern void *ebpf_sync_thread(void *ptr); diff --git a/collectors/ebpf.plugin/ebpf_vfs.c b/collectors/ebpf.plugin/ebpf_vfs.c index 060469ec5..d1c418f85 100644 --- a/collectors/ebpf.plugin/ebpf_vfs.c +++ b/collectors/ebpf.plugin/ebpf_vfs.c @@ -1576,8 +1576,9 @@ void *ebpf_vfs_thread(void *ptr) if (!em->enabled) goto endvfs; - probe_links = ebpf_load_program(ebpf_plugin_dir, em, kernel_string, &objects); + probe_links = ebpf_load_program(ebpf_plugin_dir, em, running_on_kernel, isrh, &objects); if (!probe_links) { + em->enabled = CONFIG_BOOLEAN_NO; goto endvfs; } @@ -1591,11 +1592,15 @@ void *ebpf_vfs_thread(void *ptr) pthread_mutex_lock(&lock); ebpf_create_global_charts(em); + ebpf_update_stats(&plugin_statistics, em); pthread_mutex_unlock(&lock); vfs_collector(em); endvfs: + if (!em->enabled) + ebpf_update_disabled_plugin_stats(em); + netdata_thread_cleanup_pop(1); return NULL; } diff --git a/collectors/freebsd.plugin/plugin_freebsd.h b/collectors/freebsd.plugin/plugin_freebsd.h index ab46080be..26f76b6bf 100644 --- a/collectors/freebsd.plugin/plugin_freebsd.h +++ b/collectors/freebsd.plugin/plugin_freebsd.h @@ -5,20 +5,6 @@ #include "daemon/common.h" -#if (TARGET_OS == OS_FREEBSD) - -#define NETDATA_PLUGIN_HOOK_FREEBSD \ - { \ - .name = "PLUGIN[freebsd]", \ - .config_section = CONFIG_SECTION_PLUGINS, \ - .config_name = "freebsd", \ - .enabled = 1, \ - .thread = NULL, \ - .init_routine = NULL, \ - .start_routine = freebsd_main \ - }, - - #include #define KILO_FACTOR 1024 @@ -27,8 +13,6 @@ #define MAX_INT_DIGITS 10 // maximum number of digits for int -void *freebsd_main(void *ptr); - extern int freebsd_plugin_init(); extern int do_vm_loadavg(int update_every, usec_t dt); @@ -65,10 +49,4 @@ extern int do_kstat_zfs_misc_arcstats(int update_every, usec_t dt); extern int do_kstat_zfs_misc_zio_trim(int update_every, usec_t dt); extern int do_ipfw(int update_every, usec_t dt); -#else // (TARGET_OS == OS_FREEBSD) - -#define NETDATA_PLUGIN_HOOK_FREEBSD - -#endif // (TARGET_OS == OS_FREEBSD) - #endif /* NETDATA_PLUGIN_FREEBSD_H */ diff --git a/collectors/freeipmi.plugin/freeipmi_plugin.c b/collectors/freeipmi.plugin/freeipmi_plugin.c index 0141a6a78..6c6f3d747 100644 --- a/collectors/freeipmi.plugin/freeipmi_plugin.c +++ b/collectors/freeipmi.plugin/freeipmi_plugin.c @@ -16,6 +16,7 @@ */ #include "libnetdata/libnetdata.h" +#include "libnetdata/required_dummies.h" #include #include @@ -40,39 +41,6 @@ #define IPMI_PARSE_DEVICE_SUNBMC_STR2 "bmc" #define IPMI_PARSE_DEVICE_INTELDCMI_STR "inteldcmi" -// ---------------------------------------------------------------------------- - -// callback required by fatal() -void netdata_cleanup_and_exit(int ret) { - exit(ret); -} - -void send_statistics( const char *action, const char *action_result, const char *action_data) { - (void)action; - (void)action_result; - (void)action_data; - return; -} - -// callbacks required by popen() -void signals_block(void) {}; -void signals_unblock(void) {}; -void signals_reset(void) {}; - -// callback required by eval() -int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *rc, calculated_number *result) { - (void)variable; - (void)hash; - (void)rc; - (void)result; - return 0; -}; - -// required by get_system_cpus() -char *netdata_configured_host_prefix = ""; - -// ---------------------------------------------------------------------------- - #include #include diff --git a/collectors/idlejitter.plugin/README.md b/collectors/idlejitter.plugin/README.md index 3703e2ee2..40436d33c 100644 --- a/collectors/idlejitter.plugin/README.md +++ b/collectors/idlejitter.plugin/README.md @@ -5,7 +5,9 @@ custom_edit_url: https://github.com/netdata/netdata/edit/master/collectors/idlej # idlejitter.plugin -It works like this: +Idle jitter is a measure of delays in timing for user processes caused by scheduling limitations. + +## How Netdata measures idle jitter A thread is spawned that requests to sleep for 20000 microseconds (20ms). When the system wakes it up, it measures how many microseconds have passed. @@ -14,7 +16,17 @@ This is done at most 50 times per second, to ensure we have a good average. This number is useful: -1. in real-time environments, when the CPU jitter can affect the quality of the service (like VoIP media gateways). -2. in cloud infrastructure, at can pause the VM or container for a small duration to perform operations at the host. +- In multimedia-streaming environments such as VoIP gateways, where the CPU jitter can affect the quality of the service. +- On time servers and other systems that require very precise timing, where CPU jitter can actively interfere with timing precision. +- On gaming systems, where CPU jitter can cause frame drops and stuttering. +- In cloud infrastructure that can pause the VM or container for a small duration to perform operations at the host. + +## Charts + +idlejitter.plugin generates the idlejitter chart which measures CPU idle jitter in milliseconds lost per second. + +## Configuration + +This chart is available without any configuration. [![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fidlejitter.plugin%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>) diff --git a/collectors/idlejitter.plugin/plugin_idlejitter.c b/collectors/idlejitter.plugin/plugin_idlejitter.c index c59541ecb..12ab8601a 100644 --- a/collectors/idlejitter.plugin/plugin_idlejitter.c +++ b/collectors/idlejitter.plugin/plugin_idlejitter.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -#include "plugin_idlejitter.h" +#include "daemon/common.h" #define CPU_IDLEJITTER_SLEEP_TIME_MS 20 diff --git a/collectors/idlejitter.plugin/plugin_idlejitter.h b/collectors/idlejitter.plugin/plugin_idlejitter.h deleted file mode 100644 index 6da78a085..000000000 --- a/collectors/idlejitter.plugin/plugin_idlejitter.h +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef NETDATA_PLUGIN_IDLEJITTER_H -#define NETDATA_PLUGIN_IDLEJITTER_H 1 - -#include "daemon/common.h" - -#define NETDATA_PLUGIN_HOOK_IDLEJITTER \ - { \ - .name = "PLUGIN[idlejitter]", \ - .config_section = CONFIG_SECTION_PLUGINS, \ - .config_name = "idlejitter", \ - .enabled = 1, \ - .thread = NULL, \ - .init_routine = NULL, \ - .start_routine = cpuidlejitter_main \ - }, - -extern void *cpuidlejitter_main(void *ptr); - -#endif /* NETDATA_PLUGIN_IDLEJITTER_H */ diff --git a/collectors/macos.plugin/plugin_macos.h b/collectors/macos.plugin/plugin_macos.h index a66ec0852..b4c2cf542 100644 --- a/collectors/macos.plugin/plugin_macos.h +++ b/collectors/macos.plugin/plugin_macos.h @@ -1,43 +1,12 @@ // SPDX-License-Identifier: GPL-3.0-or-later - #ifndef NETDATA_PLUGIN_MACOS_H #define NETDATA_PLUGIN_MACOS_H 1 #include "daemon/common.h" -#if (TARGET_OS == OS_MACOS) - -#define NETDATA_PLUGIN_HOOK_MACOS \ - { \ - .name = "PLUGIN[macos]", \ - .config_section = CONFIG_SECTION_PLUGINS, \ - .config_name = "macos", \ - .enabled = 1, \ - .thread = NULL, \ - .init_routine = NULL, \ - .start_routine = macos_main \ - }, - -void *macos_main(void *ptr); - -#define GETSYSCTL_BY_NAME(name, var) getsysctl_by_name(name, &(var), sizeof(var)) - -extern int getsysctl_by_name(const char *name, void *ptr, size_t len); - extern int do_macos_sysctl(int update_every, usec_t dt); extern int do_macos_mach_smi(int update_every, usec_t dt); extern int do_macos_iokit(int update_every, usec_t dt); - -#else // (TARGET_OS == OS_MACOS) - -#define NETDATA_PLUGIN_HOOK_MACOS - -#endif // (TARGET_OS == OS_MACOS) - - - - - #endif /* NETDATA_PLUGIN_MACOS_H */ diff --git a/collectors/nfacct.plugin/plugin_nfacct.c b/collectors/nfacct.plugin/plugin_nfacct.c index 7876c231f..35209a281 100644 --- a/collectors/nfacct.plugin/plugin_nfacct.c +++ b/collectors/nfacct.plugin/plugin_nfacct.c @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "libnetdata/libnetdata.h" +#include "libnetdata/required_dummies.h" + #include #include #include @@ -22,34 +24,6 @@ static inline size_t mnl_buffer_size() { return (size_t)s; } -// callback required by fatal() -void netdata_cleanup_and_exit(int ret) { - exit(ret); -} - -void send_statistics( const char *action, const char *action_result, const char *action_data) { - (void) action; - (void) action_result; - (void) action_data; - return; -} - -// callbacks required by popen() -void signals_block(void) {}; -void signals_unblock(void) {}; -void signals_reset(void) {}; - -// callback required by eval() -int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *rc, calculated_number *result) { - (void)variable; - (void)hash; - (void)rc; - (void)result; - return 0; -}; - -// required by get_system_cpus() -char *netdata_configured_host_prefix = ""; // variables static int debug = 0; static int netdata_update_every = 1; @@ -690,7 +664,11 @@ static void nfacct_send_metrics() { if(likely(d->updated)) { if(unlikely(!d->packets_dimension_added)) { d->packets_dimension_added = 1; - printf("CHART netfilter.nfacct_packets '' 'Netfilter Accounting Packets' 'packets/s'\n"); + printf( + "CHART netfilter.nfacct_packets '' 'Netfilter Accounting Packets' 'packets/s' 'nfacct' '' stacked %d %d %s\n", + NETDATA_CHART_PRIO_NETFILTER_PACKETS, + nfacct_root.update_every, + PLUGIN_NFACCT_NAME); printf("DIMENSION %s '' incremental 1 %d\n", d->name, nfacct_root.update_every); } } @@ -721,7 +699,11 @@ static void nfacct_send_metrics() { if(likely(d->updated)) { if(unlikely(!d->bytes_dimension_added)) { d->bytes_dimension_added = 1; - printf("CHART netfilter.nfacct_bytes '' 'Netfilter Accounting Bandwidth' 'kilobytes/s'\n"); + printf( + "CHART netfilter.nfacct_bytes '' 'Netfilter Accounting Bandwidth' 'kilobytes/s' 'nfacct' '' stacked %d %d %s\n", + NETDATA_CHART_PRIO_NETFILTER_BYTES, + nfacct_root.update_every, + PLUGIN_NFACCT_NAME); printf("DIMENSION %s '' incremental 1 %d\n", d->name, 1000 * nfacct_root.update_every); } } diff --git a/collectors/node.d.plugin/sma_webbox/README.md b/collectors/node.d.plugin/sma_webbox/README.md index ec6b248c3..99e093b70 100644 --- a/collectors/node.d.plugin/sma_webbox/README.md +++ b/collectors/node.d.plugin/sma_webbox/README.md @@ -6,7 +6,7 @@ sidebar_label: "SMA Sunny WebBox" # SMA Sunny WebBox monitoring with Netdata -Montiroing for the [SMA Sunny +Monitoring for the [SMA Sunny WebBox](https://www.sma-sunny.com/en/questions-and-answers-on-discontinuation-of-the-sunny-webbox/). The module supports any number of name servers: diff --git a/collectors/node.d.plugin/snmp/README.md b/collectors/node.d.plugin/snmp/README.md index 93ade5e64..df6d7eaca 100644 --- a/collectors/node.d.plugin/snmp/README.md +++ b/collectors/node.d.plugin/snmp/README.md @@ -183,37 +183,50 @@ The `options` given for each server, are: To use SNMPv3: -- set `version` to 3 - use `user` instead of `community` +- set `version` to 3 User syntax: ```json { - "user": { + "enable_autodetect": false, + "update_every": 10, + "servers": [ + { + "hostname": "10.11.12.8", + "user": { "name": "userName", "level": 3, "authProtocol": "3", "authKey": "authKey", "privProtocol": "2", "privKey": "privKey" + }, + "update_every": 10, + "options": { + "version": 3 + }, + "charts": { + } } + ] } ``` -Security levels: +Security levels (`level`): - 1 is `noAuthNoPriv` - 2 is `authNoPriv` - 3 is `authPriv` -Authentication protocols: +Authentication protocols (`authProtocol`): - "1" is `none` - "2" is `md5` - "3" is `sha` -Privacy protocols: +Privacy protocols (`privProtocol`): - "1" is `none` - "2" is `des` diff --git a/collectors/perf.plugin/perf_plugin.c b/collectors/perf.plugin/perf_plugin.c index 151ba9078..4020cf066 100644 --- a/collectors/perf.plugin/perf_plugin.c +++ b/collectors/perf.plugin/perf_plugin.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "libnetdata/libnetdata.h" +#include "libnetdata/required_dummies.h" #include @@ -29,37 +30,6 @@ #define NETDATA_CHART_PRIO_PERF_ITLB 8825 #define NETDATA_CHART_PRIO_PERF_PBU 8826 -// callback required by fatal() -void netdata_cleanup_and_exit(int ret) { - exit(ret); -} - -void send_statistics( const char *action, const char *action_result, const char *action_data) { - (void) action; - (void) action_result; - (void) action_data; - return; -} - -// callbacks required by popen() -void signals_block(void) {}; -void signals_unblock(void) {}; -void signals_reset(void) {}; - -// callback required by eval() -int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *rc, calculated_number *result) { - (void)variable; - (void)hash; - (void)rc; - (void)result; - return 0; -}; - -// required by get_system_cpus() -char *netdata_configured_host_prefix = ""; - -// Variables - #define RRD_TYPE_PERF "perf" #define RRD_FAMILY_HW "hardware" #define RRD_FAMILY_SW "software" diff --git a/collectors/plugins.d/plugins_d.h b/collectors/plugins.d/plugins_d.h index b9e30e12b..8f0b02857 100644 --- a/collectors/plugins.d/plugins_d.h +++ b/collectors/plugins.d/plugins_d.h @@ -5,18 +5,6 @@ #include "daemon/common.h" -#define NETDATA_PLUGIN_HOOK_PLUGINSD \ - { \ - .name = "PLUGINSD", \ - .config_section = NULL, \ - .config_name = NULL, \ - .enabled = 1, \ - .thread = NULL, \ - .init_routine = NULL, \ - .start_routine = pluginsd_main \ - }, - - #define PLUGINSD_FILE_SUFFIX ".plugin" #define PLUGINSD_FILE_SUFFIX_LEN strlen(PLUGINSD_FILE_SUFFIX) #define PLUGINSD_CMD_MAX (FILENAME_MAX*2) @@ -71,8 +59,6 @@ struct plugind { extern struct plugind *pluginsd_root; -extern void *pluginsd_main(void *ptr); - extern size_t pluginsd_process(RRDHOST *host, struct plugind *cd, FILE *fp, int trust_durations); extern int pluginsd_split_words(char *str, char **words, int max_words, char *recover_string, char **recover_location, int max_recover); diff --git a/collectors/proc.plugin/plugin_proc.h b/collectors/proc.plugin/plugin_proc.h index 18714b548..60a5a78a2 100644 --- a/collectors/proc.plugin/plugin_proc.h +++ b/collectors/proc.plugin/plugin_proc.h @@ -5,25 +5,9 @@ #include "daemon/common.h" -#if (TARGET_OS == OS_LINUX) - -#define NETDATA_PLUGIN_HOOK_LINUX_PROC \ - { \ - .name = "PLUGIN[proc]", \ - .config_section = CONFIG_SECTION_PLUGINS, \ - .config_name = "proc", \ - .enabled = 1, \ - .thread = NULL, \ - .init_routine = NULL, \ - .start_routine = proc_main \ - }, - - #define PLUGIN_PROC_CONFIG_NAME "proc" #define PLUGIN_PROC_NAME PLUGIN_PROC_CONFIG_NAME ".plugin" -extern void *proc_main(void *ptr); - extern int do_proc_net_dev(int update_every, usec_t dt); extern int do_proc_net_wireless(int update_every, usec_t dt); extern int do_proc_diskstats(int update_every, usec_t dt); @@ -74,11 +58,4 @@ extern void netdev_rename_device_del(const char *host_device); #include "proc_pressure.h" #include "zfs_common.h" -#else // (TARGET_OS == OS_LINUX) - -#define NETDATA_PLUGIN_HOOK_LINUX_PROC - -#endif // (TARGET_OS == OS_LINUX) - - #endif /* NETDATA_PLUGIN_PROC_H */ diff --git a/collectors/proc.plugin/sys_class_infiniband.c b/collectors/proc.plugin/sys_class_infiniband.c index 1a75ce13f..7e63bcbb4 100644 --- a/collectors/proc.plugin/sys_class_infiniband.c +++ b/collectors/proc.plugin/sys_class_infiniband.c @@ -481,8 +481,11 @@ int do_sys_class_infiniband(int update_every, usec_t dt) if (!p->discovered) info( - "Infiniband card %s port %s at speed %lu width %lu", dev_dent->d_name, port_dent->d_name, - p->speed, p->width); + "Infiniband card %s port %s at speed %" PRIu64 " width %" PRIu64 "", + dev_dent->d_name, + port_dent->d_name, + p->speed, + p->width); p->discovered = 1; } @@ -537,7 +540,8 @@ int do_sys_class_infiniband(int update_every, usec_t dt) rrdset_flag_set(port->st_bytes, RRDSET_FLAG_DETAIL); // On this chart, we want to have a KB/s so the dashboard will autoscale it // The reported values are also per-lane, so we must multiply it by the width - FOREACH_COUNTER_BYTES(GEN_RRD_DIM_ADD_CUSTOM, port, 8 * port->width, 1024, RRD_ALGORITHM_INCREMENTAL) + // x4 lanes multiplier as per Documentation/ABI/stable/sysfs-class-infiniband + FOREACH_COUNTER_BYTES(GEN_RRD_DIM_ADD_CUSTOM, port, 4 * 8 * port->width, 1024, RRD_ALGORITHM_INCREMENTAL) port->stv_speed = rrdsetvar_custom_chart_variable_create(port->st_bytes, "link_speed"); } else diff --git a/collectors/python.d.plugin/anomalies/README.md b/collectors/python.d.plugin/anomalies/README.md index c58c858bf..3552053ee 100644 --- a/collectors/python.d.plugin/anomalies/README.md +++ b/collectors/python.d.plugin/anomalies/README.md @@ -229,6 +229,7 @@ If you would like to go deeper on what exactly the anomalies collector is doing - If you activate this collector on a fresh node, it might take a little while to build up enough data to calculate a realistic and useful model. - Some models like `iforest` can be comparatively expensive (on same n1-standard-2 system above ~2s runtime during predict, ~40s training time, ~50% cpu on both train and predict) so if you would like to use it you might be advised to set a relatively high `update_every` maybe 10, 15 or 30 in `anomalies.conf`. - Setting a higher `train_every_n` and `update_every` is an easy way to devote less resources on the node to anomaly detection. Specifying less charts and a lower `train_n_secs` will also help reduce resources at the expense of covering less charts and maybe a more noisy model if you set `train_n_secs` to be too small for how your node tends to behave. +- If you would like to enable this on a Rasberry Pi, then check out [this guide](https://learn.netdata.cloud/guides/monitor/raspberry-pi-anomaly-detection) which will guide you through first installing LLVM. ## Useful links and further reading @@ -240,4 +241,4 @@ If you would like to go deeper on what exactly the anomalies collector is doing - Good [blog post](https://www.anodot.com/blog/what-is-anomaly-detection/) from Anodot on time series anomaly detection. Anodot also have some great whitepapers in this space too that some may find useful. - Novelty and outlier detection in the [scikit-learn documentation](https://scikit-learn.org/stable/modules/outlier_detection.html). -[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fpython.d.plugin%2Fanomalies%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]() \ No newline at end of file +[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fpython.d.plugin%2Fanomalies%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]() diff --git a/collectors/python.d.plugin/example/README.md b/collectors/python.d.plugin/example/README.md index 561ea62ed..b1c21ecbc 100644 --- a/collectors/python.d.plugin/example/README.md +++ b/collectors/python.d.plugin/example/README.md @@ -5,7 +5,10 @@ custom_edit_url: https://github.com/netdata/netdata/edit/master/collectors/pytho # Example -An example python data collection module. -You can use this example to help you [write a new Python module](../#how-to-write-a-new-module). +You can add custom data collectors using Python. + +Netdata provides an [example python data collection module](https://github.com/netdata/netdata/tree/master/collectors/python.d.plugin/example). + +If you want to write your own collector, read our [writing a new Python module](/collectors/python.d.plugin/README.md#how-to-write-a-new-module) tutorial. [![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fcollectors%2Fpython.d.plugin%2Fexample%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)](<>) diff --git a/collectors/python.d.plugin/fail2ban/README.md b/collectors/python.d.plugin/fail2ban/README.md index c1ad994a5..90a59dce0 100644 --- a/collectors/python.d.plugin/fail2ban/README.md +++ b/collectors/python.d.plugin/fail2ban/README.md @@ -10,14 +10,55 @@ Monitors the fail2ban log file to show all bans for all active jails. ## Requirements -- fail2ban.log file MUST BE readable by Netdata (A good idea is to add **create 0640 root netdata** to fail2ban conf at logrotate.d) +The `fail2ban.log` file must be readable by the user `netdata`: -It produces one chart with multiple lines (one line per jail) +- change the file ownership and access permissions. +- update `/etc/logrotate.d/fail2ban` to persists the changes after rotating the log file. + +
+ Click to expand the instruction. + +To change the file ownership and access permissions, execute the following: + +```shell +sudo chown root:netdata /var/log/fail2ban.log +sudo chmod 640 /var/log/fail2ban.log +``` + +To persist the changes after rotating the log file, add `create 640 root netdata` to the `/etc/logrotate.d/fail2ban`: + +```shell +/var/log/fail2ban.log { + + weekly + rotate 4 + compress + + delaycompress + missingok + postrotate + fail2ban-client flushlogs 1>/dev/null + endscript + + # If fail2ban runs as non-root it still needs to have write access + # to logfiles. + # create 640 fail2ban adm + create 640 root netdata +} +``` + +
+ +## Charts + +- Failed attempts in attempts/s +- Bans in bans/s +- Banned IP addresses (since the last restart of netdata) in ips ## Configuration -Edit the `python.d/fail2ban.conf` configuration file using `edit-config` from the Netdata [config -directory](/docs/configure/nodes.md), which is typically at `/etc/netdata`. +Edit the `python.d/fail2ban.conf` configuration file using `edit-config` from the +Netdata [config directory](/docs/configure/nodes.md), which is typically at `/etc/netdata`. ```bash cd /etc/netdata # Replace this path with your Netdata config directory, if different @@ -28,13 +69,13 @@ Sample: ```yaml local: - log_path: '/var/log/fail2ban.log' - conf_path: '/etc/fail2ban/jail.local' - exclude: 'dropbear apache' + log_path: '/var/log/fail2ban.log' + conf_path: '/etc/fail2ban/jail.local' + exclude: 'dropbear apache' ``` -If no configuration is given, module will attempt to read log file at `/var/log/fail2ban.log` and conf file at `/etc/fail2ban/jail.local`. -If conf file is not found default jail is `ssh`. +If no configuration is given, module will attempt to read log file at `/var/log/fail2ban.log` and conf file +at `/etc/fail2ban/jail.local`. If conf file is not found default jail is `ssh`. --- diff --git a/collectors/python.d.plugin/fail2ban/fail2ban.chart.py b/collectors/python.d.plugin/fail2ban/fail2ban.chart.py index 99dbf79dd..76f6d92b4 100644 --- a/collectors/python.d.plugin/fail2ban/fail2ban.chart.py +++ b/collectors/python.d.plugin/fail2ban/fail2ban.chart.py @@ -11,8 +11,9 @@ from glob import glob from bases.FrameworkServices.LogService import LogService ORDER = [ + 'jails_failed_attempts', 'jails_bans', - 'jails_in_jail', + 'jails_banned_ips', ] @@ -23,40 +24,49 @@ def charts(jails): ch = { ORDER[0]: { - 'options': [None, 'Jails Ban Rate', 'bans/s', 'bans', 'jail.bans', 'line'], + 'options': [None, 'Failed attempts', 'attempts/s', 'failed attempts', 'fail2ban.failed_attempts', 'line'], 'lines': [] }, ORDER[1]: { - 'options': [None, 'Banned IPs (since the last restart of netdata)', 'IPs', 'in jail', - 'jail.in_jail', 'line'], + 'options': [None, 'Bans', 'bans/s', 'bans', 'fail2ban.bans', 'line'], + 'lines': [] + }, + ORDER[2]: { + 'options': [None, 'Banned IP addresses (since the last restart of netdata)', 'ips', 'banned ips', + 'fail2ban.banned_ips', 'line'], 'lines': [] }, } for jail in jails: - dim = [ - jail, - jail, - 'incremental', - ] + dim = ['{0}_failed_attempts'.format(jail), jail, 'incremental'] ch[ORDER[0]]['lines'].append(dim) - dim = [ - '{0}_in_jail'.format(jail), - jail, - 'absolute', - ] + dim = [jail, jail, 'incremental'] ch[ORDER[1]]['lines'].append(dim) + dim = ['{0}_in_jail'.format(jail), jail, 'absolute'] + ch[ORDER[2]]['lines'].append(dim) + return ch RE_JAILS = re.compile(r'\[([a-zA-Z0-9_-]+)\][^\[\]]+?enabled\s+= +(true|yes|false|no)') +ACTION_BAN = 'Ban' +ACTION_UNBAN = 'Unban' +ACTION_RESTORE_BAN = 'Restore Ban' +ACTION_FOUND = 'Found' + # Example: -# 2018-09-12 11:45:53,715 fail2ban.actions[25029]: WARNING [ssh] Unban 195.201.88.33 -# 2018-09-12 11:45:58,727 fail2ban.actions[25029]: WARNING [ssh] Ban 217.59.246.27 -# 2018-09-12 11:45:58,727 fail2ban.actions[25029]: WARNING [ssh] Restore Ban 217.59.246.27 -RE_DATA = re.compile(r'\[(?P[A-Za-z-_0-9]+)\] (?PUnban|Ban|Restore Ban) (?P[a-f0-9.:]+)') +# 2018-09-12 11:45:58,727 fail2ban.actions[25029]: WARNING [ssh] Found 203.0.113.1 +# 2018-09-12 11:45:58,727 fail2ban.actions[25029]: WARNING [ssh] Ban 203.0.113.1 +# 2018-09-12 11:45:58,727 fail2ban.actions[25029]: WARNING [ssh] Restore Ban 203.0.113.1 +# 2018-09-12 11:45:53,715 fail2ban.actions[25029]: WARNING [ssh] Unban 203.0.113.1 +RE_DATA = re.compile( + r'\[(?P[A-Za-z-_0-9]+)\] (?P{0}|{1}|{2}|{3}) (?P[a-f0-9.:]+)'.format( + ACTION_BAN, ACTION_UNBAN, ACTION_RESTORE_BAN, ACTION_FOUND + ) +) DEFAULT_JAILS = [ 'ssh', @@ -94,6 +104,7 @@ class Service(LogService): self.monitoring_jails = self.jails_auto_detection() for jail in self.monitoring_jails: + self.data['{0}_failed_attempts'.format(jail)] = 0 self.data[jail] = 0 self.data['{0}_in_jail'.format(jail)] = 0 @@ -124,12 +135,14 @@ class Service(LogService): jail, action, ip = match['jail'], match['action'], match['ip'] - if action == 'Ban' or action == 'Restore Ban': + if action == ACTION_FOUND: + self.data['{0}_failed_attempts'.format(jail)] += 1 + elif action in (ACTION_BAN, ACTION_RESTORE_BAN): self.data[jail] += 1 if ip not in self.banned_ips[jail]: self.banned_ips[jail].add(ip) self.data['{0}_in_jail'.format(jail)] += 1 - else: + elif action == ACTION_UNBAN: if ip in self.banned_ips[jail]: self.banned_ips[jail].remove(ip) self.data['{0}_in_jail'.format(jail)] -= 1 @@ -196,9 +209,9 @@ class Service(LogService): if name in exclude: continue - if status in ('true','yes') and name not in active_jails: + if status in ('true', 'yes') and name not in active_jails: active_jails.append(name) - elif status in ('false','no') and name in active_jails: + elif status in ('false', 'no') and name in active_jails: active_jails.remove(name) return active_jails or DEFAULT_JAILS diff --git a/collectors/python.d.plugin/mongodb/README.md b/collectors/python.d.plugin/mongodb/README.md index c0df123d7..e122736ac 100644 --- a/collectors/python.d.plugin/mongodb/README.md +++ b/collectors/python.d.plugin/mongodb/README.md @@ -152,7 +152,7 @@ Number of charts depends on mongodb version, storage engine and other features ( - member (time when last heartbeat was received from replica set member) -## prerequisite +## Prerequisite Create a read-only user for Netdata in the admin database. diff --git a/collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py b/collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py index 9c69586dd..00bc7884d 100644 --- a/collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py +++ b/collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py @@ -28,6 +28,7 @@ GPU_UTIL = 'gpu_utilization' MEM_UTIL = 'mem_utilization' ENCODER_UTIL = 'encoder_utilization' MEM_USAGE = 'mem_usage' +BAR_USAGE = 'bar1_mem_usage' TEMPERATURE = 'temperature' CLOCKS = 'clocks' POWER = 'power' @@ -42,6 +43,7 @@ ORDER = [ MEM_UTIL, ENCODER_UTIL, MEM_USAGE, + BAR_USAGE, TEMPERATURE, CLOCKS, POWER, @@ -95,6 +97,13 @@ def gpu_charts(gpu): ['fb_memory_used', 'used'], ] }, + BAR_USAGE: { + 'options': [None, 'Bar1 Memory Usage', 'MiB', fam, 'nvidia_smi.bar1_memory_usage', 'stacked'], + 'lines': [ + ['bar1_memory_free', 'free'], + ['bar1_memory_used', 'used'], + ] + }, TEMPERATURE: { 'options': [None, 'Temperature', 'celsius', fam, 'nvidia_smi.temperature', 'line'], 'lines': [ @@ -285,12 +294,14 @@ def get_username_by_pid_safe(pid, passwd_file): try: uid = os.stat(path).st_uid except (OSError, IOError): - return '' - - try: - return passwd_file[uid][0] - except KeyError: - return str(uid) + return '' + if IS_INSIDE_DOCKER: + try: + return passwd_file[uid][0] + except KeyError: + return str(uid) + else: + return pwd.getpwuid(uid)[0] class GPU: @@ -344,6 +355,14 @@ class GPU: def fb_memory_free(self): return self.root.find('fb_memory_usage').find('free').text.split()[0] + @handle_attr_error + def bar1_memory_used(self): + return self.root.find('bar1_memory_usage').find('used').text.split()[0] + + @handle_attr_error + def bar1_memory_free(self): + return self.root.find('bar1_memory_usage').find('free').text.split()[0] + @handle_attr_error def temperature(self): return self.root.find('temperature').find('gpu_temp').text.split()[0] @@ -399,6 +418,8 @@ class GPU: 'decoder_util': self.decoder_util(), 'fb_memory_used': self.fb_memory_used(), 'fb_memory_free': self.fb_memory_free(), + 'bar1_memory_used': self.bar1_memory_used(), + 'bar1_memory_free': self.bar1_memory_free(), 'gpu_temp': self.temperature(), 'graphics_clock': self.graphics_clock(), 'video_clock': self.video_clock(), diff --git a/collectors/python.d.plugin/postgres/postgres.chart.py b/collectors/python.d.plugin/postgres/postgres.chart.py index 29026a6a3..bd8f71a66 100644 --- a/collectors/python.d.plugin/postgres/postgres.chart.py +++ b/collectors/python.d.plugin/postgres/postgres.chart.py @@ -336,18 +336,18 @@ WHERE d.datallowconn; QUERY_TABLE_STATS = { DEFAULT: """ SELECT - ((sum(relpages) * 8) * 1024) AS table_size, - count(1) AS table_count + sum(relpages) * current_setting('block_size')::numeric AS table_size, + count(1) AS table_count FROM pg_class -WHERE relkind IN ('r', 't'); +WHERE relkind IN ('r', 't', 'm'); """, } QUERY_INDEX_STATS = { DEFAULT: """ SELECT - ((sum(relpages) * 8) * 1024) AS index_size, - count(1) AS index_count + sum(relpages) * current_setting('block_size')::numeric AS index_size, + count(1) AS index_count FROM pg_class WHERE relkind = 'i'; """, diff --git a/collectors/python.d.plugin/python.d.plugin.in b/collectors/python.d.plugin/python.d.plugin.in index b263f229e..b943f3a20 100644 --- a/collectors/python.d.plugin/python.d.plugin.in +++ b/collectors/python.d.plugin/python.d.plugin.in @@ -1,6 +1,6 @@ #!/usr/bin/env bash '''':; -pybinary=$(which python || which python3 || which python2) +pybinary=$(which python3 || which python || which python2) filtered=() for arg in "$@" do diff --git a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/ExecutableService.py b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/ExecutableService.py index dea50eea0..a74b4239e 100644 --- a/collectors/python.d.plugin/python_modules/bases/FrameworkServices/ExecutableService.py +++ b/collectors/python.d.plugin/python_modules/bases/FrameworkServices/ExecutableService.py @@ -35,7 +35,7 @@ class ExecutableService(SimpleService): for line in std: try: data.append(line.decode('utf-8')) - except TypeError: + except (TypeError, UnicodeDecodeError): continue return data diff --git a/collectors/python.d.plugin/spigotmc/spigotmc.chart.py b/collectors/python.d.plugin/spigotmc/spigotmc.chart.py index f334113e4..81370fb4c 100644 --- a/collectors/python.d.plugin/spigotmc/spigotmc.chart.py +++ b/collectors/python.d.plugin/spigotmc/spigotmc.chart.py @@ -22,6 +22,7 @@ COMMAND_ONLINE = 'online' ORDER = [ 'tps', + 'mem', 'users', ] @@ -39,15 +40,27 @@ CHARTS = { 'lines': [ ['users', 'Users', 'absolute', 1, 1] ] + }, + 'mem': { + 'options': [None, 'Minecraft Memory Usage', 'MiB', 'spigotmc', 'spigotmc.mem', 'line'], + 'lines': [ + ['mem_used', 'used', 'absolute', 1, 1], + ['mem_alloc', 'allocated', 'absolute', 1, 1], + ['mem_max', 'max', 'absolute', 1, 1] + ] } } _TPS_REGEX = re.compile( + # Examples: + # §6TPS from last 1m, 5m, 15m: §a*20.0, §a*20.0, §a*20.0 + # §6Current Memory Usage: §a936/65536 mb (Max: 65536 mb) r'^.*: .*?' # Message lead-in r'(\d{1,2}.\d+), .*?' # 1-minute TPS value r'(\d{1,2}.\d+), .*?' # 5-minute TPS value - r'(\d{1,2}\.\d+).*$', # 15-minute TPS value - re.X + r'(\d{1,2}\.\d+).*?' # 15-minute TPS value + r'(\s.*?(\d+)\/(\d+).*?: (\d+).*)?', # Current Memory Usage / Total Memory (Max Memory) + re.MULTILINE ) _LIST_REGEX = re.compile( # Examples: @@ -126,6 +139,10 @@ class Service(SimpleService): data['tps1'] = int(float(match.group(1)) * PRECISION) data['tps5'] = int(float(match.group(2)) * PRECISION) data['tps15'] = int(float(match.group(3)) * PRECISION) + if match.group(4): + data['mem_used'] = int(match.group(5)) + data['mem_alloc'] = int(match.group(6)) + data['mem_max'] = int(match.group(7)) else: self.error('Unable to process TPS values.') if not raw: diff --git a/collectors/python.d.plugin/web_log/README.md b/collectors/python.d.plugin/web_log/README.md index 2cf60ed9e..8bbb9a83a 100644 --- a/collectors/python.d.plugin/web_log/README.md +++ b/collectors/python.d.plugin/web_log/README.md @@ -31,7 +31,7 @@ If Netdata is installed on a system running a web server, it will detect it and ![image](https://cloud.githubusercontent.com/assets/2662304/22900686/e283f636-f237-11e6-93d2-cbdf63de150c.png) *[**netdata**](https://my-netdata.io/) charts based on metrics collected by querying the `nginx` API (i.e. `/stub_status`).* -> [**netdata**](https://my-netdata.io/) supports `apache`, `nginx`, `lighttpd` and `tomcat`. To obtain real-time information from a web server API, the web server needs to expose it. For directions on configuring your web server, check the config files for each web server. There is a directory with a config file for each web server under [`/etc/netdata/python.d/`](../). +> [**netdata**](https://my-netdata.io/) supports `apache`, `nginx`, `lighttpd` and `tomcat`. To obtain real-time information from a web server API, the web server needs to expose it. For directions on configuring your web server, check the config files for each web server. There is a directory with a config file for each web server under `/etc/netdata/python.d/`. ## Configuration @@ -120,7 +120,7 @@ This is a nice view of the traffic the web server is receiving and is sending. What is important to know for this chart, is that the bandwidth used for each request and response is accounted at the time the log is written. Since [**netdata**](https://my-netdata.io/) refreshes this chart every single second, you may have unrealistic spikes is the size of the requests or responses is too big. The reason is simple: a response may have needed 1 minute to be completed, but all the bandwidth used during that minute for the specific response will be accounted at the second the log line is written. -As the legend on the chart suggests, you can use FireQoS to setup QoS on the web server ports and IPs to accurately measure the bandwidth the web server is using. Actually, [there may be a few more reasons to install QoS on your servers](/collectors/tc.plugin/README.md#tcplugin)... +As the legend on the chart suggests, you can use FireQOS to setup QoS on the web server ports and IPs to accurately measure the bandwidth the web server is using. Actually, [there may be a few more reasons to install QoS on your servers](/collectors/tc.plugin/README.md#tcplugin)... **Bandwidth** KB/s diff --git a/collectors/slabinfo.plugin/slabinfo.c b/collectors/slabinfo.plugin/slabinfo.c index 58d9c4fff..0913b895e 100644 --- a/collectors/slabinfo.plugin/slabinfo.c +++ b/collectors/slabinfo.plugin/slabinfo.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later -#include "libnetdata/libnetdata.h" #include "daemon/common.h" +#include "libnetdata/required_dummies.h" #define PLUGIN_SLABINFO_NAME "slabinfo.plugin" #define PLUGIN_SLABINFO_PROCFILE "/proc/slabinfo" @@ -16,39 +16,6 @@ fprintf(stderr, ##args); \ fprintf(stderr, "\n"); } - -// ---------------------------------------------------------------------------- - -// callback required by fatal() -void netdata_cleanup_and_exit(int ret) { - exit(ret); -} - -void send_statistics(const char *action, const char *action_result, const char *action_data) { - (void) action; - (void) action_result; - (void) action_data; - return; -} - -// callbacks required by popen() -void signals_block(void) {}; -void signals_unblock(void) {}; -void signals_reset(void) {}; - -// callback required by eval() -int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *rc, calculated_number *result) { - (void)variable; - (void)hash; - (void)rc; - (void)result; - return 0; -}; - -// required by get_system_cpus() -char *netdata_configured_host_prefix = ""; - - int running = 1; int debug = 0; size_t lines_discovered = 0; diff --git a/collectors/statsd.plugin/README.md b/collectors/statsd.plugin/README.md index ba4ada517..1d1c8ab70 100644 --- a/collectors/statsd.plugin/README.md +++ b/collectors/statsd.plugin/README.md @@ -4,8 +4,6 @@ description: "The Netdata Agent is a fully-featured StatsD server that collects custom_edit_url: https://github.com/netdata/netdata/edit/master/collectors/statsd.plugin/README.md --> -# statsd.plugin - StatsD is a system to collect data from any application. Applications send metrics to it, usually via non-blocking UDP communication, and StatsD servers collect these metrics, perform a few simple calculations on them and push them to backend time-series databases. If you want to learn more about the StatsD protocol, we have written a [blog post](https://www.netdata.cloud/blog/introduction-to-statsd/) about it! @@ -19,7 +17,7 @@ Since statsd is embedded in Netdata, it means you now have a statsd server embed Netdata statsd is fast. It can collect more than **1.200.000 metrics per second** on modern hardware, more than **200Mbps of sustained statsd traffic**, using 1 CPU core. The implementation uses two threads: one thread collects metrics, another one updates the charts from the collected data. -# Available StatsD collectors +## Available StatsD collectors Netdata ships with collectors implemented using the StatsD collector. They are configuration files (as you will read below), but they function as a collector, in the sense that configuration file organize the metrics of a data source into pre-defined charts. @@ -532,7 +530,7 @@ Using the client library by [sivy/node-statsd](https://github.com/sivy/node-stat You can also use StatsD with: - Golang, thanks to [alexcesaro/statsd](https://github.com/alexcesaro/statsd) - Ruby, thanks to [reinh/statsd](https://github.com/reinh/statsd) -- Java, thanks to [DataDog/java-docstatsd-client](https://github.com/DataDog/java-dogstatsd-client) +- Java, thanks to [DataDog/java-dogstatsd-client](https://github.com/DataDog/java-dogstatsd-client) ### Shell diff --git a/collectors/statsd.plugin/statsd.c b/collectors/statsd.plugin/statsd.c index 9e152b09e..a630d00d0 100644 --- a/collectors/statsd.plugin/statsd.c +++ b/collectors/statsd.plugin/statsd.c @@ -1,11 +1,14 @@ // SPDX-License-Identifier: GPL-3.0-or-later -#include "statsd.h" +#include "daemon/common.h" #define STATSD_CHART_PREFIX "statsd" #define PLUGIN_STATSD_NAME "statsd.plugin" +#define STATSD_LISTEN_PORT 8125 +#define STATSD_LISTEN_BACKLOG 4096 + // -------------------------------------------------------------------------------------- // #define STATSD_MULTITHREADED 1 diff --git a/collectors/statsd.plugin/statsd.h b/collectors/statsd.plugin/statsd.h deleted file mode 100644 index 37d6a08b3..000000000 --- a/collectors/statsd.plugin/statsd.h +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef NETDATA_STATSD_H -#define NETDATA_STATSD_H 1 - -#include "daemon/common.h" - -#define STATSD_LISTEN_PORT 8125 -#define STATSD_LISTEN_BACKLOG 4096 - -#define NETDATA_PLUGIN_HOOK_STATSD \ - { \ - .name = "STATSD", \ - .config_section = NULL, \ - .config_name = NULL, \ - .enabled = 1, \ - .thread = NULL, \ - .init_routine = NULL, \ - .start_routine = statsd_main \ - }, - - -extern void *statsd_main(void *ptr); - -#endif //NETDATA_STATSD_H diff --git a/collectors/tc.plugin/plugin_tc.c b/collectors/tc.plugin/plugin_tc.c index 0197db073..ce3fe668b 100644 --- a/collectors/tc.plugin/plugin_tc.c +++ b/collectors/tc.plugin/plugin_tc.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -#include "plugin_tc.h" +#include "daemon/common.h" #define RRD_TYPE_TC "tc" #define PLUGIN_TC_NAME "tc.plugin" diff --git a/collectors/tc.plugin/plugin_tc.h b/collectors/tc.plugin/plugin_tc.h deleted file mode 100644 index d51fcf674..000000000 --- a/collectors/tc.plugin/plugin_tc.h +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef NETDATA_PLUGIN_TC_H -#define NETDATA_PLUGIN_TC_H 1 - -#include "daemon/common.h" - -#if (TARGET_OS == OS_LINUX) - -#define NETDATA_PLUGIN_HOOK_LINUX_TC \ - { \ - .name = "PLUGIN[tc]", \ - .config_section = CONFIG_SECTION_PLUGINS, \ - .config_name = "tc", \ - .enabled = 1, \ - .thread = NULL, \ - .init_routine = NULL, \ - .start_routine = tc_main \ - }, - -extern void *tc_main(void *ptr); - -#else // (TARGET_OS == OS_LINUX) - -#define NETDATA_PLUGIN_HOOK_LINUX_TC - -#endif // (TARGET_OS == OS_LINUX) - - -#endif /* NETDATA_PLUGIN_TC_H */ - diff --git a/collectors/tc.plugin/tc-qos-helper.sh.in b/collectors/tc.plugin/tc-qos-helper.sh.in index 65d33153b..97d4d016d 100755 --- a/collectors/tc.plugin/tc-qos-helper.sh.in +++ b/collectors/tc.plugin/tc-qos-helper.sh.in @@ -89,13 +89,13 @@ if [ ! -d "${fireqos_run_dir}" ]; then if [ -d "${LOCALSTATEDIR}/run/fireqos" ]; then fireqos_run_dir="${LOCALSTATEDIR}/run/fireqos" else - warning "FireQoS is installed as '${fireqos}', its installation config at '${fireqos_exec_dir}/install.config' specifies local state data at '${LOCALSTATEDIR}/run/fireqos', but this directory is not found or is not readable (check the permissions of its parents)." + warning "FireQOS is installed as '${fireqos}', its installation config at '${fireqos_exec_dir}/install.config' specifies local state data at '${LOCALSTATEDIR}/run/fireqos', but this directory is not found or is not readable (check the permissions of its parents)." fi else - warning "Although FireQoS is installed on this system as '${fireqos}', I cannot find/read its installation configuration at '${fireqos_exec_dir}/install.config'." + warning "Although FireQOS is installed on this system as '${fireqos}', I cannot find/read its installation configuration at '${fireqos_exec_dir}/install.config'." fi else - warning "FireQoS is not installed on this system. Use FireQoS to apply traffic QoS and expose the class names to netdata. Check https://github.com/netdata/netdata/tree/master/collectors/tc.plugin#tcplugin" + warning "FireQOS is not installed on this system. Use FireQOS to apply traffic QoS and expose the class names to netdata. Check https://github.com/netdata/netdata/tree/master/collectors/tc.plugin#tcplugin" fi fi diff --git a/collectors/timex.plugin/plugin_timex.c b/collectors/timex.plugin/plugin_timex.c index b3e722a4c..b69f34292 100644 --- a/collectors/timex.plugin/plugin_timex.c +++ b/collectors/timex.plugin/plugin_timex.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later -#include "plugin_timex.h" +#include "daemon/common.h" #include "sys/timex.h" #define PLUGIN_TIMEX_NAME "timex.plugin" diff --git a/collectors/timex.plugin/plugin_timex.h b/collectors/timex.plugin/plugin_timex.h deleted file mode 100644 index f83786163..000000000 --- a/collectors/timex.plugin/plugin_timex.h +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later - -#ifndef NETDATA_PLUGIN_TIMEX_H -#define NETDATA_PLUGIN_TIMEX_H - -#include "daemon/common.h" - -#if (TARGET_OS == OS_LINUX) - -#define NETDATA_PLUGIN_HOOK_LINUX_TIMEX \ - { \ - .name = "PLUGIN[timex]", \ - .config_section = CONFIG_SECTION_PLUGINS, \ - .config_name = "timex", \ - .enabled = 1, \ - .thread = NULL, \ - .init_routine = NULL, \ - .start_routine = timex_main \ - }, - -extern void *timex_main(void *ptr); - -#else // (TARGET_OS == OS_LINUX) - -#define NETDATA_PLUGIN_HOOK_LINUX_TIMEX - -#endif // (TARGET_OS == OS_LINUX) - -#endif //NETDATA_PLUGIN_TIMEX_H diff --git a/collectors/xenstat.plugin/xenstat_plugin.c b/collectors/xenstat.plugin/xenstat_plugin.c index abcb5a1c3..781b22afe 100644 --- a/collectors/xenstat.plugin/xenstat_plugin.c +++ b/collectors/xenstat.plugin/xenstat_plugin.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later #include "libnetdata/libnetdata.h" +#include "libnetdata/required_dummies.h" #include #include @@ -35,35 +36,6 @@ #define CHART_IS_OBSOLETE 1 #define CHART_IS_NOT_OBSOLETE 0 -// callback required by fatal() -void netdata_cleanup_and_exit(int ret) { - exit(ret); -} - -void send_statistics( const char *action, const char *action_result, const char *action_data) { - (void) action; - (void) action_result; - (void) action_data; - return; -} - -// callbacks required by popen() -void signals_block(void) {}; -void signals_unblock(void) {}; -void signals_reset(void) {}; - -// callback required by eval() -int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *rc, calculated_number *result) { - (void)variable; - (void)hash; - (void)rc; - (void)result; - return 0; -}; - -// required by get_system_cpus() -char *netdata_configured_host_prefix = ""; - // Variables static int debug = 0; static int netdata_update_every = 1; -- cgit v1.2.3