From 56160b9cdc5dbe75bc860d5344f6ebc1cd0b690c Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sat, 29 Jul 2017 18:22:47 -0700 Subject: [PATCH] kcollect - Fix gunplot warning when -x -f is specified * gnuplot warns about multiple set terminal commands when the refresh occurs. Rearrange when the command is sent to avoid the problem. --- usr.bin/kcollect/gnuplot.c | 58 ++++++++++++++++++++++----------------------- usr.bin/kcollect/kcollect.c | 8 +++---- usr.bin/kcollect/kcollect.h | 4 ++-- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/usr.bin/kcollect/gnuplot.c b/usr.bin/kcollect/gnuplot.c index 703f488b90..593b081398 100644 --- a/usr.bin/kcollect/gnuplot.c +++ b/usr.bin/kcollect/gnuplot.c @@ -32,41 +32,13 @@ #include "kcollect.h" void -start_gnuplot(int ac __unused, char **av __unused) +start_gnuplot(int ac __unused, char **av __unused, const char *plotfile) { OutFP = popen("gnuplot", "w"); if (OutFP == NULL) { fprintf(stderr, "can't find gnuplot\n"); exit(1); } -} - -void -dump_gnuplot(kcollect_t *ary, size_t count, const char *plotfile) -{ - int plot1[] = { KCOLLECT_MEMFRE, KCOLLECT_MEMCAC, - KCOLLECT_MEMINA, KCOLLECT_MEMACT, - KCOLLECT_MEMWIR, KCOLLECT_LOAD }; - int plot2[] = { KCOLLECT_IDLEPCT, KCOLLECT_INTRPCT, - KCOLLECT_SYSTPCT, KCOLLECT_USERPCT, - KCOLLECT_VMFAULT, KCOLLECT_SYSCALLS, KCOLLECT_NLOOKUP }; - const char *id1[] = { - "free", "cache", - "inact", "active", - "wired", "load" }; - const char *id2[] = { - "idle", "intr", "system", "user", - "faults", "syscalls", "nlookups" }; - struct tm *tmv; - char buf[64]; - uint64_t value; - time_t t; - double dv; - double smoothed_dv; - int i; - int j; - int jj; - int k; /* * If plotfile is specified allow .jpg or .JPG or .png or .PNG @@ -96,6 +68,34 @@ dump_gnuplot(kcollect_t *ary, size_t count, const char *plotfile) fprintf(OutFP, "set terminal x11 persist size %d,%d\n", OutputWidth, OutputHeight); } +} + +void +dump_gnuplot(kcollect_t *ary, size_t count) +{ + int plot1[] = { KCOLLECT_MEMFRE, KCOLLECT_MEMCAC, + KCOLLECT_MEMINA, KCOLLECT_MEMACT, + KCOLLECT_MEMWIR, KCOLLECT_LOAD }; + int plot2[] = { KCOLLECT_IDLEPCT, KCOLLECT_INTRPCT, + KCOLLECT_SYSTPCT, KCOLLECT_USERPCT, + KCOLLECT_VMFAULT, KCOLLECT_SYSCALLS, KCOLLECT_NLOOKUP }; + const char *id1[] = { + "free", "cache", + "inact", "active", + "wired", "load" }; + const char *id2[] = { + "idle", "intr", "system", "user", + "faults", "syscalls", "nlookups" }; + struct tm *tmv; + char buf[64]; + uint64_t value; + time_t t; + double dv; + double smoothed_dv; + int i; + int j; + int jj; + int k; /* * NOTE: be sure to reset any fields adjusted by the second plot, diff --git a/usr.bin/kcollect/kcollect.c b/usr.bin/kcollect/kcollect.c index 84116f5fc2..44a273d8f6 100644 --- a/usr.bin/kcollect/kcollect.c +++ b/usr.bin/kcollect/kcollect.c @@ -143,7 +143,7 @@ main(int ac, char **av) last_ticks = 0; if (cmd == 'x' || cmd == 'w') - start_gnuplot(ac - optind, av + optind); + start_gnuplot(ac - optind, av + optind, datafile); do { /* @@ -212,15 +212,15 @@ main(int ac, char **av) break; /* NOT REACHED */ case 'g': if (count > 2) - dump_gnuplot(ary, count, NULL); + dump_gnuplot(ary, count); break; case 'w': if (count >= 2) - dump_gnuplot(ary, count, datafile); + dump_gnuplot(ary, count); break; case 'x': if (count > 2) - dump_gnuplot(ary, count, NULL); + dump_gnuplot(ary, count); break; } if (keepalive) { diff --git a/usr.bin/kcollect/kcollect.h b/usr.bin/kcollect/kcollect.h index 190af2b841..d66fc0897a 100644 --- a/usr.bin/kcollect/kcollect.h +++ b/usr.bin/kcollect/kcollect.h @@ -46,5 +46,5 @@ extern int OutputWidth; extern int OutputHeight; extern int SmoothOpt; -void start_gnuplot(int ac, char **av); -void dump_gnuplot(kcollect_t *ary, size_t count, const char *plotfile); +void start_gnuplot(int ac, char **av, const char *plotfile); +void dump_gnuplot(kcollect_t *ary, size_t count); -- 2.11.4.GIT