Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storing regex matching environment variables in the existing cmdine variable #221

Merged
merged 1 commit into from
Aug 19, 2023

Conversation

jbd
Copy link
Contributor

@jbd jbd commented Dec 13, 2022

The goal is to store selected environment variables per process.

The -z regex option can be used to capture some environment variables and showing them by prepending them to the displayed command line. They are stored directly in the existing curtask->gen.cmdline variable which is convenient for the already existing filtering mechanism. It consumes space that will not be available for the real command line though (related to #101).

For example, when using the SLURM HPC job scheduler, each job inherits SLURM_* variables like the jobid. It is very useful to have the job id directly accessible in atop, avoiding a manual and tedious search within the scheduler job history. With this patch, using the following atop command line and submitting an interactive SLURM job shell:

atop -z 'SLURM_JOBID|SLURM_STEP_NUM_TASKS'

The full command line display will be, after a 'SLURM' filter:

    PID     TID S   CPU COMMAND-LINE (horizontal scroll with <- and -> keys)                                                                            1/1
3686269       - R    0% SLURM_JOBID=51443556 SLURM_STEP_NUM_TASKS=1 ./atop -z SLURM_JOBID|SLURM_STEP_NUM_TASKS
3674287       - S    0% SLURM_JOBID=51443556 SLURM_STEP_NUM_TASKS=1 /bin/bash

…ommand line.

This option can be used to capture some environment variables and displaying them
by prepending them to the command line. They are stored directly in the existing
curtask->gen.cmdline variable. It consumes space not available for the real command
line.
@sagb
Copy link

sagb commented Jan 29, 2023

Alternatively, with #230, you can parse /proc/PID/environ with external script and transform it to more readable "command line", say, "id:51443556 nt:1".

@jbd
Copy link
Contributor Author

jbd commented Mar 3, 2023

This might do the trick indeed, but it involves spawning a process for the external script. I think my approach is better for my specific use case.

I do hope this PR will be discussed, it is quite useful for us !

@kpetrov
Copy link

kpetrov commented Mar 3, 2023

a very cool idea, would give us ability to quickly navigate among dozens of jobs which are running on the server. It was not needed before with just several cores, but with 128 it seems imperative

@Atoptool Atoptool merged commit 99e625e into Atoptool:master Aug 19, 2023
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.

4 participants