Skip to content

Commit

Permalink
Adds grep command for checking proc variables
Browse files Browse the repository at this point in the history
  • Loading branch information
djperrefort committed Nov 2, 2023
1 parent 98cb0ce commit 8f6650c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions shinigami/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ def get_nodes(cluster: str, ignore_nodes: Collection[str] = tuple()) -> set:
return set(node for node in all_nodes if node not in ignore_nodes)


def build_grep_command(vars: Collection[str], proc: Collection[int]) -> str:

# grep -Eq '^DBUS_SESSION_BUS_ADDRESS=|^some_other_var=' /proc/44703/environ /proc/2235/environ;
variable_regex = '|'.join(f'^{variable}=' for variable in vars)
proc_files = ' '.join(f'/proc/{proc_id}/environ' for proc_id in proc)
return f"grep -Eq '{variable_regex}' {proc_files}"


async def terminate_errant_processes(
node: str,
uid_whitelist: Collection[Union[int, List[int]]],
Expand Down

0 comments on commit 8f6650c

Please sign in to comment.