UCSF-TI / TIPCC-Tools

Scripts for TIPCC (not really useful elsewhere)
1 stars 0 forks source link

c4 head drops processes with only UID (without usernames) #9

Closed HenrikBengtsson closed 7 years ago

HenrikBengtsson commented 7 years ago

@jjed, wrote:

I think I found a bug in the “c4 head” tool. It only shows processes where the process username is listed, but not those that only show the UID. For example, the vlavergne account has UID 622. Running “c4 head” doesn’t show any processes belonging to vlavergne, but “c4 ps --node head | grep 622” shows many. [...]

HenrikBengtsson commented 7 years ago

This is because c4 head loops only over usernames:

    for user in ${users[@]}; do
    res=$(printf '%s\n' "${bfr[@]}" | grep "$user " | grep -v "grep -E \"$user \"")

To fix this, we need to also translate username to UID and then include processes using also grep UID.

jjed commented 7 years ago

What about just grep’ing for any UID that is greater than 500? No need for the script to translate, we can do that manually if necessary.

HenrikBengtsson commented 7 years ago

It would require a modified loop iterator, because it's currently looping over known usernames (see link to code); it would also have to loop over known UID. Doable, but it wouldn't group UIDs with known users and we would still have to look up the user information somehow via finger.

HenrikBengtsson commented 7 years ago

Forgot to say, I don't think it's that hard to map UID to username and vice versa. So, I should be able to a this feature soon-ish.

HenrikBengtsson commented 7 years ago

Fixed using id -u $user, cf. https://github.com/UCSF-CBC/TIPCC-Tools/blob/master/cbc/shared/bin/c4#L171-L172