当前位置: 首页>>代码示例>>Python>>正文


Python Process.cmdline方法代码示例

本文整理汇总了Python中psutil.Process.cmdline方法的典型用法代码示例。如果您正苦于以下问题:Python Process.cmdline方法的具体用法?Python Process.cmdline怎么用?Python Process.cmdline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在psutil.Process的用法示例。


在下文中一共展示了Process.cmdline方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_procinfo_by_address

# 需要导入模块: from psutil import Process [as 别名]
# 或者: from psutil.Process import cmdline [as 别名]
def get_procinfo_by_address(ip_src, ip_dst, port_src=None, port_dst=None):
	"""
	Gets Infos about the Prozess associated with the given address information
	Both port_src and port_dst must be not None or None at the same time.

	return -- [pid, "/path/to/command", "user", "hash"] or []
	"""
	result = []

	if port_src is not None:
		pids = [c.pid for c in net_connections()
			if len(c.raddr) != 0 and c.pid is not None and
				(c.laddr[0], c.raddr[0], c.laddr[1], c.raddr[1]) == (ip_src, ip_dst, port_src, port_dst)]
	else:
		pids = [c.pid for c in net_connections()
			if len(c.raddr) != 0 and c.pid is not None and (c.laddr[0], c.raddr[0]) == (ip_src, ip_dst)]

	try:
		if len(pids) > 1:
			logger.warning("more than 1 matching process: %r", pids)
		proc = Process(pids[0])
		cmd = [pids[0], proc.cmdline(), proc.username()]
		hash_input = "%d%s%s" % (cmd[0], cmd[1], cmd[2])
		procinfo_hash = hashlib.sha256(hash_input.encode("UTF-8"))
		cmd.append(procinfo_hash)
		logger.debug("process info: %r", cmd)
		return cmd
	except IndexError:
		pass
	return []
开发者ID:mike01,项目名称:ifi,代码行数:32,代码来源:procinfo.py

示例2: get_soledad_server_pid

# 需要导入模块: from psutil import Process [as 别名]
# 或者: from psutil.Process import cmdline [as 别名]
def get_soledad_server_pid():
    output = check_output(['pidof', 'python'])
    for pid in output.split():
        proc = Process(int(pid))
        cmdline = proc.cmdline()
        if args.issubset(set(cmdline)):
            return int(pid)
开发者ID:leapcode,项目名称:soledad,代码行数:9,代码来源:utils.py

示例3: query_process

# 需要导入模块: from psutil import Process [as 别名]
# 或者: from psutil.Process import cmdline [as 别名]
def query_process(process=None):
    if not isinstance(process, Process):
        process = Process(process)
    cmd_line = u" ".join((u'"%s"' % x.replace('"', r'\"') if " " in x else x.replace('"', r'\"') \
                         for x in process.cmdline()))
    return {"pid": process.pid, "cmd_line": cmd_line, "owner": process.uids()[0]}
开发者ID:phillipberndt,项目名称:scripts,代码行数:8,代码来源:pskill.py


注:本文中的psutil.Process.cmdline方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。