Skip to content

Conversation

@orasagar
Copy link
Contributor

No description provided.

Added tests to verify pcp-ps output when filtering by specific command (-c) and user (-U root).
Refactored the ReportingMetricRepository class to unify and simplify cache handling for current and previous metric values. Replaced redundant methods with consolidated dictionary-based lookups, improving code readability and efficiency. Also fixed ppid filter flag handling for improved clarity.
This refactoring simplifies test parameter management and makes it easier to adjust sample count in one place
… precomputed predicates

added new -O option where %cpu and %mem output can be sorted as per user preference, by default it will be %cpu sorted.
Refactored ProcessFilter to precompute filter predicates during initialization, improving filter efficiency by reducing per-process overhead. Simplified logic and removed redundant methods to enhance maintainability and performance.
Add commands and output verification to test pcp-ps output sorted by %cpu and %mem usage.
- Improved handling of None and empty values, returning '-' instead of None or ambiguous symbols for better readability.
- Adjusted formatting logic for process name and arguments, ensuring consistent column widths.
- Fixed total_mem extraction to handle dict types returned from metrics.
- Updated scheduler policy handling for correctness and clearer fallback ('?').
- Standardized column headers by reducing excessive tab characters for improved alignment.
- Enhanced print_report logic for graceful termination and sorting validation.
These enhancements improve the clarity and robustness of process status reporting in pcp-ps.
Expanded the qa/1987 test to cover pcp-ps output using custom user-selected formats and sorting (e.g., by %mem and %cpu). Updated the expected output file accordingly to verify new behaviors and handle failure cases. This enhances test coverage for pcp-ps formatting and sorting functionality.
Refactored DynamicProcessReporter to consolidate process list formatting and output logic. Improved sorting validation and index determination, especially for the "ALL" filter state.
Add descriptions for the -O (sort by %mem or %cpu) and -d (debug mode)
@kurik
Copy link
Contributor

kurik commented Jan 5, 2026

Hi @orasagar ,
I have not walk through the full code, however just compiling these code changes and running the pcp ps gives me the following error:

# pcp ps -O '%mem,%cpu'
Invalid sorting option, defaulting to %cpu
Linux  6.12.0-167.el10.x86_64  (vm-10-0-184-136)  01/05/26  x86_64    (4 CPU)
Sorting indices not set for selected flag, please remove sorting flag or choose another flag for output
Sorting indices not set for selected flag, please remove sorting flag or choose another flag for output

The traditional ps works fine with this option:

# ps -O '%mem,%cpu'
    PID %MEM %CPU S TTY          TIME COMMAND
1359809  0.0  0.0 S pts/0    00:00:00 /bin/bash --noprofile --rcfile /tmp/tmp.lQ1StVWzDo
2026683  0.0  0.0 R pts/0    00:00:00 ps -O %mem,%cpu

Am I using the pcp ps in a wrong way ?

@sagarramdev173
Copy link

Hi @kurik ,
By default, pcp ps doesn't have %mem or %cpu column that's you are seeing this "Sorting indices not set for selected flag, please remove sorting flag or choose another flag for output"

if you like to see the output sorted then you need to have column in the output to be sorted.

you can use
pcp ps -u -O "%mem" or
pcp ps -u -O "%cpu"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants