@cryptotaxi247 / netdata-1 / commits / 2a6ba8065

expose CmdLine in apps function (#15275)

Ilya Mashchenko committed Jun 30, 2023 at 10:16 UTC 2a6ba8065a257b41dafbd8207e4e36496cf90f7a
1 file changed +21 -10
collectors/apps.plugin/apps_plugin.c
+21 -10
@@ -106,6 +106,7 @@ static int
106 enable_file_charts = 1,
107 max_fds_cache_seconds = 60,
108 #endif
109 + enable_function_cmdline = 0,
110 enable_detailed_uptime_charts = 0,
111 enable_users_charts = 1,
112 enable_groups_charts = 1,
@@ -4122,6 +4123,10 @@ static void parse_args(int argc, char **argv)
4123 enable_detailed_uptime_charts = 1;
4124 continue;
4125 }
4126 + if(strcmp("with-function-cmdline", argv[i]) == 0) {
4127 + enable_function_cmdline = 1;
4128 + continue;
4129 + }
4130
4131 if(strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
4132 fprintf(stderr,
@@ -4139,6 +4144,11 @@ static void parse_args(int argc, char **argv)
4144 "\n"
4145 " debug enable debugging (lot of output)\n"
4146 "\n"
4147 + " with-function-cmdline enable reporting the complete command line for processes\n"
4148 + " it includes the command and passed arguments\n"
4149 + " it may include sensitive data such as passwords and tokens\n"
4150 + " enabling this could be a security risk\n"
4151 + "\n"
4152 " with-childs\n"
4153 " without-childs enable / disable aggregating exited\n"
4154 " children resources into parents\n"
@@ -4538,10 +4548,10 @@ static void apps_plugin_function_processes(const char *transaction, char *functi
4548 // cmd
4549 buffer_json_add_array_item_string(wb, p->comm);
4550
4541 -#ifdef NETDATA_DEV_MODE
4551 // cmdline
4543 - buffer_json_add_array_item_string(wb, (p->cmdline && *p->cmdline) ? p->cmdline : p->comm);
4544 -#endif
4552 + if (enable_function_cmdline) {
4553 + buffer_json_add_array_item_string(wb, (p->cmdline && *p->cmdline) ? p->cmdline : p->comm);
4554 + }
4555
4556 // ppid
4557 buffer_json_add_array_item_uint64(wb, p->ppid);
@@ -4648,13 +4658,14 @@ static void apps_plugin_function_processes(const char *transaction, char *functi
4658 RRDF_FIELD_FILTER_MULTISELECT,
4659 RRDF_FIELD_OPTS_VISIBLE | RRDF_FIELD_OPTS_STICKY, NULL);
4660
4651 -#ifdef NETDATA_DEV_MODE
4652 - buffer_rrdf_table_add_field(wb, field_id++, "CmdLine", "Command Line", RRDF_FIELD_TYPE_DETAIL_STRING,
4653 - RRDF_FIELD_VISUAL_VALUE, RRDF_FIELD_TRANSFORM_NONE, 0,
4654 - NULL, NAN, RRDF_FIELD_SORT_ASCENDING, NULL, RRDF_FIELD_SUMMARY_COUNT,
4655 - RRDF_FIELD_FILTER_MULTISELECT,
4656 - RRDF_FIELD_OPTS_NONE, NULL);
4657 -#endif
4661 + if (enable_function_cmdline) {
4662 + buffer_rrdf_table_add_field(wb, field_id++, "CmdLine", "Command Line", RRDF_FIELD_TYPE_STRING,
4663 + RRDF_FIELD_VISUAL_VALUE, RRDF_FIELD_TRANSFORM_NONE, 0,
4664 + NULL, NAN, RRDF_FIELD_SORT_ASCENDING, NULL, RRDF_FIELD_SUMMARY_COUNT,
4665 + RRDF_FIELD_FILTER_MULTISELECT,
4666 + RRDF_FIELD_OPTS_NONE, NULL);
4667 + }
4668 +
4669 buffer_rrdf_table_add_field(wb, field_id++, "PPID", "Parent Process ID", RRDF_FIELD_TYPE_INTEGER,
4670 RRDF_FIELD_VISUAL_VALUE, RRDF_FIELD_TRANSFORM_NUMBER, 0, NULL,
4671 NAN, RRDF_FIELD_SORT_ASCENDING, "PID", RRDF_FIELD_SUMMARY_COUNT,