summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/vyos/util.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 49c47cd85..7558bd3b1 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -268,6 +268,17 @@ def process_running(pid_file):
return pid_exists(int(pid))
+def process_named_running(name):
+ """ Checks if process with given name is running and returns its PID.
+ If Process is not running, return None
+ """
+ from psutil import process_iter
+ for p in process_iter():
+ if name in p.name():
+ return p.pid
+ return None
+
+
def seconds_to_human(s, separator=""):
""" Converts number of seconds passed to a human-readable
interval such as 1w4d18h35m59s