Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1857121

Summary: `pcp atopsar` misinterprets `-H` option
Product: Red Hat Enterprise Linux 8 Reporter: Denis Volkov <dvolkov>
Component: pcpAssignee: Nathan Scott <nathans>
Status: CLOSED ERRATA QA Contact: Jan Kurik <jkurik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.2CC: agerstmayr, cww, jkurik, mgoodwin, nathans, patrickm
Target Milestone: rcKeywords: Bugfix, Triaged
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcp-5.2.1 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 15:19:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1854035    
Bug Blocks:    

Description Denis Volkov 2020-07-15 07:47:59 UTC
Description of problem:
`pcp atopsar` has `-H` option:

          -H  repeat report headers (in case of tty: depending on screen lines)

But it changes behaviour of pcp-atopsar instead of just adding the headers.

Version-Release number of selected component (if applicable):
pcp-5.0.2-5.el8.x86_64

Steps to Reproduce:
1. run `pcp atopsar`. The output is the data from the beginning of pmlogger:

# pcp atopsar |head

fastvm-rhel-8-1-189  4.18.0-193.6.3.el8_2.x86_64  #1 SMP Mon Jun 1 20:24:55 UTC 2020  x86_64  2020/07/15

-------------------------- analysis date: 2020/07/10 --------------------------

00:10:22  cpu  %usr %nice %sys %irq %softirq  %steal %guest  %wait %idle  _cpu_

00:10:42  cpu  %usr %nice %sys %irq %softirq  %steal %guest  %wait %idle  _cpu_
00:10:42  all     5     0    4    0        0       0      0      0   190
            0     3     0    2    0        0       0      0      0    94


2. run `pcp atopsar -H` (added -H flag). The output changes to output of current data:

# pcp atopsar -H 3

fastvm-rhel-8-1-189  4.18.0-193.6.3.el8_2.x86_64  #1 SMP Mon Jun 1 20:24:55 UTC 2020  x86_64  2020/07/15

-------------------------- analysis date: 2020/07/15 --------------------------

08:35:04  cpu  %usr %nice %sys %irq %softirq  %steal %guest  %wait %idle  _cpu_
08:35:07  all     0     0    1    0        0       0      0      0   199
            0     0     0    0    0        0       0      0      0   100
            1     0     0    1    0        0       0      0      0    99
08:35:10  all     0     0    1    0        0       0      0      0   199
            0     0     0    0    0        0       0      0      0   100
            1     0     0    1    0        0       0      0      0    99
08:35:13  all     0     0    1    0        0       0      0      0   199
            0     0     0    0    0        0       0      0      0   100
            1     0     0    1    0        0       0      0      0    99
08:35:16  all     0     0    1    0        0       0      0      0   199
            0     0     0    0    0        0       0      0      0   100
            1     0     0    1    0        0       0      0      0    99
08:35:19  all     0     0    1    0        0       0      0      0   199
            0     0     0    0    0        0       0      0      0   100
            1     0     0    1    0        0       0      0      0    99
08:35:22  all     0     0    1    0        0       0      0      0   199
            0     0     0    0    0        0       0      0      0   100

As shown, `pcp atopsar` interprets `-H 3` as `--interval 3` making it show the current data every 3 seconds
          --interval DELTA      sampling interval


Additional info:
At the same time if run with `-r` option, `pcp atopsar` interprets `-H` correctly - it starts adding header lines:

# pcp atopsar  -r /var/log/pcp/pmlogger/fastvm-rhel-8-1-189/ -H 

fastvm-rhel-8-1-189  4.18.0-193.6.3.el8_2.x86_64  #1 SMP Mon Jun 1 20:24:55 UTC 2020  x86_64  2020/07/15

-------------------------- analysis date: 2020/07/10 --------------------------

00:10:22  cpu  %usr %nice %sys %irq %softirq  %steal %guest  %wait %idle  _cpu_

00:10:42  cpu  %usr %nice %sys %irq %softirq  %steal %guest  %wait %idle  _cpu_
00:10:42  all     5     0    4    0        0       0      0      0   190
            0     3     0    2    0        0       0      0      0    94
            1     2     0    2    0        0       0      0      0    96
...
00:13:22  cpu  %usr %nice %sys %irq %softirq  %steal %guest  %wait %idle  _cpu_
00:13:22  all     0     0    0    0        0       0      0      0   200
            0     0     0    0    0        0       0      0      0   100
            1     0     0    0    0        0       0      0      0   100
00:13:32  all     0     0    0    0        0       0      0      0   200
            0     0     0    0    0        0       0      0      0   100
            1     0     0    0    0        0       0      0      0   100

Comment 1 Nathan Scott 2020-07-21 02:11:15 UTC
Hi Denis,

(In reply to Denis Volkov from comment #0)
> Description of problem:
> `pcp atopsar` has `-H` option:
> 
>           -H  repeat report headers (in case of tty: depending on screen
> lines)
> 
> But it changes behaviour of pcp-atopsar instead of just adding the headers.

Hmm, I don't think it does and I suspect confusion lies elsewhere, as follows:

> 
> As shown, `pcp atopsar` interprets `-H 3` as `--interval 3` making it show
> the current data every 3 seconds
>           --interval DELTA      sampling interval

The -H option does not take an argument, as per the man page:

   -H   Repeat the header line within a report for every N detail lines. The value of N  is  determined  dynami‐
        cally in case of output to a tty/window (depending on the number of lines); for output to a file or pipe
        this value is 23.

The documentations use of 'N' (as if it can be set) but then later saying
'determined dynamically' may be the source of confusion here?

So, the '3' is a separate argument entirely, and that is the interpreted as
(again from the man page):

    atopsar [-flags...]  interval [ samples ]

i.e. the '3' becomes the interval, correctly, and we sample every 3 seconds.

> Additional info:
> At the same time if run with `-r` option, `pcp atopsar` interprets `-H`
> correctly - it starts adding header lines:
> 
> # pcp atopsar  -r /var/log/pcp/pmlogger/fastvm-rhel-8-1-189/ -H 

But that's different again - now you're not using the '3' (interval) anymore.

I think there may be no bug here after all - can you check the above and confirm?

Thanks.

Comment 2 Denis Volkov 2020-07-21 09:24:35 UTC
Sorry for confusion with interval. Still, the `-H` header changes behavior:

########################################################################################################
Initial command (no `-H`).
Output starts with first available PCP archive - from 2020/07/20. Header is shown only once

# pcp atopsar 

fastvm-rhel-8-1-189  4.18.0-193.6.3.el8_2.x86_64  #1 SMP Mon Jun 1 20:24:55 UTC 2020  x86_64  2020/07/21

-------------------------- analysis date: 2020/07/20 --------------------------

00:10:32  cpu  %usr %nice %sys %irq %softirq  %steal %guest  %wait %idle  _cpu_

00:10:52  cpu  %usr %nice %sys %irq %softirq  %steal %guest  %wait %idle  _cpu_
00:10:52  all    29    29   29   29       29      29      0     29    -2
            0    13    13   13   13       13      13      0     13     6
            1    13    13   13   13       13      13      0     13     6
00:11:02  all     0     0    0    0        0       0      0      0     0
            0     0     0    0    0        0       0      0      0     0
            1     0     0    0    0        0       0      0      0     0
00:11:12  all     0     0    0    0        0       0      0      0     0
            0     0     0    0    0        0       0      0      0     0
            1     0     0    0    0        0       0      0      0     0
00:11:22  all     0     0    0    0        0       0      0      0     0



########################################################################################################
Command with `-H`.
Output starts from the current time, header is repeated

# -------------------------- analysis date: 2020/07/21 --------------------------

10:13:06  cpu  %usr %nice %sys %irq %softirq  %steal %guest  %wait %idle  _cpu_
10:13:16  all     0     0    0    0        0       0      0      0   200
            0     0     0    0    0        0       0      0      0   100
            1     0     0    0    0        0       0      0      0   100
10:13:26  all     0     0    0    0        0       0      0      0   199
            0     0     0    0    0        0       0      0      0   100
            1     0     0    0    0        0       0      0      0    99
10:13:36  all     0     0    0    0        0       0      0      0   200
            0     0     0    0    0        0       0      0      0   100
            1     0     0    0    0        0       0      0      0   100
10:13:46  all     0     0    0    0        0       0      0      0   200
            0     0     0    0    0        0       0      0      0   100
            1     0     0    0    0        0       0      0      0   100
10:13:56  all     0     0    0    0        0       0      0      0   199
            0     0     0    0    0        0       0      0      0   100
            1     0     0    0    0        0       0      0      0   100

########################################################################################################
Command with `-H` and `-r`.
Output starts with first available PCP archive - from 2020/07/20. Header is repeated.

# pcp atopsar -r /var/log/pcp/pmlogger/$(hostname)/ -H             

fastvm-rhel-8-1-189  4.18.0-193.6.3.el8_2.x86_64  #1 SMP Mon Jun 1 20:24:55 UTC 2020  x86_64  2020/07/21

-------------------------- analysis date: 2020/07/20 --------------------------

00:10:32  cpu  %usr %nice %sys %irq %softirq  %steal %guest  %wait %idle  _cpu_

00:10:52  cpu  %usr %nice %sys %irq %softirq  %steal %guest  %wait %idle  _cpu_
00:10:52  all    29    29   29   29       29      29      0     29    -2
            0    13    13   13   13       13      13      0     13     6
            1    13    13   13   13       13      13      0     13     6
00:11:02  all     0     0    0    0        0       0      0      0     0
            0     0     0    0    0        0       0      0      0     0
            1     0     0    0    0        0       0      0      0     0
00:11:12  all     0     0    0    0        0       0      0      0     0
            0     0     0    0    0        0       0      0      0     0
            1     0     0    0    0        0       0      0      0     0
00:11:22  all     0     0    0    0        0       0      0      0     0
            0     0     0    0    0        0       0      0      0     0
            1     0     0    0    0        0       0      0      0     0
00:11:32  all     0     0    0    0        0       0      0      0     0
            0     0     0    0    0        0       0      0      0     0

Comment 3 Nathan Scott 2020-07-23 01:31:32 UTC
Hi Denis,

Aha, I think I understand this - you're referring to the two headers reported immediately in succession sometimes, AIUI, from reading your above cases.

This depends on the sample timestamp proximity to the start of the PCP archive, and has been resolved (yesterday!) as part of the changes relating to some unrelated issues (BZs #1806824, #1847925 and #1806927) - this will be in upstream pcp-5.2.0.  The new code is in pcp git master branch now, will be in Fedora in a couple of weeks, and RHEL 8 in a few months.

I've verified each of the cases you listed above and each behaves correctly now with the latest code.

Comment 5 Denis Volkov 2020-08-17 07:18:32 UTC
Hello, Nathan

Sorry for a long delay in response.

The original question is not about two headers. The question is about the start of the data:

- in the first case (without `-H` option) output starts from the first pcp archive (2020/07/10 00:10:32)
- in the second case (with `-H` option) output starts from the current time, the moment when the `pcp atopsar` was run (2020/07/15 08:35:04)

Description of the `-H` option says that it should only add the header, not `add the headers and start collecting new data from the current time`

Comment 6 Jan Kurik 2020-09-11 08:23:26 UTC
I can reproduce the behavior Denis described in Comment #5 on pcp-5.2.0 build currently available in Fedora-32.

Comment 7 Nathan Scott 2020-09-12 07:22:44 UTC
Thanks for the reminder Jan - yes, I see it too and can see where the
problem is in the code now.  Fix will be in pcp-5.2.1 in a few weeks.

nathans@shard:/source/git/pcp/src/pcp/atop$ ./pcp-atopsar -H | head

shard  5.8.4-200.fc32.x86_64  #1 SMP Wed Aug 26 22:28:08 UTC 2020  x86_64  2020/09/12

-------------------------- analysis date: 2020/09/08 --------------------------

14:55:25  cpu  %usr %nice %sys %irq %softirq  %steal %guest  %wait %idle  _cpu_
14:55:25  all    21     0   10   38        2       0      0      1   726
            0     3     0    2    5        0       0      0      0    90
            1     2     0    1    5        0       0      0      0    92
            2     4     0    2    5        0       0      0      0    89
nathans@shard:/source/git/pcp/src/pcp/atop$ ./pcp-atopsar | head

shard  5.8.4-200.fc32.x86_64  #1 SMP Wed Aug 26 22:28:08 UTC 2020  x86_64  2020/09/12

-------------------------- analysis date: 2020/09/08 --------------------------

14:55:25  cpu  %usr %nice %sys %irq %softirq  %steal %guest  %wait %idle  _cpu_
14:55:25  all    21     0   10   38        2       0      0      1   726
            0     3     0    2    5        0       0      0      0    90
            1     2     0    1    5        0       0      0      0    92
            2     4     0    2    5        0       0      0      0    89

Comment 8 Nathan Scott 2020-09-14 05:19:29 UTC
This issue is fixed and regression tested upstream via:

commit 4f721ea5dba84d29fe360eced32b57eee9859555
Author: Nathan Scott <nathans>
Date:   Mon Sep 14 15:16:31 2020 +1000

    pcp-atopsar: fix a command line args handling issue

    Resolves Red Hat BZ #1857121

Comment 15 errata-xmlrpc 2021-05-18 15:19:32 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (pcp bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:1754