|
|
87cc1f |
commit 2ab1cf5d1e547f991c64dde97749a666c045fc25
|
|
|
87cc1f |
Author: Nathan Scott <nathans@redhat.com>
|
|
|
87cc1f |
Date: Tue Oct 29 02:28:10 2019 +1100
|
|
|
87cc1f |
|
|
|
87cc1f |
pcp-atopsar: fix mishandling of some command line arguments
|
|
|
87cc1f |
|
|
|
87cc1f |
Cleanup several aspects of command line handling in pcp-atopsar,
|
|
|
87cc1f |
and resolve a reported bug where the samples argument was not
|
|
|
87cc1f |
honoured due to shadowing of a same-named variable with atop.
|
|
|
87cc1f |
|
|
|
87cc1f |
Resolves Red Hat BZ 1764748.
|
|
|
87cc1f |
|
|
|
87cc1f |
diff --git a/qa/785 b/qa/785
|
|
|
87cc1f |
index 89e564d2a..5f637367b 100755
|
|
|
87cc1f |
--- a/qa/785
|
|
|
87cc1f |
+++ b/qa/785
|
|
|
87cc1f |
@@ -1,4 +1,4 @@
|
|
|
87cc1f |
-#!/bin/sh
|
|
|
87cc1f |
+#!/usr/bin/sh
|
|
|
87cc1f |
# PCP QA Test No. 785
|
|
|
87cc1f |
# Basic checkout of the pcp-atopsar(1) utility.
|
|
|
87cc1f |
#
|
|
|
87cc1f |
@@ -51,10 +51,11 @@ echo; echo == Checking sample count and interval
|
|
|
87cc1f |
export PCP_ARCHIVE=$here/archives/pcp-atop
|
|
|
87cc1f |
pcp -z atopsar -m 2 3 > $tmp.mem1
|
|
|
87cc1f |
pcp -z -t 2 -s 3 atopsar -m > $tmp.mem2
|
|
|
87cc1f |
-unset PCP_ARCHIVE
|
|
|
87cc1f |
test -s $tmp.mem1 || echo "Unexpected empty file 1"
|
|
|
87cc1f |
test -s $tmp.mem2 || echo "Unexpected empty file 2"
|
|
|
87cc1f |
diff $tmp.mem1 $tmp.mem2 && echo OK
|
|
|
87cc1f |
+pcp -z atopsar -m 1 2 | _filter
|
|
|
87cc1f |
+unset PCP_ARCHIVE
|
|
|
87cc1f |
|
|
|
87cc1f |
echo; echo == Check handling of missing values
|
|
|
87cc1f |
pcp atopsar -r archives/pcp-vmstat
|
|
|
87cc1f |
diff --git a/qa/785.out b/qa/785.out
|
|
|
87cc1f |
index 32207712c..e38b7e743 100644
|
|
|
87cc1f |
--- a/qa/785.out
|
|
|
87cc1f |
+++ b/qa/785.out
|
|
|
87cc1f |
@@ -89,6 +89,13 @@ HOST-SUMMARY-LINE
|
|
|
87cc1f |
== Checking sample count and interval
|
|
|
87cc1f |
OK
|
|
|
87cc1f |
|
|
|
87cc1f |
+HOST-SUMMARY-LINE
|
|
|
87cc1f |
+
|
|
|
87cc1f |
+-------------------------- analysis date: 2015/09/25 --------------------------
|
|
|
87cc1f |
+
|
|
|
87cc1f |
+11:03:21 memtotal memfree buffers cached dirty slabmem swptotal swpfree _mem_
|
|
|
87cc1f |
+11:03:21 3849M 196M 275M 1553M 0M 357M 13661M 13652M
|
|
|
87cc1f |
+
|
|
|
87cc1f |
== Check handling of missing values
|
|
|
87cc1f |
pcp-atopsar: no per-processor values available
|
|
|
87cc1f |
pcp-atopsar: no per-interface values available
|
|
|
87cc1f |
diff --git a/src/pcp/atop/atop.c b/src/pcp/atop/atop.c
|
|
|
87cc1f |
index cf6ec821f..fbfc19c89 100644
|
|
|
87cc1f |
--- a/src/pcp/atop/atop.c
|
|
|
87cc1f |
+++ b/src/pcp/atop/atop.c
|
|
|
87cc1f |
@@ -173,7 +173,7 @@ struct visualize vis = {generic_samp, generic_error,
|
|
|
87cc1f |
** argument values
|
|
|
87cc1f |
*/
|
|
|
87cc1f |
static char awaittrigger; /* boolean: awaiting trigger */
|
|
|
87cc1f |
-static unsigned int nsamples = 0xffffffff;
|
|
|
87cc1f |
+unsigned int nsamples = 0xffffffff;
|
|
|
87cc1f |
static char midnightflag;
|
|
|
87cc1f |
|
|
|
87cc1f |
/*
|
|
|
87cc1f |
@@ -294,7 +294,6 @@ main(int argc, char *argv[])
|
|
|
87cc1f |
if ( (p = getenv("HOME")) )
|
|
|
87cc1f |
{
|
|
|
87cc1f |
pmsprintf(path, sizeof(path), "%s/.atoprc", p);
|
|
|
87cc1f |
- path[sizeof(path)-1] = '\0';
|
|
|
87cc1f |
readrc(path, 0);
|
|
|
87cc1f |
}
|
|
|
87cc1f |
|
|
|
87cc1f |
@@ -424,7 +423,7 @@ main(int argc, char *argv[])
|
|
|
87cc1f |
if (opts.narchives > 0)
|
|
|
87cc1f |
rawreadflag++;
|
|
|
87cc1f |
|
|
|
87cc1f |
- __pmEndOptions(&opts);
|
|
|
87cc1f |
+ close_options(&opts);
|
|
|
87cc1f |
|
|
|
87cc1f |
if (opts.errors)
|
|
|
87cc1f |
prusage(pmGetProgname(), &opts);
|
|
|
87cc1f |
diff --git a/src/pcp/atop/atop.h b/src/pcp/atop/atop.h
|
|
|
87cc1f |
index 45f09dc76..c10e5e13a 100644
|
|
|
87cc1f |
--- a/src/pcp/atop/atop.h
|
|
|
87cc1f |
+++ b/src/pcp/atop/atop.h
|
|
|
87cc1f |
@@ -175,6 +175,7 @@ int contcompar(const void *, const void *);
|
|
|
87cc1f |
count_t subcount(count_t, count_t);
|
|
|
87cc1f |
|
|
|
87cc1f |
void setup_options(struct pmOptions *, char **, char *);
|
|
|
87cc1f |
+void close_options(struct pmOptions *);
|
|
|
87cc1f |
void rawread(struct pmOptions *);
|
|
|
87cc1f |
void rawfolio(struct pmOptions *);
|
|
|
87cc1f |
void rawarchive(struct pmOptions *, const char *);
|
|
|
87cc1f |
diff --git a/src/pcp/atop/atopsar.c b/src/pcp/atop/atopsar.c
|
|
|
87cc1f |
index 47324e757..4a61c8dc5 100644
|
|
|
87cc1f |
--- a/src/pcp/atop/atopsar.c
|
|
|
87cc1f |
+++ b/src/pcp/atop/atopsar.c
|
|
|
87cc1f |
@@ -48,7 +48,6 @@
|
|
|
87cc1f |
/*
|
|
|
87cc1f |
** miscellaneous values
|
|
|
87cc1f |
*/
|
|
|
87cc1f |
-static unsigned int nsamples = 9999999;
|
|
|
87cc1f |
static char stampalways;
|
|
|
87cc1f |
static char usemarkers;
|
|
|
87cc1f |
static char allresources;
|
|
|
87cc1f |
@@ -74,6 +73,7 @@ struct pridef {
|
|
|
87cc1f |
char *about; /* statistics about what */
|
|
|
87cc1f |
};
|
|
|
87cc1f |
|
|
|
87cc1f |
+extern unsigned int nsamples;
|
|
|
87cc1f |
extern struct pridef pridef[]; /* table of print-functions */
|
|
|
87cc1f |
extern int pricnt; /* total number of print-functions */
|
|
|
87cc1f |
|
|
|
87cc1f |
@@ -272,13 +272,13 @@ atopsar(int argc, char *argv[])
|
|
|
87cc1f |
rawreadflag++;
|
|
|
87cc1f |
}
|
|
|
87cc1f |
|
|
|
87cc1f |
- __pmEndOptions(&opts);
|
|
|
87cc1f |
+ close_options(&opts);
|
|
|
87cc1f |
|
|
|
87cc1f |
if (opts.errors)
|
|
|
87cc1f |
- prusage(pmGetProgname(), &opts);
|
|
|
87cc1f |
+ pratopsaruse(pmGetProgname(), &opts);
|
|
|
87cc1f |
|
|
|
87cc1f |
- if (opts.samples)
|
|
|
87cc1f |
- nsamples = opts.samples;
|
|
|
87cc1f |
+ if (opts.samples > 0)
|
|
|
87cc1f |
+ nsamples = opts.samples + 1;
|
|
|
87cc1f |
|
|
|
87cc1f |
if (opts.interval.tv_sec || opts.interval.tv_usec)
|
|
|
87cc1f |
interval = opts.interval;
|
|
|
87cc1f |
@@ -314,9 +314,9 @@ atopsar(int argc, char *argv[])
|
|
|
87cc1f |
if (rawreadflag)
|
|
|
87cc1f |
{
|
|
|
87cc1f |
vis.show_samp = reportraw;
|
|
|
87cc1f |
- vis.prep = prep;
|
|
|
87cc1f |
- vis.next = next_prinow;
|
|
|
87cc1f |
- prinow = 0;
|
|
|
87cc1f |
+ vis.prep = prep;
|
|
|
87cc1f |
+ vis.next = next_prinow;
|
|
|
87cc1f |
+ prinow = 0;
|
|
|
87cc1f |
}
|
|
|
87cc1f |
else
|
|
|
87cc1f |
vis.show_samp = reportlive;
|
|
|
87cc1f |
diff --git a/src/pcp/atop/various.c b/src/pcp/atop/various.c
|
|
|
87cc1f |
index 1a89af05d..afd418279 100644
|
|
|
87cc1f |
--- a/src/pcp/atop/various.c
|
|
|
87cc1f |
+++ b/src/pcp/atop/various.c
|
|
|
87cc1f |
@@ -71,6 +71,15 @@ setup_options(pmOptions *opts, char **argv, char *short_options)
|
|
|
87cc1f |
__pmStartOptions(opts);
|
|
|
87cc1f |
}
|
|
|
87cc1f |
|
|
|
87cc1f |
+void
|
|
|
87cc1f |
+close_options(pmOptions *opts)
|
|
|
87cc1f |
+{
|
|
|
87cc1f |
+ __pmEndOptions(opts);
|
|
|
87cc1f |
+
|
|
|
87cc1f |
+ if (opts->errors)
|
|
|
87cc1f |
+ pmflush();
|
|
|
87cc1f |
+}
|
|
|
87cc1f |
+
|
|
|
87cc1f |
/*
|
|
|
87cc1f |
** Function convtime() converts a value (number of seconds since
|
|
|
87cc1f |
** 1-1-1970) to an ascii-string in the format hh:mm:ss, stored in
|