grr/core/grr_response_core/lib/parsers/linux_cmd_parser.py
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken,
            knowledge_base):
    """Parse the ps output.

    Note that cmdline consumes every field up to the end of line
    and as it is string, we can't perfectly see what the arguments
    on the command line really were. We just assume a space is the arg
    seperator. It's imperfect, but it's better than nothing.
    Obviously, if cmd/cmdline is specified, it must be the last
    column of output.

    Args:
      cmd: A string containing the base command that was run.
      args: A list of strings containing the commandline args for the command.
      stdout: A string containing the stdout of the command run.
      stderr: A string containing the stderr of the command run. (Unused)
      return_val: The return code following command execution.
      time_taken: The time taken to run the process. (Unused)
      knowledge_base: An RDF KnowledgeBase. (Unused)

    Yields:
      RDF Process objects.
    """

    _ = stderr, time_taken, knowledge_base  # Unused.
    self.CheckReturn(cmd, return_val)

    lines = stdout.splitlines()[1:]  # First line is just a header.
    for line in lines:
      try:
        uid, pid, ppid, c, _, tty, _, cmd = line.split(None, 7)

        rdf_process = rdf_client.Process()
        rdf_process.username = uid
        rdf_process.pid = int(pid)
        rdf_process.ppid = int(ppid)
        rdf_process.cpu_percent = float(c)
        rdf_process.terminal = tty
        rdf_process.cmdline = cmd.split()
        yield rdf_process
      except ValueError as error:
        message = "Error while parsing `ps` output line '%s': %s"
        logging.warning(message, line, error)
Parse the ps output.

    Note that cmdline consumes every field up to the end of line
    and as it is string, we can't perfectly see what the arguments
    on the command line really were. We just assume a space is the arg
    seperator. It's imperfect, but it's better than nothing.
    Obviously, if cmd/cmdline is specified, it must be the last
    column of output.

    Args:
      cmd: A string containing the base command that was run.
      args: A list of strings containing the commandline args for the command.
      stdout: A string containing the stdout of the command run.
      stderr: A string containing the stderr of the command run. (Unused)
      return_val: The return code following command execution.
      time_taken: The time taken to run the process. (Unused)
      knowledge_base: An RDF KnowledgeBase. (Unused)

    Yields:
      RDF Process objects.
    
Parse the ps output.
Note that cmdline consumes every field up to the end of line
and as it is string, we can't perfectly see what the arguments
on the command line really were. We just assume a space is the arg
seperator. It's imperfect, but it's better than nothing.
Obviously, if cmd/cmdline is specified, it must be the last
column of output.
Parse the ps output . Note that cmdline consumes every field up to the end of line and as it is string we can ' t perfectly see what the arguments on the command line really were . We just assume a space is the arg seperator . It ' s imperfect but it ' s better than nothing . Obviously if cmd / cmdline is specified it must be the last column of output .
def Parse(self, cmd, args, stdout, stderr, return_val, time_taken,
            knowledge_base):
    _ = stderr, time_taken, knowledge_base  
    self.CheckReturn(cmd, return_val)
    lines = stdout.splitlines()[1:]  
    for line in lines:
      try:
        uid, pid, ppid, c, _, tty, _, cmd = line.split(None, 7)
        rdf_process = rdf_client.Process()
        rdf_process.username = uid
        rdf_process.pid = int(pid)
        rdf_process.ppid = int(ppid)
        rdf_process.cpu_percent = float(c)
        rdf_process.terminal = tty
        rdf_process.cmdline = cmd.split()
        yield rdf_process
      except ValueError as error:
        message = "Error while parsing `ps` output line '%s': %s"
        logging.warning(message, line, error)
def Parse ( self , cmd , args , stdout , stderr , return_val , time_taken , knowledge_base ) : _ = stderr , time_taken , knowledge_base self . CheckReturn ( cmd , return_val ) lines = stdout . splitlines ( ) [ 1 : ] for line in lines : try : uid , pid , ppid , c , _ , tty , _ , cmd = line . split ( None , 7 ) rdf_process = rdf_client . Process ( ) rdf_process . username = uid rdf_process . pid = int ( pid ) rdf_process . ppid = int ( ppid ) rdf_process . cpu_percent = float ( c ) rdf_process . terminal = tty rdf_process . cmdline = cmd . split ( ) yield rdf_process except ValueError as error : message = "Error while parsing `ps` output line '%s': %s" logging . warning ( message , line , error )
Parse the ps output.
Parse the ps output .
"""Parse the ps output.

    Note that cmdline consumes every field up to the end of line
    and as it is string, we can't perfectly see what the arguments
    on the command line really were. We just assume a space is the arg
    seperator. It's imperfect, but it's better than nothing.
    Obviously, if cmd/cmdline is specified, it must be the last
    column of output.

    Args:
      cmd: A string containing the base command that was run.
      args: A list of strings containing the commandline args for the command.
      stdout: A string containing the stdout of the command run.
      stderr: A string containing the stderr of the command run. (Unused)
      return_val: The return code following command execution.
      time_taken: The time taken to run the process. (Unused)
      knowledge_base: An RDF KnowledgeBase. (Unused)

    Yields:
      RDF Process objects.
    """ # Unused. # First line is just a header.
RDF Process objects.
RDF Process objects .
self
cmd
A string containing the base command that was run.
A string containing the base command that was run .
args
A list of strings containing the commandline args for the command.
A list of strings containing the commandline args for the command .
stdout
A string containing the stdout of the command run.
A string containing the stdout of the command run .
stderr
A string containing the stderr of the command run. (Unused)
A string containing the stderr of the command run . ( Unused )
return_val
The return code following command execution.
The return code following command execution .
time_taken
The time taken to run the process. (Unused)
The time taken to run the process . ( Unused )
knowledge_base
An RDF KnowledgeBase. (Unused)
An RDF KnowledgeBase . ( Unused )