[sysadmin-bin] Add script for detecting long-running upload-pack processes



commit 86053003a65b5c8296e0eaa79215ce6fd9b6ace8
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date:   Fri Jan 31 12:35:59 2020 +0100

    Add script for detecting long-running upload-pack processes

 gitlab/psgit.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/gitlab/psgit.py b/gitlab/psgit.py
new file mode 100644
index 0000000..8ae1bd1
--- /dev/null
+++ b/gitlab/psgit.py
@@ -0,0 +1,15 @@
+#!/usr/bin/python
+
+import psutil
+import time
+
+for p in psutil.process_iter():
+    name = p.name()
+    cmdline = p.cmdline()
+
+    if len(cmdline) > 2 and cmdline[1] == "upload-pack":
+        repo = "/".join(cmdline[-1].split('/')[6:])
+        age = int(time.time()) - int(p.create_time())
+        pid = p.pid
+
+        print("{} {} {}".format(pid, age, repo))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]