Skip to content

Commit

Permalink
Improve logging if future process discovered
Browse files Browse the repository at this point in the history
Before this change we only logged that it happened.

With this change in place, we log how we decide that it is a future
process.
  • Loading branch information
walles committed Sep 1, 2020
1 parent 415997c commit 6b22f1d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions px/px_process.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import datetime
import operator
import subprocess
Expand All @@ -21,6 +22,9 @@
from six import text_type # NOQA


LOG = logging.getLogger(__name__)


# Match + group: " 7708 1 Mon Mar 7 09:33:11 2016 netbios 0.1 0:00.08 0.0 /usr/sbin/netbiosd hj"
PS_LINE = re.compile(
" *([0-9]+) +([0-9]+) +([A-Za-z0-9: ]+) +([^ ]+) +([0-9.]+) +([-0-9.:]+) +([0-9.]+) +(.*)")
Expand Down Expand Up @@ -65,6 +69,13 @@ def __init__(self,
time = datetime.datetime.strptime(start_time_string.strip(), "%c")
self.start_time = time.replace(tzinfo=TIMEZONE) # type: datetime.datetime
self.age_seconds = (now - self.start_time).total_seconds() # type: float
if self.age_seconds < 0:
LOG.error("Process age < 0: age_seconds=%r now=%r start_time=%r start_time_string=%r",
self.age_seconds,
now,
self.start_time,
start_time_string.strip())
assert False
assert self.age_seconds >= 0
self.age_s = seconds_to_str(self.age_seconds) # type: text_type

Expand Down

0 comments on commit 6b22f1d

Please sign in to comment.