mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
added check_ps common function
This commit is contained in:
parent
920f9f4815
commit
c68d81fe4f
1 changed files with 19 additions and 0 deletions
|
@ -202,3 +202,22 @@ def daemonize(module, cmd):
|
|||
return_data += b(data)
|
||||
|
||||
return pickle.loads(to_text(return_data, errors=errors))
|
||||
|
||||
def check_ps(module, pattern):
|
||||
|
||||
# Set ps flags
|
||||
if platform.system() == 'SunOS':
|
||||
psflags = '-ef'
|
||||
else:
|
||||
psflags = 'auxww'
|
||||
|
||||
# Find ps binary
|
||||
psbin = module.get_bin_path('ps', True)
|
||||
|
||||
(rc, out, err) = module.run_command('%s %s' % (psbin, psflags))
|
||||
# If rc is 0, set running as appropriate
|
||||
if rc == 0:
|
||||
for line in out.split('\n'):
|
||||
if pattern in line:
|
||||
return True
|
||||
return False
|
||||
|
|
Loading…
Reference in a new issue