Properly handle case where no match from grep

This commit is contained in:
Alexandre Aubin 2020-09-08 17:20:59 +02:00
parent 8b98360fd2
commit 50f68e2886

View file

@ -119,8 +119,8 @@ class SystemResourcesDiagnoser(Diagnoser):
def analyzed_kern_log():
cmd = 'tail -n 10000 /var/log/kern.log | grep "oom_reaper: reaped process" || true'
out = subprocess.check_output(cmd, shell=True)
lines = out.strip().split("\n")
out = subprocess.check_output(cmd, shell=True).strip()
lines = out.split("\n") if out else []
now = datetime.datetime.now()