code cleanup
Costa Tsaousis (ktsaou) committed
May 22, 2014 at 23:48 UTC
ac431a74838aa773ad85b45e15652d51043e099d
1 file changed
+81
-61
apps_plugin.c
+81
-61
@@ -113,7 +113,7 @@ struct target *get_target(const char *id, struct target *target)
113
114
w = calloc(sizeof(struct target), 1);
115
if(!w) {
116
- fprintf(stderr, "Cannot allocate %lu bytes of memory\n", sizeof(struct target));
116
+ fprintf(stderr, "apps.plugin: cannot allocate %lu bytes of memory\n", sizeof(struct target));
117
return NULL;
118
}
119
@@ -127,7 +127,7 @@ struct target *get_target(const char *id, struct target *target)
127
w->next = target_root;
128
target_root = w;
129
130
- if(debug) fprintf(stderr, "Adding hook for process '%s', compare '%s' on target '%s'\n", w->id, w->compare, w->target?w->target->id:"");
130
+ if(debug) fprintf(stderr, "apps.plugin: adding hook for process '%s', compare '%s' on target '%s'\n", w->id, w->compare, w->target?w->target->id:"");
131
132
return w;
133
}
@@ -156,10 +156,10 @@ int read_process_groups(const char *name)
156
157
snprintf(filename, FILENAME_MAX, "%s/apps_%s.conf", CONFIG_DIR, name);
158
159
- if(debug) fprintf(stderr, "Process groups file: '%s'\n", filename);
159
+ if(debug) fprintf(stderr, "apps.plugin: process groups file: '%s'\n", filename);
160
FILE *fp = fopen(filename, "r");
161
if(!fp) {
162
- fprintf(stderr, "Cannot open file '%s' (%s)\n", filename, strerror(errno));
162
+ fprintf(stderr, "apps.plugin: ERROR: cannot open file '%s' (%s)\n", filename, strerror(errno));
163
return 1;
164
}
165
@@ -168,13 +168,13 @@ int read_process_groups(const char *name)
168
int whidden = 0, wdebug = 0;
169
line++;
170
171
- // if(debug) fprintf(stderr, "\tread %s\n", buffer);
171
+ // if(debug) fprintf(stderr, "apps.plugin: \tread %s\n", buffer);
172
173
char *s = buffer, *t, *p;
174
s = trim(s);
175
if(!s || !*s || *s == '#') continue;
176
177
- if(debug) fprintf(stderr, "\tread %s\n", s);
177
+ if(debug) fprintf(stderr, "apps.plugin: \tread %s\n", s);
178
179
// the target name
180
t = strsep(&s, ":");
@@ -201,7 +201,7 @@ int read_process_groups(const char *name)
201
if(stop) break;
202
}
203
204
- if(debug) fprintf(stderr, "\t\ttarget %s\n", t);
204
+ if(debug) fprintf(stderr, "apps.plugin: \t\ttarget %s\n", t);
205
206
struct target *w = NULL;
207
long count = 0;
@@ -220,7 +220,7 @@ int read_process_groups(const char *name)
220
}
221
222
if(w) strncpy(w->name, t, MAX_NAME);
223
- if(!count) fprintf(stderr, "the line %ld on file '%s', for group '%s' does not state any process names.\n", line, filename, t);
223
+ if(!count) fprintf(stderr, "apps.plugin: ERROR: the line %ld on file '%s', for group '%s' does not state any process names.\n", line, filename, t);
224
}
225
fclose(fp);
226
@@ -254,7 +254,7 @@ void parse_args(int argc, char **argv)
254
continue;
255
}
256
257
- fprintf(stderr, "Cannot understand option %s\n", argv[i]);
257
+ fprintf(stderr, "apps.plugin: ERROR: cannot understand option %s\n", argv[i]);
258
exit(1);
259
}
260
@@ -262,7 +262,7 @@ void parse_args(int argc, char **argv)
262
if(!name) name = "groups";
263
264
if(read_process_groups(name)) {
265
- fprintf(stderr, "Cannot read process groups %s\n", name);
265
+ fprintf(stderr, "apps.plugin: ERROR: cannot read process groups %s\n", name);
266
exit(1);
267
}
268
}
@@ -385,7 +385,7 @@ struct pid_stat *get_entry(pid_t pid)
385
386
all_pids[pid] = calloc(sizeof(struct pid_stat), 1);
387
if(!all_pids[pid]) {
388
- fprintf(stderr, "Cannot allocate %lu bytes of memory", sizeof(struct pid_stat));
388
+ fprintf(stderr, "apps.plugin: ERROR: Cannot allocate %lu bytes of memory", sizeof(struct pid_stat));
389
return NULL;
390
}
391
@@ -402,7 +402,7 @@ void del_entry(pid_t pid)
402
{
403
if(!all_pids[pid]) return;
404
405
- if(debug) fprintf(stderr, "Process %d %s exited, deleting it.\n", pid, all_pids[pid]->comm);
405
+ if(debug) fprintf(stderr, "apps.plugin: process %d %s exited, deleting it.\n", pid, all_pids[pid]->comm);
406
407
if(root == all_pids[pid]) root = all_pids[pid]->next;
408
if(all_pids[pid]->next) all_pids[pid]->next->prev = all_pids[pid]->prev;
@@ -414,7 +414,7 @@ void del_entry(pid_t pid)
414
415
int update_from_proc(void)
416
{
417
- static long count_open_errors = 0;
417
+ static long count_errors = 0;
418
419
char buffer[PROC_BUFFER + 1];
420
char name[PROC_BUFFER + 1];
@@ -458,8 +458,8 @@ int update_from_proc(void)
458
int fd = open(filename, O_RDONLY);
459
if(fd == -1) {
460
if(errno != ENOENT && errno != ESRCH) {
461
- if(!count_open_errors) fprintf(stderr, "Cannot open file '%s' for reading (%d, %s).\n", filename, errno, strerror(errno));
462
- count_open_errors++;
461
+ if(!count_errors++ || debug)
462
+ fprintf(stderr, "apps.plugin: ERROR: cannot open file '%s' for reading (%d, %s).\n", filename, errno, strerror(errno));
463
}
464
continue;
465
}
@@ -469,13 +469,15 @@ int update_from_proc(void)
469
close(fd);
470
471
if(bytes == -1) {
472
- fprintf(stderr, "Cannot read from file '%s' (%s).\n", filename, strerror(errno));
472
+ if(!count_errors++ || debug)
473
+ fprintf(stderr, "apps.plugin: ERROR: cannot read from file '%s' (%s).\n", filename, strerror(errno));
474
+
475
continue;
476
}
477
478
if(bytes < 10) continue;
479
buffer[bytes] = '\0';
478
- if(debug) fprintf(stderr, "READ stat: %s", buffer);
480
+ if(debug) fprintf(stderr, "apps.plugin: READ stat: %s", buffer);
481
482
p = get_entry(pid);
483
if(!p) continue;
@@ -517,24 +519,27 @@ int update_from_proc(void)
519
strncpy(p->comm, name, MAX_COMPARE_NAME);
520
p->comm[MAX_COMPARE_NAME] = '\0';
521
520
- if(debug || (p->target && p->target->debug)) fprintf(stderr, "VALUES: %s utime=%llu, stime=%llu, cutime=%llu, cstime=%llu, minflt=%llu, majflt=%llu, cminflt=%llu, cmajflt=%llu\n", p->comm, p->utime, p->stime, p->cutime, p->cstime, p->minflt, p->majflt, p->cminflt, p->cmajflt);
522
+ if(debug || (p->target && p->target->debug)) fprintf(stderr, "apps.plugin: VALUES: %s utime=%llu, stime=%llu, cutime=%llu, cstime=%llu, minflt=%llu, majflt=%llu, cminflt=%llu, cmajflt=%llu\n", p->comm, p->utime, p->stime, p->cutime, p->cstime, p->minflt, p->majflt, p->cminflt, p->cmajflt);
523
522
- if(parsed < 39) fprintf(stderr, "file %s gave %d results (expected 44)\n", filename, parsed);
524
+ if(parsed < 39) {
525
+ if(!count_errors++ || debug || (p->target && p->target->debug))
526
+ fprintf(stderr, "apps.plugin: ERROR: file %s gave %d results (expected 44)\n", filename, parsed);
527
+ }
528
529
// check if it is target
530
// we do this only once, the first time this pid is loaded
531
if(p->new_entry) {
527
- if(debug) fprintf(stderr, "\tJust added %s\n", p->comm);
532
+ if(debug) fprintf(stderr, "apps.plugin: \tJust added %s\n", p->comm);
533
534
struct target *w;
535
for(w = target_root; w ; w = w->next) {
531
- // if(debug || (p->target && p->target->debug)) fprintf(stderr, "\t\tcomparing '%s' with '%s'\n", w->compare, p->comm);
536
+ // if(debug || (p->target && p->target->debug)) fprintf(stderr, "apps.plugin: \t\tcomparing '%s' with '%s'\n", w->compare, p->comm);
537
538
if(strcmp(w->compare, p->comm) == 0) {
539
if(w->target) p->target = w->target;
540
else p->target = w;
541
537
- if(debug || (p->target && p->target->debug)) fprintf(stderr, "\t\t%s linked to target %s\n", p->comm, p->target->name);
542
+ if(debug || (p->target && p->target->debug)) fprintf(stderr, "apps.plugin: \t\t%s linked to target %s\n", p->comm, p->target->name);
543
}
544
}
545
}
@@ -550,8 +555,8 @@ int update_from_proc(void)
555
fd = open(filename, O_RDONLY);
556
if(fd == -1) {
557
if(errno != ENOENT && errno != ESRCH) {
553
- if(!count_open_errors) fprintf(stderr, "Cannot open file '%s' for reading (%d, %s).\n", filename, errno, strerror(errno));
554
- count_open_errors++;
558
+ if(!count_errors++ || debug || (p->target && p->target->debug))
559
+ fprintf(stderr, "apps.plugin: ERROR: cannot open file '%s' for reading (%d, %s).\n", filename, errno, strerror(errno));
560
}
561
}
562
else {
@@ -560,11 +565,13 @@ int update_from_proc(void)
565
close(fd);
566
567
if(bytes == -1) {
563
- fprintf(stderr, "Cannot read from file '%s' (%s).\n", filename, strerror(errno));
568
+ if(!count_errors++ || debug || (p->target && p->target->debug))
569
+ fprintf(stderr, "apps.plugin: ERROR: cannot read from file '%s' (%s).\n", filename, strerror(errno));
570
}
571
else if(bytes > 10) {
572
buffer[bytes] = '\0';
567
- if(debug || (p->target && p->target->debug)) fprintf(stderr, "READ statm: %s", buffer);
573
+ if(debug || (p->target && p->target->debug))
574
+ fprintf(stderr, "apps.plugin: READ statm: %s", buffer);
575
576
parsed = sscanf(buffer,
577
"%llu %llu %llu %llu %llu %llu %llu"
@@ -577,7 +584,10 @@ int update_from_proc(void)
584
, &p->statm_dirty
585
);
586
580
- if(parsed < 7) fprintf(stderr, "file %s gave %d results (expected 7)\n", filename, parsed);
587
+ if(parsed < 7) {
588
+ if(!count_errors++ || debug || (p->target && p->target->debug))
589
+ fprintf(stderr, "apps.plugin: ERROR: file %s gave %d results (expected 7)\n", filename, parsed);
590
+ }
591
}
592
}
593
@@ -588,8 +598,8 @@ int update_from_proc(void)
598
fd = open(filename, O_RDONLY);
599
if(fd == -1) {
600
if(errno != ENOENT && errno != ESRCH) {
591
- if(!count_open_errors) fprintf(stderr, "Cannot open file '%s' for reading (%d, %s).\n", filename, errno, strerror(errno));
592
- count_open_errors++;
601
+ if(!count_errors++ || debug || (p->target && p->target->debug))
602
+ fprintf(stderr, "apps.plugin: ERROR: cannot open file '%s' for reading (%d, %s).\n", filename, errno, strerror(errno));
603
}
604
}
605
else {
@@ -598,11 +608,12 @@ int update_from_proc(void)
608
close(fd);
609
610
if(bytes == -1) {
601
- fprintf(stderr, "Cannot read from file '%s' (%s).\n", filename, strerror(errno));
611
+ if(!count_errors++ || debug || (p->target && p->target->debug))
612
+ fprintf(stderr, "apps.plugin: ERROR: cannot read from file '%s' (%s).\n", filename, strerror(errno));
613
}
614
else if(bytes > 10) {
615
buffer[bytes] = '\0';
605
- if(debug || (p->target && p->target->debug)) fprintf(stderr, "READ io: %s", buffer);
616
+ if(debug || (p->target && p->target->debug)) fprintf(stderr, "apps.plugin: READ io: %s", buffer);
617
618
parsed = sscanf(buffer,
619
"rchar: %llu\nwchar: %llu\nsyscr: %llu\nsyscw: %llu\nread_bytes: %llu\nwrite_bytes: %llu\ncancelled_write_bytes: %llu"
@@ -615,7 +626,10 @@ int update_from_proc(void)
626
, &p->io_cancelled_write_bytes
627
);
628
618
- if(parsed < 7) fprintf(stderr, "file %s gave %d results (expected 7)\n", filename, parsed);
629
+ if(parsed < 7) {
630
+ if(!count_errors++ || debug || (p->target && p->target->debug))
631
+ fprintf(stderr, "apps.plugin: ERROR: file %s gave %d results (expected 7)\n", filename, parsed);
632
+ }
633
}
634
}
635
@@ -635,7 +649,10 @@ int update_from_proc(void)
649
sprintf(fdname, "/proc/%s/fd/%s", file->d_name, de->d_name);
650
int l = readlink(fdname, linkname, FILENAME_MAX);
651
if(l == -1) {
638
- fprintf(stderr, "Cannot read link %s\n", fdname);
652
+ if(debug || (p->target && p->target->debug)) {
653
+ if(!count_errors++ || debug || (p->target && p->target->debug))
654
+ fprintf(stderr, "apps.plugin: ERROR: cannot read link %s\n", fdname);
655
+ }
656
continue;
657
}
658
file_counter++;
@@ -651,10 +668,13 @@ int update_from_proc(void)
668
else if(strcmp(linkname, "anon_inode:[timerfd]") == 0) p->opentimerfds++;
669
else if(strcmp(linkname, "anon_inode:[signalfd]") == 0) p->opensignalfds++;
670
else if(strncmp(linkname, "anon_inode:", 11) == 0) {
654
- fprintf(stderr, "anonymous inode: %s\n", linkname);
671
+ if(debug || (p->target && p->target->debug)) fprintf(stderr, "apps.plugin: FIXME: unknown anonymous inode: %s\n", linkname);
672
p->openanoninodes++;
673
}
657
- else p->openother++;
674
+ else {
675
+ if(debug || (p->target && p->target->debug)) fprintf(stderr, "apps.plugin: FIXME: cannot understand linkname: %s\n", linkname);
676
+ p->openother++;
677
+ }
678
}
679
closedir(fds);
680
}
@@ -665,9 +685,9 @@ int update_from_proc(void)
685
// mark it as updated
686
p->updated = 1;
687
}
668
- if(count_open_errors > 1 && count_open_errors > 1000) {
669
- fprintf(stderr, "file open errors repeated %ld times\n", count_open_errors - 1);
670
- count_open_errors = 0;
688
+ if(count_errors > 1000) {
689
+ fprintf(stderr, "apps.plugin: ERROR: %ld more errors encountered\n", count_errors - 1);
690
+ count_errors = 0;
691
}
692
693
closedir(dir);
@@ -718,12 +738,12 @@ void update_statistics(void)
738
// link all parents and update childs count
739
for(p = root; p ; p = p->next) {
740
if(p->ppid > 0 && p->ppid <= pid_max && all_pids[p->ppid]) {
721
- if(debug || (p->target && p->target->debug)) fprintf(stderr, "\tParent of %d %s is %d %s\n", p->pid, p->comm, p->ppid, all_pids[p->ppid]->comm);
741
+ if(debug || (p->target && p->target->debug)) fprintf(stderr, "apps.plugin: \tparent of %d %s is %d %s\n", p->pid, p->comm, p->ppid, all_pids[p->ppid]->comm);
742
743
p->parent = all_pids[p->ppid];
744
p->parent->childs++;
745
}
726
- else if(p->ppid != 0) fprintf(stderr, "\t\tWRONG! pid %d %s states parent %d, but the later does not exist.\n", p->pid, p->comm, p->ppid);
746
+ else if(p->ppid != 0) fprintf(stderr, "apps.plugin: \t\tWRONG! pid %d %s states parent %d, but the later does not exist.\n", p->pid, p->comm, p->ppid);
747
}
748
749
// find all the procs with 0 childs and merge them to their parents
@@ -745,13 +765,13 @@ void update_statistics(void)
765
// the parent inherits the child's target, if it does not have a target itself
766
if(p->target && !p->parent->target) {
767
p->parent->target = p->target;
748
- if(debug || (p->target && p->target->debug)) fprintf(stderr, "\t\ttarget %s is inherited by %d %s from its child %d %s.\n", p->target->name, p->parent->pid, p->parent->comm, p->pid, p->comm);
768
+ if(debug || (p->target && p->target->debug)) fprintf(stderr, "apps.plugin: \t\ttarget %s is inherited by %d %s from its child %d %s.\n", p->target->name, p->parent->pid, p->parent->comm, p->pid, p->comm);
769
}
770
771
found++;
772
}
773
}
754
- if(debug) fprintf(stderr, "Merged %d processes\n", found);
774
+ if(debug) fprintf(stderr, "apps.plugin: merged %d processes\n", found);
775
}
776
777
// give a default target on all top level processes
@@ -788,7 +808,7 @@ void update_statistics(void)
808
for(p = root; p ; p = p->next) {
809
if(p->updated) continue;
810
791
- fprintf(stderr, "UNMERGING %d %s\n", p->pid, p->comm);
811
+ fprintf(stderr, "apps.plugin: UNMERGING %d %s\n", p->pid, p->comm);
812
813
unsigned long long diff_utime = p->utime + p->cutime + p->fix_cutime;
814
unsigned long long diff_stime = p->stime + p->cstime + p->fix_cstime;
@@ -805,35 +825,35 @@ void update_statistics(void)
825
diff_utime -= x;
826
t->diff_cutime -= x;
827
t->fix_cutime += x;
808
- fprintf(stderr, "\t cutime %llu from %d %s %s\n", x, t->pid, t->comm, t->target->name);
828
+ fprintf(stderr, "apps.plugin: \t cutime %llu from %d %s %s\n", x, t->pid, t->comm, t->target->name);
829
}
830
if(diff_stime && t->diff_cstime) {
831
x = (t->diff_cstime < diff_stime)?t->diff_cstime:diff_stime;
832
diff_stime -= x;
833
t->diff_cstime -= x;
834
t->fix_cstime += x;
815
- fprintf(stderr, "\t cstime %llu from %d %s %s\n", x, t->pid, t->comm, t->target->name);
835
+ fprintf(stderr, "apps.plugin: \t cstime %llu from %d %s %s\n", x, t->pid, t->comm, t->target->name);
836
}
837
if(diff_minflt && t->diff_cminflt) {
838
x = (t->diff_cminflt < diff_minflt)?t->diff_cminflt:diff_minflt;
839
diff_minflt -= x;
840
t->diff_cminflt -= x;
841
t->fix_cminflt += x;
822
- fprintf(stderr, "\t cminflt %llu from %d %s %s\n", x, t->pid, t->comm, t->target->name);
842
+ fprintf(stderr, "apps.plugin: \t cminflt %llu from %d %s %s\n", x, t->pid, t->comm, t->target->name);
843
}
844
if(diff_majflt && t->diff_cmajflt) {
845
x = (t->diff_cmajflt < diff_majflt)?t->diff_cmajflt:diff_majflt;
846
diff_majflt -= x;
847
t->diff_cmajflt -= x;
848
t->fix_cmajflt += x;
829
- fprintf(stderr, "\t cmajflt %llu from %d %s %s\n", x, t->pid, t->comm, t->target->name);
849
+ fprintf(stderr, "apps.plugin: \t cmajflt %llu from %d %s %s\n", x, t->pid, t->comm, t->target->name);
850
}
851
}
852
833
- if(diff_utime) fprintf(stderr, "\t cannot fix up utime %llu\n", diff_utime);
834
- if(diff_stime) fprintf(stderr, "\t cannot fix up stime %llu\n", diff_stime);
835
- if(diff_minflt) fprintf(stderr, "\t cannot fix up minflt %llu\n", diff_minflt);
836
- if(diff_majflt) fprintf(stderr, "\t cannot fix up majflt %llu\n", diff_majflt);
853
+ if(diff_utime) fprintf(stderr, "apps.plugin: \t cannot fix up utime %llu\n", diff_utime);
854
+ if(diff_stime) fprintf(stderr, "apps.plugin: \t cannot fix up stime %llu\n", diff_stime);
855
+ if(diff_minflt) fprintf(stderr, "apps.plugin: \t cannot fix up minflt %llu\n", diff_minflt);
856
+ if(diff_majflt) fprintf(stderr, "apps.plugin: \t cannot fix up majflt %llu\n", diff_majflt);
857
}
858
*/
859
// zero all the targets
@@ -884,7 +904,7 @@ void update_statistics(void)
904
// concentrate everything on the targets
905
for(p = root; p ; p = p->next) {
906
if(!p->target) {
887
- fprintf(stderr, "WRONG! pid %d %s was left without a target!\n", p->pid, p->comm);
907
+ fprintf(stderr, "apps.plugin: ERROR: pid %d %s was left without a target!\n", p->pid, p->comm);
908
continue;
909
}
910
@@ -931,7 +951,7 @@ void update_statistics(void)
951
952
p->target->processes++;
953
934
- if(debug || p->target->debug) fprintf(stderr, "\tAgregating %s pid %d on %s utime=%llu, stime=%llu, cutime=%llu, cstime=%llu, minflt=%llu, majflt=%llu, cminflt=%llu, cmajflt=%llu\n", p->comm, p->pid, p->target->name, p->utime, p->stime, p->cutime, p->cstime, p->minflt, p->majflt, p->cminflt, p->cmajflt);
954
+ if(debug || p->target->debug) fprintf(stderr, "apps.plugin: \tAgregating %s pid %d on %s utime=%llu, stime=%llu, cutime=%llu, cstime=%llu, minflt=%llu, majflt=%llu, cminflt=%llu, cmajflt=%llu\n", p->comm, p->pid, p->target->name, p->utime, p->stime, p->cutime, p->cstime, p->minflt, p->majflt, p->cminflt, p->cmajflt);
955
956
/* if(p->utime - p->old_utime > 100) fprintf(stderr, "BIG CHANGE: %d %s utime increased by %llu from %llu to %llu\n", p->pid, p->comm, p->utime - p->old_utime, p->old_utime, p->utime);
957
if(p->cutime - p->old_cutime > 100) fprintf(stderr, "BIG CHANGE: %d %s cutime increased by %llu from %llu to %llu\n", p->pid, p->comm, p->cutime - p->old_cutime, p->old_cutime, p->cutime);
@@ -1205,7 +1225,7 @@ void show_charts(void)
1225
if(!w->exposed && w->processes) {
1226
newly_added++;
1227
w->exposed = 1;
1208
- if(debug || w->debug) fprintf(stderr, "%s just added - regenerating charts.\n", w->name);
1228
+ if(debug || w->debug) fprintf(stderr, "apps.plugin: %s just added - regenerating charts.\n", w->name);
1229
}
1230
1231
// nothing more to show
@@ -1373,7 +1393,7 @@ unsigned long long get_hertz(void)
1393
hz = (sizeof(long)==sizeof(int) || htons(999)==999) ? 100UL : 1024UL;
1394
#endif
1395
1376
- fprintf(stderr, "Unknown HZ value. Assuming %llu.\n", hz);
1396
+ fprintf(stderr, "apps.plugin: ERROR: unknown HZ value. Assuming %llu.\n", hz);
1397
return hz;
1398
}
1399
@@ -1419,7 +1439,7 @@ int main(int argc, char **argv)
1439
1440
all_pids = calloc(sizeof(struct pid_stat *), pid_max);
1441
if(!all_pids) {
1422
- fprintf(stderr, "Cannot allocate %lu bytes of memory.\n", sizeof(struct pid_stat *) * pid_max);
1442
+ fprintf(stderr, "apps.plugin: ERROR: cannot allocate %lu bytes of memory.\n", sizeof(struct pid_stat *) * pid_max);
1443
printf("DISABLE\n");
1444
exit(1);
1445
}
@@ -1431,7 +1451,7 @@ int main(int argc, char **argv)
1451
1452
for(;1; counter++) {
1453
if(!update_from_proc()) {
1434
- fprintf(stderr, "Cannot allocate %lu bytes of memory.\n", sizeof(struct pid_stat *) * pid_max);
1454
+ fprintf(stderr, "apps.plugin: ERROR: cannot allocate %lu bytes of memory.\n", sizeof(struct pid_stat *) * pid_max);
1455
printf("DISABLE\n");
1456
exit(1);
1457
}
@@ -1441,25 +1461,25 @@ int main(int argc, char **argv)
1461
show_dimensions();
1462
// printf("FLUSH xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n");
1463
1444
- if(debug) fprintf(stderr, "Done Loop No %llu\n", counter);
1464
+ if(debug) fprintf(stderr, "apps.plugin: done Loop No %llu\n", counter);
1465
fflush(NULL);
1466
1467
gettimeofday(&now, NULL);
1468
usec = usecdiff(&now, &last) - susec;
1449
- if(debug) fprintf(stderr, "last loop took %llu usec (worked for %llu, sleeped for %llu).\n", usec + susec, usec, susec);
1469
+ if(debug) fprintf(stderr, "apps.plugin: last loop took %llu usec (worked for %llu, sleeped for %llu).\n", usec + susec, usec, susec);
1470
1471
// if the last loop took less than half the time
1472
// wait the rest of the time
1473
if(usec < (update_every * 1000000ULL / 2)) susec = (update_every * 1000000ULL) - usec;
1474
else susec = update_every * 1000000ULL / 2;
1475
1456
- //fprintf(stderr, "sleeping for %llu...", susec);
1476
+ //fprintf(stderr, "apps.plugin: sleeping for %llu...", susec);
1477
//fflush(NULL);
1478
//struct timeval before, after;
1479
//gettimeofday(&before, NULL);
1480
usleep(susec);
1481
//gettimeofday(&after, NULL);
1462
- //fprintf(stderr, " sleeped for %llu\n", usecdiff(&after, &before));
1482
+ //fprintf(stderr, "apps.plugin: sleeped for %llu\n", usecdiff(&after, &before));
1483
//fflush(NULL);
1484
1485
bcopy(&now, &last, sizeof(struct timeval));