As Padraic Cunningham wrote here:
Python: How to get PID by process name?
In order to get pid from process-name:
from subprocess import check_output
def get_pid(name):
return int(check_output(["pidof","-s",name]))
As Mat wrote here: https://stackoverflow.com/a/6767792/5088142
In order to get status of a process using its pid your can use psutil https://github.com/giampaolo/psutil
import psutil
print psutil.Process(pid).status
Edit: You can combine those two parts into the following code:
from subprocess import check_output
import psutil
def get_pid(name):
return int(check_output(["pidof","-s",name]))
def get_status(name)
pid = get_pid(name)
print psutil.Process(pid).status