make gunicorn_memory_status and gunicorn_status python3 compatible

This commit is contained in:
Doctor 2023-05-31 18:30:12 +02:00
parent 5b7d70510f
commit 4b9a11c854
2 changed files with 19 additions and 18 deletions

View File

@ -83,11 +83,11 @@ def print_config():
graph_title = "graph_title Gunicorn - Memory Usage"
if instance:
graph_title = "%s - %s" % (graph_title, instance)
print graph_title
print "graph_args --base 1024 -l 0"
print "graph_vlabel Megabytes"
print "graph_category appserver"
print "total_memory.label Total Memory"
print(graph_title)
print("graph_args --base 1024 -l 0")
print("graph_vlabel Megabytes")
print("graph_category appserver")
print("total_memory.label Total Memory")
if __name__ == "__main__":
if len(sys.argv) == 2 and sys.argv[1] == 'config':
@ -95,9 +95,9 @@ if __name__ == "__main__":
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
try:
open(GUNICORN_PID_PATH).close()
print "yes"
print("yes")
except:
print "no"
print("no")
# Some docs say it'll be called with fetch, some say no arg at all
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == 'fetch'):
try:

View File

@ -72,6 +72,7 @@ class GunicornStatus():
def _idle_worker_count(self):
idle_workers = 0
for pid in self.worker_pids:
pid = int(pid)
before = self._cpu_time(pid)
sleep(0.50)
after = self._cpu_time(pid)
@ -98,12 +99,12 @@ def print_config():
graph_title = "graph_title Gunicorn - Status"
if instance:
graph_title = "%s - %s" % (graph_title, instance)
print graph_title
print "graph_args -l 0"
print "graph_vlabel Number of workers"
print "graph_category appserver"
print "total_workers.label Total Workers"
print "idle_workers.label Idle Workers"
print(graph_title)
print("graph_args -l 0")
print("graph_vlabel Number of workers")
print("graph_category appserver")
print("total_workers.label Total Workers")
print("idle_workers.label Idle Workers")
if __name__ == "__main__":
if len(sys.argv) == 2 and sys.argv[1] == 'config':
@ -111,9 +112,9 @@ if __name__ == "__main__":
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
try:
open(GUNICORN_PID_PATH).close()
print "yes"
print("yes")
except:
print "no"
print("no")
# Some docs say it'll be called with fetch, some say no arg at all
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == 'fetch'):
status = GunicornStatus()