2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

Added instance name for gunicorn_memory_status plugin if linked as gunicorn_memory_status_INSTANCE or gunicorn_INSTANCE_memory_status

This commit is contained in:
Johann Schmitz 2015-12-02 06:31:52 +01:00
parent c301832032
commit 7d58abe5c5
No known key found for this signature in database
GPG Key ID: A084064277C501ED

View File

@ -22,7 +22,7 @@
"""
import sys, os
import sys, os, re
from subprocess import check_output
# set path to your gunicorn pid
@ -44,11 +44,9 @@ class GunicornMemoryStatus():
except:
raise Exception("Couldn't read gunicorn pid information")
def print_total_memory(self):
print ('total_memory.value %d' % self._get_total_memory())
def _get_master_pid(self):
master_pid_file = open(GUNICORN_PID_PATH)
self.master_pid = master_pid_file.read().rstrip()
@ -74,7 +72,18 @@ class GunicornMemoryStatus():
return worker_memory_usage
def print_config():
print "graph_title Gunicorn - Memory Usage"
instance = None
name = os.path.basename(sys.argv[0])
if name != "gunicorn_memory_status":
for r in ("^gunicorn_(.*?)_memory_status$", "^gunicorn_memory_status_(.*?)$"):
m = re.match(r, name, re.IGNORECASE)
if m:
instance = m.group(1)
break
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 gunicorn"