mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
cpumf/lshwc: Add command line flag for run time
Add a command line flag to specify run time of lshwc command in terms of days, hours, minutes and seconds. The command line flag is named -t and has a number as argument followed by one of the letters 's' for seconds (default), 'm' for minutes, 'h' for hours and 'd' for days. Default is seconds when no trailing letter is detected. Signed-off-by: Thomas Richter <tmricht@linux.ibm.com> Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
9f9dddddd4
commit
b4cc30ac10
@@ -51,7 +51,7 @@
|
||||
|
||||
static unsigned int read_interval = IOCTLSLEEP;
|
||||
static int cfvn, csvn, authorization;
|
||||
static unsigned long loop_count = 1;
|
||||
static unsigned long loop_count = 1, timeout;
|
||||
static unsigned char *ioctlbuffer;
|
||||
static bool allcpu;
|
||||
static char *ctrformat = "%ld";
|
||||
@@ -684,6 +684,11 @@ static struct util_opt opt_vec[] = {
|
||||
.option = { "delta", no_argument, NULL, 'd' },
|
||||
.desc = "Display delta counter values"
|
||||
},
|
||||
{
|
||||
.option = { "timeout", required_argument, NULL, 't' },
|
||||
.argument = "NUMBER",
|
||||
.desc = "run time in s (seconds) m (minutes) h (hours) and d (days)"
|
||||
},
|
||||
UTIL_OPT_HELP,
|
||||
UTIL_OPT_VERSION,
|
||||
UTIL_OPT_END
|
||||
@@ -713,6 +718,7 @@ static void have_support(void)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unsigned long no;
|
||||
char *slash;
|
||||
int ch;
|
||||
|
||||
@@ -763,9 +769,38 @@ int main(int argc, char **argv)
|
||||
delta = true;
|
||||
firstread = true;
|
||||
break;
|
||||
case 't':
|
||||
errno = 0;
|
||||
no = strtoul(optarg, &slash, 0);
|
||||
if (errno)
|
||||
errx(EXIT_FAILURE, "Invalid argument for -%c", ch);
|
||||
switch (*slash) {
|
||||
case 's':
|
||||
case '\0':
|
||||
timeout += no;
|
||||
break;
|
||||
case 'm':
|
||||
timeout += no * 60;
|
||||
break;
|
||||
case 'h':
|
||||
timeout += no * 60 * 60;
|
||||
break;
|
||||
case 'd':
|
||||
timeout += no * 60 * 60 * 24;
|
||||
break;
|
||||
default:
|
||||
errx(EXIT_FAILURE, "Invalid argument for -%c", ch);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (timeout && timeout < read_interval)
|
||||
read_interval = timeout;
|
||||
/* If no timeout specified, simply add zero */
|
||||
loop_count += timeout / read_interval;
|
||||
|
||||
have_support();
|
||||
if (!libcpumf_cpumcf_info(&cfvn, &csvn, &authorization))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
@@ -14,11 +14,13 @@ lshwc \- extract CPU Measurement Facilities counter sets
|
||||
.
|
||||
.SH SYNOPSIS
|
||||
\*c
|
||||
.RB [ \-a ][ \-d][ \-H][ \-s ][ \-x ][ \-X]
|
||||
.RB [ \-a ][ \-d ][ \-H ][ \-s ][ \-x ][ \-X ]
|
||||
.RB [ \-l
|
||||
.IR count ]
|
||||
.RB [ \-i
|
||||
.IR interval ]
|
||||
.RB [ \-t
|
||||
.IR time ]
|
||||
\fR[\fIcpulist\fR][:\fIsets\fR]\fP
|
||||
.br
|
||||
\*c
|
||||
@@ -99,6 +101,23 @@ Undefined counter.
|
||||
.RE
|
||||
.
|
||||
.TP
|
||||
.BR \-t ", " \-\-time
|
||||
Specifies the runtime in form of days, hours, minutes or seconds.
|
||||
This option can be specified multiple times and the runtime adds up.
|
||||
Time is a number followed by one of the letters
|
||||
.RS
|
||||
.IP d
|
||||
Specifies number as days.
|
||||
.IP h
|
||||
Specifies number as hours.
|
||||
.IP m
|
||||
Specifies number as minutes.
|
||||
.IP s
|
||||
Specifies number as seconds. This is the default when no
|
||||
letter follows the number.
|
||||
.RE
|
||||
.
|
||||
.TP
|
||||
.BR \-x ", " \-\-hex
|
||||
Displays counter values as hexadecimal values.
|
||||
.
|
||||
|
||||
Reference in New Issue
Block a user