def running_service_owners(exclude=('/dev', '/home', '/media', '/proc', '/run', '/sys/', '/tmp', '/var')):
 error = {}
 if ('pkg.owner' not in __salt__):
  error['Unsupported Package Manager'] = 'The module for the package manager on this system does not support looking up which package(s) owns which file(s)'
 if ('file.open_files' not in __salt__):
  error['Unsupported File Module'] = 'The file module on this system does not support looking up open files on the system'
 if error:
  return {'Error': error}
 ret = {}
 open_files = __salt__['file.open_files']()
 execs = __salt__['service.execs']()
 for path in open_files:
  ignore = False
  for bad_dir in exclude:
   if path.startswith(bad_dir):
    ignore = True
  if ignore:
   continue
  if (not os.access(path, os.X_OK)):
   continue
  for service in execs:
   if (path == execs[service]):
    pkg = __salt__['pkg.owner'](path)
    ret[service] = next(six.itervalues(pkg))
 return ret

def running_service_owners ( exclude = ( '/dev' , '/home' , '/media' , '/proc' , '/run' , '/sys/' , '/tmp' , '/var' ) ) : error = { } if ( 'pkg.owner' not in __salt__ ) : error [ 'Unsupported Package Manager' ] = 'The module for the package manager on this system does not support looking up which package(s) owns which file(s)' if ( 'file.open_files' not in __salt__ ) : error [ 'Unsupported File Module' ] = 'The file module on this system does not support looking up open files on the system' if error : return { 'Error' : error } ret = { } open_files = __salt__ [ 'file.open_files' ] ( ) execs = __salt__ [ 'service.execs' ] ( ) for path in open_files : ignore = False for bad_dir in exclude : if path . startswith ( bad_dir ) : ignore = True if ignore : continue if ( not os . access ( path , os . X_OK ) ) : continue for service in execs : if ( path == execs [ service ] ) : pkg = __salt__ [ 'pkg.owner' ] ( path ) ret [ service ] = next ( six . itervalues ( pkg ) ) return ret
determine which packages own the currently running services .