code: def kill_process_on_host(
      hostname,
      pattern
  ):
      
  
      status, stdout = run_command_on_agent(hostname, "ps aux | grep -v grep | grep '{}'".format(pattern))
      pids = [p.strip().split()[1] for p in stdout.splitlines()]
  
      for pid in pids:
          status, stdout = run_command_on_agent(hostname, "sudo kill -9 {}".format(pid))
          if status:
              print("Killed pid: {}".format(pid))
          else:
              print("Unable to killed pid: {}".format(pid))
docs: Kill the process matching pattern at ip
  
          :param hostname: the hostname or ip address of the host on which the process will be killed
          :param pattern: a regular expression matching the name of the process to kill