@cryptotaxi247 / netdata-1 / commits / bc8b5a8ad

Fix line arguments (eBPF) (#11670)

* fix_line_arguments: Remove short options * fix_line_arguments: Move config read before line arguments * fix_line_arguments: Bring an unique pattern for descriptions * fix_line_arguments: Rename function * fix_line_arguments: Move thread configuration parsers to also configure them with inline options * fix_line_arguments: Remove unecessary variable and function call * fix_line_arguments: Reorganize indexes and options * fix_line_arguments: Update help * fix_line_arguments: Fix global selection * fix_line_arguments: Fix thread selection * fix_line_arguments: Fix typo * fix_line_arguments: Rename function * fix_line_arguments: add missing variable to reset * fix_line_arguments: Fix rebase * fix_line_arguments: Address comment https://github.com/netdata/netdata/pull/11670#discussion_r730909607

thiagoftsm committed Oct 19, 2021 at 07:09 UTC bc8b5a8add5abf772a2ad291bad4448099677ea8
3 files changed +203 -175
collectors/ebpf.plugin/ebpf.c
+182 -163
@@ -700,6 +700,21 @@ static inline void ebpf_enable_all_charts(int apps, int cgroups)
700 }
701 }
702
703 +/**
704 + * Disable all Global charts
705 + *
706 + * Disable charts
707 + */
708 +static inline void disable_all_global_charts()
709 +{
710 + int i;
711 + for (i = 0; ebpf_modules[i].thread_name; i++) {
712 + ebpf_modules[i].enabled = 0;
713 + ebpf_modules[i].global_charts = 0;
714 + }
715 +}
716 +
717 +
718 /**
719 * Enable the specified chart group
720 *
@@ -730,6 +745,19 @@ static inline void ebpf_disable_apps()
745 }
746 }
747
748 +/**
749 + * Disable Cgroups
750 + *
751 + * Disable charts for apps loading only global charts.
752 + */
753 +static inline void ebpf_disable_cgroups()
754 +{
755 + int i;
756 + for (i = 0; ebpf_modules[i].thread_name; i++) {
757 + ebpf_modules[i].cgroup_charts = 0;
758 + }
759 +}
760 +
761 /**
762 * Print help on standard error for user knows how to use the collector.
763 */
@@ -751,49 +779,49 @@ void ebpf_print_help()
779 " Released under GNU General Public License v3 or later.\n"
780 " All rights reserved.\n"
781 "\n"
754 - " This program is a data collector plugin for netdata.\n"
782 + " This eBPF.plugin is a data collector plugin for netdata.\n"
783 "\n"
756 - " Available command line options:\n"
784 + " This plugin only accepts long options with one or two dashes. The available command line options are:\n"
785 "\n"
758 - " SECONDS Set the data collection frequency.\n"
786 + " SECONDS Set the data collection frequency.\n"
787 "\n"
760 - " --help or -h Show this help.\n"
788 + " [-]-help Show this help.\n"
789 "\n"
762 - " --version or -v Show software version.\n"
790 + " [-]-version Show software version.\n"
791 "\n"
764 - " --global or -g Disable charts per application and cgroup.\n"
792 + " [-]-global Disable charts per application and cgroup.\n"
793 "\n"
766 - " --all or -a Enable all chart groups (global, apps, and cgroup), unless -g is also given.\n"
794 + " [-]-all Enable all chart groups (global, apps, and cgroup), unless -g is also given.\n"
795 "\n"
768 - " --cachestat or -c Enable charts related to process run time.\n"
796 + " [-]-cachestat Enable charts related to process run time.\n"
797 "\n"
770 - " --dcstat or -d Enable charts related to directory cache.\n"
798 + " [-]-dcstat Enable charts related to directory cache.\n"
799 "\n"
772 - " --disk or -k Enable charts related to disk monitoring.\n"
800 + " [-]-disk Enable charts related to disk monitoring.\n"
801 "\n"
774 - " --filesystem or -i Enable chart related to filesystem run time.\n"
802 + " [-]-filesystem Enable chart related to filesystem run time.\n"
803 "\n"
776 - " --hardirq or -q Enable chart related to hard IRQ latency.\n"
804 + " [-]-hardirq Enable chart related to hard IRQ latency.\n"
805 "\n"
778 - " --mount or -m Enable charts related to mount monitoring.\n"
806 + " [-]-mount Enable charts related to mount monitoring.\n"
807 "\n"
780 - " --net or -n Enable network viewer charts.\n"
808 + " [-]-net Enable network viewer charts.\n"
809 "\n"
782 - " --oomkill or -o Enable chart related to OOM kill tracking.\n"
810 + " [-]-oomkill Enable chart related to OOM kill tracking.\n"
811 "\n"
784 - " --process or -p Enable charts related to process run time.\n"
812 + " [-]-process Enable charts related to process run time.\n"
813 "\n"
786 - " --return or -r Run the collector in return mode.\n"
814 + " [-]-return Run the collector in return mode.\n"
815 "\n"
788 - " --shm or -b Enable chart related to shared memory tracking.\n"
816 + " [-]-shm Enable chart related to shared memory tracking.\n"
817 "\n"
790 - " --softirq or -t Enable chart related to soft IRQ latency.\n"
818 + " [-]-softirq Enable chart related to soft IRQ latency.\n"
819 "\n"
792 - " --sync or -s Enable chart related to sync run time.\n"
820 + " [-]-sync Enable chart related to sync run time.\n"
821 "\n"
794 - " --swap or -w Enable chart related to swap run time.\n"
822 + " [-]-swap Enable chart related to swap run time.\n"
823 "\n"
796 - " --vfs or -f Enable chart related to vfs run time.\n"
824 + " [-]-vfs Enable chart related to vfs run time.\n"
825 "\n",
826 VERSION,
827 (year >= 116) ? year + 1900 : 2020);
@@ -1300,40 +1328,54 @@ void set_global_variables()
1328 ebpf_update_kernel(kernel_string, 63, isrh, running_on_kernel);
1329 }
1330
1331 +/**
1332 + * Load collector config
1333 + *
1334 + * @param lmode the mode that will be used for them.
1335 + */
1336 +static inline void ebpf_load_thread_config()
1337 +{
1338 + int i;
1339 + for (i = 0; ebpf_modules[i].thread_name; i++) {
1340 + ebpf_update_module(&ebpf_modules[i]);
1341 + }
1342 +}
1343 +
1344 /**
1345 * Parse arguments given from user.
1346 *
1347 * @param argc the number of arguments
1348 * @param argv the pointer to the arguments
1349 */
1309 -static void parse_args(int argc, char **argv)
1350 +static void ebpf_parse_args(int argc, char **argv)
1351 {
1311 - int enabled = 0;
1352 int disable_apps = 0;
1313 - int disable_cgroups = 0;
1353 + int disable_cgroups = 1;
1354 int freq = 0;
1355 int option_index = 0;
1356 + uint64_t select_threads = 0;
1357 static struct option long_options[] = {
1317 - {"help", no_argument, 0, 'h' },
1318 - {"version", no_argument, 0, 'v' },
1319 - {"global", no_argument, 0, 'g' },
1320 - {"all", no_argument, 0, 'a' },
1321 - {"cachestat", no_argument, 0, 'c' },
1322 - {"dcstat", no_argument, 0, 'd' },
1323 - {"disk", no_argument, 0, 'k' },
1324 - {"filesystem", no_argument, 0, 'i' },
1325 - {"filedescriptor", no_argument, 0, 'e' },
1326 - {"hardirq", no_argument, 0, 'q' },
1327 - {"mount", no_argument, 0, 'm' },
1328 - {"net", no_argument, 0, 'n' },
1329 - {"oomkill", no_argument, 0, 'o' },
1330 - {"process", no_argument, 0, 'p' },
1331 - {"return", no_argument, 0, 'r' },
1332 - {"shm", no_argument, 0, 'b' },
1333 - {"softirq", no_argument, 0, 't' },
1334 - {"sync", no_argument, 0, 's' },
1335 - {"swap", no_argument, 0, 'w' },
1336 - {"vfs", no_argument, 0, 'f' },
1358 + {"process", no_argument, 0, 0 },
1359 + {"net", no_argument, 0, 0 },
1360 + {"cachestat", no_argument, 0, 0 },
1361 + {"sync", no_argument, 0, 0 },
1362 + {"dcstat", no_argument, 0, 0 },
1363 + {"swap", no_argument, 0, 0 },
1364 + {"vfs", no_argument, 0, 0 },
1365 + {"filesystem", no_argument, 0, 0 },
1366 + {"disk", no_argument, 0, 0 },
1367 + {"mount", no_argument, 0, 0 },
1368 + {"filedescriptor", no_argument, 0, 0 },
1369 + {"hardirq", no_argument, 0, 0 },
1370 + {"softirq", no_argument, 0, 0 },
1371 + {"oomkill", no_argument, 0, 0 },
1372 + {"shm", no_argument, 0, 0 },
1373 + /* INSERT NEW THREADS BEFORE THIS COMMENT TO KEEP COMPATIBILITY WITH enum ebpf_module_indexes */
1374 + {"all", no_argument, 0, 0 },
1375 + {"version", no_argument, 0, 0 },
1376 + {"help", no_argument, 0, 0 },
1377 + {"global", no_argument, 0, 0 },
1378 + {"return", no_argument, 0, 0 },
1379 {0, 0, 0, 0}
1380 };
1381
@@ -1347,163 +1389,159 @@ static void parse_args(int argc, char **argv)
1389 }
1390 }
1391
1392 + if (!freq)
1393 + freq = EBPF_DEFAULT_UPDATE_EVERY;
1394 +
1395 + if (load_collector_config(ebpf_user_config_dir, &disable_apps, &disable_cgroups, freq)) {
1396 + info(
1397 + "Does not have a configuration file inside `%s/ebpf.d.conf. It will try to load stock file.",
1398 + ebpf_user_config_dir);
1399 + if (load_collector_config(ebpf_stock_config_dir, &disable_apps, &disable_cgroups, freq)) {
1400 + info("Does not have a stock file. It is starting with default options.");
1401 + }
1402 + }
1403 +
1404 + ebpf_load_thread_config();
1405 +
1406 while (1) {
1351 - int c = getopt_long(argc, argv, "hvgacdkieqmnoprbtswf", long_options, &option_index);
1407 + int c = getopt_long_only(argc, argv, "", long_options, &option_index);
1408 if (c == -1)
1409 break;
1410
1355 - switch (c) {
1356 - case 'h': {
1357 - ebpf_print_help();
1358 - exit(0);
1359 - }
1360 - case 'v': {
1361 - printf("ebpf.plugin %s\n", VERSION);
1362 - exit(0);
1363 - }
1364 - case 'g': {
1365 - disable_apps = 1;
1366 - ebpf_disable_apps();
1411 + switch (option_index) {
1412 + case EBPF_MODULE_PROCESS_IDX: {
1413 + select_threads |= 1<<EBPF_MODULE_PROCESS_IDX;
1414 #ifdef NETDATA_INTERNAL_CHECKS
1368 - info(
1369 - "EBPF running with global chart group, because it was started with the option \"--global\" or \"-g\".");
1415 + info("EBPF enabling \"PROCESS\" charts, because it was started with the option \"[-]-process\".");
1416 #endif
1417 break;
1418 }
1373 - case 'a': {
1374 - ebpf_enable_all_charts(disable_apps, disable_cgroups);
1419 + case EBPF_MODULE_SOCKET_IDX: {
1420 + select_threads |= 1<<EBPF_MODULE_SOCKET_IDX;
1421 #ifdef NETDATA_INTERNAL_CHECKS
1376 - info("EBPF running with all chart groups, because it was started with the option \"--all\" or \"-a\".");
1422 + info("EBPF enabling \"NET\" charts, because it was started with the option \"[-]-net\".");
1423 #endif
1424 break;
1425 }
1380 - case 'c': {
1381 - enabled = 1;
1382 - ebpf_enable_chart(EBPF_MODULE_CACHESTAT_IDX, disable_apps, disable_cgroups);
1426 + case EBPF_MODULE_CACHESTAT_IDX: {
1427 + select_threads |= 1<<EBPF_MODULE_CACHESTAT_IDX;
1428 #ifdef NETDATA_INTERNAL_CHECKS
1384 - info(
1385 - "EBPF enabling \"CACHESTAT\" charts, because it was started with the option \"--cachestat\" or \"-c\".");
1429 + info("EBPF enabling \"CACHESTAT\" charts, because it was started with the option \"[-]-cachestat\".");
1430 #endif
1431 break;
1432 }
1389 - case 'd': {
1390 - enabled = 1;
1391 - ebpf_enable_chart(EBPF_MODULE_DCSTAT_IDX, disable_apps, disable_cgroups);
1433 + case EBPF_MODULE_SYNC_IDX: {
1434 + select_threads |= 1<<EBPF_MODULE_SYNC_IDX;
1435 #ifdef NETDATA_INTERNAL_CHECKS
1393 - info(
1394 - "EBPF enabling \"DCSTAT\" charts, because it was started with the option \"--dcstat\" or \"-d\".");
1436 + info("EBPF enabling \"SYNC\" chart, because it was started with the option \"[-]-sync\".");
1437 #endif
1438 break;
1439 }
1398 - case 'i': {
1399 - enabled = 1;
1400 - ebpf_enable_chart(EBPF_MODULE_FILESYSTEM_IDX, disable_apps, disable_cgroups);
1440 + case EBPF_MODULE_DCSTAT_IDX: {
1441 + select_threads |= 1<<EBPF_MODULE_DCSTAT_IDX;
1442 #ifdef NETDATA_INTERNAL_CHECKS
1402 - info("EBPF enabling \"filesystem\" chart, because it was started with the option \"--filesystem\" or \"-i\".");
1443 + info("EBPF enabling \"DCSTAT\" charts, because it was started with the option \"[-]-dcstat\".");
1444 #endif
1445 break;
1446 }
1406 - case 'q': {
1407 - enabled = 1;
1408 - ebpf_enable_chart(EBPF_MODULE_HARDIRQ_IDX, disable_apps, disable_cgroups);
1447 + case EBPF_MODULE_SWAP_IDX: {
1448 + select_threads |= 1<<EBPF_MODULE_SWAP_IDX;
1449 #ifdef NETDATA_INTERNAL_CHECKS
1410 - info("EBPF enabling \"hardirq\" chart, because it was started with the option \"--hardirq\" or \"-q\".");
1450 + info("EBPF enabling \"SWAP\" chart, because it was started with the option \"[-]-swap\".");
1451 #endif
1452 break;
1453 }
1414 - case 'k': {
1415 - enabled = 1;
1416 - ebpf_enable_chart(EBPF_MODULE_DISK_IDX, disable_apps, disable_cgroups);
1454 + case EBPF_MODULE_VFS_IDX: {
1455 + select_threads |= 1<<EBPF_MODULE_VFS_IDX;
1456 #ifdef NETDATA_INTERNAL_CHECKS
1418 - info("EBPF enabling \"disk\" chart, because it was started with the option \"--disk\" or \"-k\".");
1457 + info("EBPF enabling \"VFS\" chart, because it was started with the option \"[-]-vfs\".");
1458 #endif
1459 break;
1460 }
1422 - case 'm': {
1423 - enabled = 1;
1424 - ebpf_enable_chart(EBPF_MODULE_MOUNT_IDX, disable_apps, disable_cgroups);
1461 + case EBPF_MODULE_FILESYSTEM_IDX: {
1462 + select_threads |= 1<<EBPF_MODULE_FILESYSTEM_IDX;
1463 #ifdef NETDATA_INTERNAL_CHECKS
1426 - info("EBPF enabling \"mount\" chart, because it was started with the option \"--mount\" or \"-m\".");
1464 + info("EBPF enabling \"FILESYSTEM\" chart, because it was started with the option \"[-]-filesystem\".");
1465 #endif
1466 break;
1467 }
1430 - case 'e': {
1431 - enabled = 1;
1432 - ebpf_enable_chart(EBPF_MODULE_FD_IDX, disable_apps, disable_cgroups);
1468 + case EBPF_MODULE_DISK_IDX: {
1469 + select_threads |= 1<<EBPF_MODULE_DISK_IDX;
1470 #ifdef NETDATA_INTERNAL_CHECKS
1434 - info("EBPF enabling \"filedescriptor\" chart, because it was started with the option \"--filedescriptor\" or \"-e\".");
1471 + info("EBPF enabling \"DISK\" chart, because it was started with the option \"[-]-disk\".");
1472 #endif
1473 break;
1474 }
1438 - case 'n': {
1439 - enabled = 1;
1440 - ebpf_enable_chart(EBPF_MODULE_SOCKET_IDX, disable_apps, disable_cgroups);
1475 + case EBPF_MODULE_MOUNT_IDX: {
1476 + select_threads |= 1<<EBPF_MODULE_MOUNT_IDX;
1477 #ifdef NETDATA_INTERNAL_CHECKS
1442 - info("EBPF enabling \"NET\" charts, because it was started with the option \"--net\" or \"-n\".");
1478 + info("EBPF enabling \"MOUNT\" chart, because it was started with the option \"[-]-mount\".");
1479 #endif
1480 break;
1481 }
1446 - case 'o': {
1447 - enabled = 1;
1448 - ebpf_enable_chart(EBPF_MODULE_OOMKILL_IDX, disable_apps, disable_cgroups);
1482 + case EBPF_MODULE_FD_IDX: {
1483 + select_threads |= 1<<EBPF_MODULE_FD_IDX;
1484 #ifdef NETDATA_INTERNAL_CHECKS
1450 - info("EBPF enabling \"oomkill\" chart, because it was started with the option \"--oomkill\" or \"-o\".");
1485 + info("EBPF enabling \"FILEDESCRIPTOR\" chart, because it was started with the option \"[-]-filedescriptor\".");
1486 #endif
1487 break;
1488 }
1454 - case 'p': {
1455 - enabled = 1;
1456 - ebpf_enable_chart(EBPF_MODULE_PROCESS_IDX, disable_apps, disable_cgroups);
1489 + case EBPF_MODULE_HARDIRQ_IDX: {
1490 + select_threads |= 1<<EBPF_MODULE_HARDIRQ_IDX;
1491 #ifdef NETDATA_INTERNAL_CHECKS
1458 - info(
1459 - "EBPF enabling \"PROCESS\" charts, because it was started with the option \"--process\" or \"-p\".");
1492 + info("EBPF enabling \"HARDIRQ\" chart, because it was started with the option \"[-]-hardirq\".");
1493 #endif
1494 break;
1495 }
1463 - case 'r': {
1464 - ebpf_set_thread_mode(MODE_RETURN);
1496 + case EBPF_MODULE_SOFTIRQ_IDX: {
1497 + select_threads |= 1<<EBPF_MODULE_SOFTIRQ_IDX;
1498 #ifdef NETDATA_INTERNAL_CHECKS
1466 - info("EBPF running in \"return\" mode, because it was started with the option \"--return\" or \"-r\".");
1499 + info("EBPF enabling \"SOFTIRQ\" chart, because it was started with the option \"[-]-softirq\".");
1500 #endif
1501 break;
1502 }
1470 - case 'b': {
1471 - enabled = 1;
1472 - ebpf_enable_chart(EBPF_MODULE_SHM_IDX, disable_apps, disable_cgroups);
1503 + case EBPF_MODULE_OOMKILL_IDX: {
1504 + select_threads |= 1<<EBPF_MODULE_OOMKILL_IDX;
1505 #ifdef NETDATA_INTERNAL_CHECKS
1474 - info("EBPF enabling \"shm\" chart, because it was started with the option \"--shm\" or \"-b\".");
1506 + info("EBPF enabling \"OOMKILL\" chart, because it was started with the option \"[-]-oomkill\".");
1507 #endif
1508 break;
1509 }
1478 - case 't': {
1479 - enabled = 1;
1480 - ebpf_enable_chart(EBPF_MODULE_SOFTIRQ_IDX, disable_apps, disable_cgroups);
1510 + case EBPF_MODULE_SHM_IDX: {
1511 + select_threads |= 1<<EBPF_MODULE_SHM_IDX;
1512 #ifdef NETDATA_INTERNAL_CHECKS
1482 - info("EBPF enabling \"softirq\" chart, because it was started with the option \"--softirq\" or \"-t\".");
1513 + info("EBPF enabling \"SHM\" chart, because it was started with the option \"[-]-shm\".");
1514 #endif
1515 break;
1516 }
1486 - case 's': {
1487 - enabled = 1;
1488 - ebpf_enable_chart(EBPF_MODULE_SYNC_IDX, disable_apps, disable_cgroups);
1517 + case EBPF_OPTION_ALL_CHARTS: {
1518 + disable_apps = 0;
1519 + disable_cgroups = 0;
1520 #ifdef NETDATA_INTERNAL_CHECKS
1490 - info("EBPF enabling \"sync\" chart, because it was started with the option \"--sync\" or \"-s\".");
1521 + info("EBPF running with all chart groups, because it was started with the option \"[-]-all\".");
1522 #endif
1523 break;
1524 }
1494 - case 'w': {
1495 - enabled = 1;
1496 - ebpf_enable_chart(EBPF_MODULE_SWAP_IDX, disable_apps, disable_cgroups);
1525 + case EBPF_OPTION_VERSION: {
1526 + printf("ebpf.plugin %s\n", VERSION);
1527 + exit(0);
1528 + }
1529 + case EBPF_OPTION_HELP: {
1530 + ebpf_print_help();
1531 + exit(0);
1532 + }
1533 + case EBPF_OPTION_GLOBAL_CHART: {
1534 + disable_apps = 1;
1535 + disable_cgroups = 1;
1536 #ifdef NETDATA_INTERNAL_CHECKS
1498 - info("EBPF enabling \"swap\" chart, because it was started with the option \"--swap\" or \"-w\".");
1537 + info("EBPF running with global chart group, because it was started with the option \"[-]-global\".");
1538 #endif
1539 break;
1540 }
1502 - case 'f': {
1503 - enabled = 1;
1504 - ebpf_enable_chart(EBPF_MODULE_VFS_IDX, disable_apps, disable_cgroups);
1541 + case EBPF_OPTION_RETURN_MODE: {
1542 + ebpf_set_thread_mode(MODE_RETURN);
1543 #ifdef NETDATA_INTERNAL_CHECKS
1506 - info("EBPF enabling \"vfs\" chart, because it was started with the option \"--vfs\" or \"-f\".");
1544 + info("EBPF running in \"RETURN\" mode, because it was started with the option \"[-]-return\".");
1545 #endif
1546 break;
1547 }
@@ -1513,28 +1551,23 @@ static void parse_args(int argc, char **argv)
1551 }
1552 }
1553
1516 - if (freq <= 0) {
1517 - freq = EBPF_DEFAULT_UPDATE_EVERY;
1518 - }
1554 + if (disable_apps || disable_cgroups) {
1555 + if (disable_apps)
1556 + ebpf_disable_apps();
1557
1520 - if (load_collector_config(ebpf_user_config_dir, &disable_apps, &disable_cgroups, freq)) {
1521 - info(
1522 - "Does not have a configuration file inside `%s/ebpf.d.conf. It will try to load stock file.",
1523 - ebpf_user_config_dir);
1524 - if (load_collector_config(ebpf_stock_config_dir, &disable_apps, &disable_cgroups, freq)) {
1525 - info("Does not have a stock file. It is starting with default options.");
1526 - } else {
1527 - enabled = 1;
1528 - }
1529 - } else {
1530 - enabled = 1;
1531 - }
1558 + if (disable_cgroups)
1559 + ebpf_disable_cgroups();
1560
1533 - if (!enabled) {
1561 ebpf_enable_all_charts(disable_apps, disable_cgroups);
1535 -#ifdef NETDATA_INTERNAL_CHECKS
1536 - info("EBPF running with all charts, because neither \"-n\" or \"-p\" was given.");
1537 -#endif
1562 + }
1563 +
1564 + if (select_threads) {
1565 + disable_all_global_charts();
1566 + uint64_t idx;
1567 + for (idx = 0; idx < EBPF_OPTION_ALL_CHARTS; idx++) {
1568 + if (select_threads & 1<<idx)
1569 + ebpf_enable_specific_chart(&ebpf_modules[idx], disable_apps, disable_cgroups);
1570 + }
1571 }
1572
1573 // Load apps_groups.conf
@@ -1689,19 +1722,6 @@ static void ebpf_manage_pid(pid_t pid)
1722 ebpf_update_pid_file(filename, pid);
1723 }
1724
1692 -/**
1693 - * Load collector config
1694 - *
1695 - * @param lmode the mode that will be used for them.
1696 - */
1697 -static inline void ebpf_load_thread_config()
1698 -{
1699 - int i;
1700 - for (i = 0; ebpf_modules[i].thread_name; i++) {
1701 - ebpf_update_module(&ebpf_modules[i]);
1702 - }
1703 -}
1704 -
1725 /**
1726 * Entry point
1727 *
@@ -1713,8 +1733,7 @@ static inline void ebpf_load_thread_config()
1733 int main(int argc, char **argv)
1734 {
1735 set_global_variables();
1716 - parse_args(argc, argv);
1717 - ebpf_load_thread_config();
1736 + ebpf_parse_args(argc, argv);
1737 ebpf_manage_pid(getpid());
1738
1739 if (!has_condition_to_run(running_on_kernel)) {
collectors/ebpf.plugin/ebpf.h
+8 -2
@@ -74,7 +74,7 @@ typedef struct netdata_error_report {
74 } netdata_error_report_t;
75
76 extern ebpf_module_t ebpf_modules[];
77 -enum ebpf_module_indexes {
77 +enum ebpf_main_index {
78 EBPF_MODULE_PROCESS_IDX,
79 EBPF_MODULE_SOCKET_IDX,
80 EBPF_MODULE_CACHESTAT_IDX,
@@ -89,7 +89,13 @@ enum ebpf_module_indexes {
89 EBPF_MODULE_HARDIRQ_IDX,
90 EBPF_MODULE_SOFTIRQ_IDX,
91 EBPF_MODULE_OOMKILL_IDX,
92 - EBPF_MODULE_SHM_IDX
92 + EBPF_MODULE_SHM_IDX,
93 + /* THREADS MUST BE INCLUDED BEFORE THIS COMMENT */
94 + EBPF_OPTION_ALL_CHARTS,
95 + EBPF_OPTION_VERSION,
96 + EBPF_OPTION_HELP,
97 + EBPF_OPTION_GLOBAL_CHART,
98 + EBPF_OPTION_RETURN_MODE
99 };
100
101 typedef struct ebpf_tracepoint {
collectors/ebpf.plugin/ebpf_process.c
+13 -10
@@ -930,6 +930,7 @@ static void process_collector(ebpf_module_t *em)
930 int publish_global = em->global_charts;
931 int apps_enabled = em->apps_charts;
932 int cgroups = em->cgroup_charts;
933 + int thread_enabled = em->enabled;
934 if (cgroups)
935 ebpf_process_update_cgroup_algorithm();
936
@@ -966,19 +967,21 @@ static void process_collector(ebpf_module_t *em)
967 }
968 }
969
969 - pthread_mutex_lock(&lock);
970 - if (publish_global) {
971 - ebpf_process_send_data(em);
972 - }
970 + if (thread_enabled) {
971 + pthread_mutex_lock(&lock);
972 + if (publish_global) {
973 + ebpf_process_send_data(em);
974 + }
975
974 - if (publish_apps) {
975 - ebpf_process_send_apps_data(apps_groups_root_target, em);
976 - }
976 + if (publish_apps) {
977 + ebpf_process_send_apps_data(apps_groups_root_target, em);
978 + }
979
978 - if (cgroups) {
979 - ebpf_process_send_cgroup_data(em);
980 + if (cgroups) {
981 + ebpf_process_send_cgroup_data(em);
982 + }
983 + pthread_mutex_unlock(&lock);
984 }
981 - pthread_mutex_unlock(&lock);
985 }
986
987 pthread_mutex_unlock(&lock);