From 866df76336306359757b4ce8371a775a2bb75604 Mon Sep 17 00:00:00 2001 From: Kevin Alberts Date: Sat, 25 Apr 2020 02:50:46 +0200 Subject: [PATCH] Use sudo --- lsof_spy.py | 4 ++-- settings.py.default | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lsof_spy.py b/lsof_spy.py index b0d601b..df7a7e9 100644 --- a/lsof_spy.py +++ b/lsof_spy.py @@ -40,7 +40,7 @@ smb_active = 0 smb_files = 0 try: - smbd_output = subprocess.check_output(["lsof", "-c", "/^"+SMBD+"$/", "-Pcnt"], stderr=subprocess.DEVNULL).decode() + smbd_output = subprocess.check_output([SUDO, "lsof", "-c", "/^"+SMBD+"$/", "-Pcnt"], stderr=subprocess.DEVNULL).decode() except subprocess.CalledProcessError as e: # Error running process. pass @@ -132,7 +132,7 @@ http_users = 0 http_files = 0 try: - http_output = subprocess.check_output(["lsof", "-c", "/^"+APACHE+"$/", "-Pcnt"], stderr=subprocess.DEVNULL).decode() + http_output = subprocess.check_output([SUDO, "lsof", "-c", "/^"+APACHE+"$/", "-Pcnt"], stderr=subprocess.DEVNULL).decode() except subprocess.CalledProcessError as e: # Error running process. pass diff --git a/settings.py.default b/settings.py.default index 0fe8568..62b3248 100644 --- a/settings.py.default +++ b/settings.py.default @@ -1,4 +1,5 @@ SERVER_NAME = "SomeServer" +SUDO = "sudo" SMBD = "smbd" APACHE = "apache2" BASE_DIR = "/media/share_root"