mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
make gunicorn_memory_status and gunicorn_status python3 compatible
This commit is contained in:
parent
5b7d70510f
commit
4b9a11c854
2 changed files with 19 additions and 18 deletions
|
@ -83,11 +83,11 @@ def print_config():
|
||||||
graph_title = "graph_title Gunicorn - Memory Usage"
|
graph_title = "graph_title Gunicorn - Memory Usage"
|
||||||
if instance:
|
if instance:
|
||||||
graph_title = "%s - %s" % (graph_title, instance)
|
graph_title = "%s - %s" % (graph_title, instance)
|
||||||
print graph_title
|
print(graph_title)
|
||||||
print "graph_args --base 1024 -l 0"
|
print("graph_args --base 1024 -l 0")
|
||||||
print "graph_vlabel Megabytes"
|
print("graph_vlabel Megabytes")
|
||||||
print "graph_category appserver"
|
print("graph_category appserver")
|
||||||
print "total_memory.label Total Memory"
|
print("total_memory.label Total Memory")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == 'config':
|
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':
|
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
|
||||||
try:
|
try:
|
||||||
open(GUNICORN_PID_PATH).close()
|
open(GUNICORN_PID_PATH).close()
|
||||||
print "yes"
|
print("yes")
|
||||||
except:
|
except:
|
||||||
print "no"
|
print("no")
|
||||||
# Some docs say it'll be called with fetch, some say no arg at all
|
# 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'):
|
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == 'fetch'):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -72,6 +72,7 @@ class GunicornStatus():
|
||||||
def _idle_worker_count(self):
|
def _idle_worker_count(self):
|
||||||
idle_workers = 0
|
idle_workers = 0
|
||||||
for pid in self.worker_pids:
|
for pid in self.worker_pids:
|
||||||
|
pid = int(pid)
|
||||||
before = self._cpu_time(pid)
|
before = self._cpu_time(pid)
|
||||||
sleep(0.50)
|
sleep(0.50)
|
||||||
after = self._cpu_time(pid)
|
after = self._cpu_time(pid)
|
||||||
|
@ -98,12 +99,12 @@ def print_config():
|
||||||
graph_title = "graph_title Gunicorn - Status"
|
graph_title = "graph_title Gunicorn - Status"
|
||||||
if instance:
|
if instance:
|
||||||
graph_title = "%s - %s" % (graph_title, instance)
|
graph_title = "%s - %s" % (graph_title, instance)
|
||||||
print graph_title
|
print(graph_title)
|
||||||
print "graph_args -l 0"
|
print("graph_args -l 0")
|
||||||
print "graph_vlabel Number of workers"
|
print("graph_vlabel Number of workers")
|
||||||
print "graph_category appserver"
|
print("graph_category appserver")
|
||||||
print "total_workers.label Total Workers"
|
print("total_workers.label Total Workers")
|
||||||
print "idle_workers.label Idle Workers"
|
print("idle_workers.label Idle Workers")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if len(sys.argv) == 2 and sys.argv[1] == 'config':
|
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':
|
elif len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
|
||||||
try:
|
try:
|
||||||
open(GUNICORN_PID_PATH).close()
|
open(GUNICORN_PID_PATH).close()
|
||||||
print "yes"
|
print("yes")
|
||||||
except:
|
except:
|
||||||
print "no"
|
print("no")
|
||||||
# Some docs say it'll be called with fetch, some say no arg at all
|
# 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'):
|
elif len(sys.argv) == 1 or (len(sys.argv) == 2 and sys.argv[1] == 'fetch'):
|
||||||
status = GunicornStatus()
|
status = GunicornStatus()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue