increased the cmdline buffer of apps.plugin; added kafka and zookeeper to apps_groups.conf; fixes #2227
Costa Tsaousis (ktsaou) committed
May 24, 2017 at 11:46 UTC
c096e4ab50052225cfd161230835a12b994ca9d6
2 files changed
+15
-9
conf.d/apps_groups.conf
+3
@@ -241,6 +241,9 @@ kernel: fsnotify_mark kthrotld deferwq scsi_*
241
# -----------------------------------------------------------------------------
242
# other application servers
243
244
+kafka: *kafka.Kafka*
245
+zookeeper: *org.apache.zookeeper.server.quorum.QuorumPeerMain*
246
+
247
crsproxy: crsproxy
248
sidekiq: *sidekiq*
249
java: java
src/apps_plugin.c
+12
-9
@@ -34,8 +34,7 @@
34
35
#define MAX_COMPARE_NAME 100
36
#define MAX_NAME 100
37
-#define MAX_CMDLINE 1024
38
-
37
+#define MAX_CMDLINE 16384
38
39
// ----------------------------------------------------------------------------
40
// the rates we are going to send to netdata will have this detail a value of:
@@ -223,7 +222,7 @@ size_t
222
struct pid_stat {
223
int32_t pid;
224
char comm[MAX_COMPARE_NAME + 1];
226
- char cmdline[MAX_CMDLINE + 1];
225
+ char *cmdline;
226
227
uint32_t log_thrown;
228
@@ -698,6 +697,7 @@ static inline void del_pid_entry(pid_t pid) {
697
freez(p->statm_filename);
698
freez(p->io_filename);
699
freez(p->cmdline_filename);
700
+ freez(p->cmdline);
701
freez(p);
702
703
all_pids[pid] = NULL;
@@ -768,7 +768,7 @@ static inline void assign_target_to_pid(struct pid_stat *p) {
768
if(unlikely(( (!w->starts_with && !w->ends_with && w->comparehash == hash && !strcmp(w->compare, p->comm))
769
|| (w->starts_with && !w->ends_with && !strncmp(w->compare, p->comm, w->comparelen))
770
|| (!w->starts_with && w->ends_with && pclen >= w->comparelen && !strcmp(w->compare, &p->comm[pclen - w->comparelen]))
771
- || (proc_pid_cmdline_is_needed && w->starts_with && w->ends_with && strstr(p->cmdline, w->compare))
771
+ || (proc_pid_cmdline_is_needed && w->starts_with && w->ends_with && p->cmdline && strstr(p->cmdline, w->compare))
772
))) {
773
774
if(w->target) p->target = w->target;
@@ -787,6 +787,7 @@ static inline void assign_target_to_pid(struct pid_stat *p) {
787
// update pids from proc
788
789
static inline int read_proc_pid_cmdline(struct pid_stat *p) {
790
+ static char cmdline[MAX_CMDLINE + 1];
791
792
#ifdef __FreeBSD__
793
size_t i, bytes = MAX_CMDLINE;
@@ -796,7 +797,7 @@ static inline int read_proc_pid_cmdline(struct pid_stat *p) {
797
mib[1] = KERN_PROC;
798
mib[2] = KERN_PROC_ARGS;
799
mib[3] = p->pid;
799
- if (unlikely(sysctl(mib, 4, p->cmdline, &bytes, NULL, 0)))
800
+ if (unlikely(sysctl(mib, 4, cmdline, &bytes, NULL, 0)))
801
goto cleanup;
802
#else
803
if(unlikely(!p->cmdline_filename)) {
@@ -808,15 +809,17 @@ static inline int read_proc_pid_cmdline(struct pid_stat *p) {
809
int fd = open(p->cmdline_filename, O_RDONLY, 0666);
810
if(unlikely(fd == -1)) goto cleanup;
811
811
- ssize_t i, bytes = read(fd, p->cmdline, MAX_CMDLINE);
812
+ ssize_t i, bytes = read(fd, cmdline, MAX_CMDLINE);
813
close(fd);
814
815
if(unlikely(bytes < 0)) goto cleanup;
816
#endif
817
817
- p->cmdline[bytes] = '\0';
818
+ cmdline[bytes] = '\0';
819
for(i = 0; i < bytes ; i++)
819
- if(unlikely(!p->cmdline[i])) p->cmdline[i] = ' ';
820
+ if(unlikely(!cmdline[i])) cmdline[i] = ' ';
821
+
822
+ p->cmdline = strdupz(cmdline);
823
824
if(unlikely(debug))
825
fprintf(stderr, "Read file '%s' contents: %s\n", p->cmdline_filename, p->cmdline);
@@ -825,7 +828,7 @@ static inline int read_proc_pid_cmdline(struct pid_stat *p) {
828
829
cleanup:
830
// copy the command to the command line
828
- strncpyz(p->cmdline, p->comm, MAX_CMDLINE);
831
+ p->cmdline = strdupz(p->comm);
832
return 0;
833
}
834