def run(self):
"""
Run the check.
All check scripts must implement this method. It must return a tuple of:
(<success>, <message>)
In this example, if the check succeeds and FileSharing processes are nowhere
to be found, the check will return (True, "No FileSharing processes found").
If the check fails and an FileSharing process is found, it returns
(False, "Found SMB or AFP FileSharing processes with pids <pids>")
"""
pids = []
for p in psutil.process_iter():
try:
if (p.name() == 'AppleFileServer' or p.name() == 'smbd'):
pids.append(p.pid)
except psutil.NoSuchProcess:
pass
if len(pids):
return (False, "found SMB or AFP file sharing processes with pids: {} - Disable Sharing Prefs: File Sharing".format(', '.join([str(p) for p in pids])))
else:
return (True, "disabled")
评论列表
文章目录