def status():
"""
Fetch service status
:return:
"""
if master_pid("c") is True:
print colored(" SERVICE IS RUNNING... ", "white", "on_blue")
h = PrettyTable([u"??ID", u"????"])
h.align[u"??ID"] = "l"
h.align[u"????"] = "l"
h.padding_width = 1
pid_list = processors_list("r")
for pid in pid_list:
try:
if psutil.Process(pid).is_running():
h.add_row([pid, colored("RUNNING...",attrs=["bold"])])
else:
h.add_row([colored(pid, "magenta", "on_yellow", attrs=["bold"]),
colored("STOPED", "magenta", "on_yellow", attrs=["bold"])])
except psutil.NoSuchProcess:
h.add_row([colored(pid, "yellow", attrs=["bold", "blink"]),
colored("LOSTED", "red", attrs=["bold", "blink"])])
print h
else:
cmsg("SERVICE IS STOPED!", "e")
评论列表
文章目录