Skip to content

Commit

Permalink
fixing stale process handling
Browse files Browse the repository at this point in the history
  • Loading branch information
David Slusser committed Dec 28, 2023
1 parent d51277d commit c47d3d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docs/source/version_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ Version History
"0.0.5", "removing ajax view; using only htmx"
"0.0.6", "updating templates for latest Bootstrap"
"0.0.7", "adding isort; adding badges to readme"
"0.0.8", "fixed modal trigger on host process card"
"0.0.9", "fixed stale process handling in host process view"
23 changes: 15 additions & 8 deletions src/djangoaddicts/hostutils/views/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,23 @@ def get(self, request, *args, **kwargs):
context["title"] = self.title
context["now"] = datetime.datetime.now()
context["subtitle"] = psutil.os.uname()[1]
process_list = list(psutil.process_iter())
context["process_list"] = process_list
counts = {
"running": len([i for i in process_list if i.status() == "running"]),
"sleeping": len([i for i in process_list if i.status() == "sleeping"]),
"idle": len([i for i in process_list if i.status() == "idle"]),
"stopped": len([i for i in process_list if i.status() == "stopped"]),
"zombie": len([i for i in process_list if i.status() == "zombie"]),
"dead": len([i for i in process_list if i.status() == "dead"]),
"running": 0,
"sleeping": 0,
"idle": 0,
"stopped": 0,
"zombie": 0,
"dead": 0,
"disk-sleep": 0
}
process_list = list(psutil.process_iter())
context["process_list"] = process_list
for process in process_list:
try:
counts[process.status()] += 1
except psutil.NoSuchProcess:
continue

context["counts"] = counts
filter_form = {}
filter_form["form"] = HostProcessFilterForm(request.GET or None)
Expand Down

0 comments on commit c47d3d3

Please sign in to comment.