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

Merge pull request #678 from ercpe/gunicorn-instances

Instance name in graph title for gunicorn plugins
This commit is contained in:
Stig Sandbeck Mathisen 2016-04-04 16:47:03 +02:00
commit f717f649a9
2 changed files with 26 additions and 6 deletions

View File

@ -22,7 +22,7 @@
""" """
import sys, os import sys, os, re
from subprocess import check_output from subprocess import check_output
# set path to your gunicorn pid # set path to your gunicorn pid
@ -44,11 +44,9 @@ class GunicornMemoryStatus():
except: except:
raise Exception("Couldn't read gunicorn pid information") raise Exception("Couldn't read gunicorn pid information")
def print_total_memory(self): def print_total_memory(self):
print ('total_memory.value %d' % self._get_total_memory()) print ('total_memory.value %d' % self._get_total_memory())
def _get_master_pid(self): def _get_master_pid(self):
master_pid_file = open(GUNICORN_PID_PATH) master_pid_file = open(GUNICORN_PID_PATH)
self.master_pid = master_pid_file.read().rstrip() self.master_pid = master_pid_file.read().rstrip()
@ -74,7 +72,18 @@ class GunicornMemoryStatus():
return worker_memory_usage return worker_memory_usage
def print_config(): 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_args --base 1024 -l 0"
print "graph_vlabel Megabytes" print "graph_vlabel Megabytes"
print "graph_category gunicorn" print "graph_category gunicorn"

View File

@ -21,7 +21,7 @@
""" """
import sys, os import sys, os, re
from subprocess import check_output from subprocess import check_output
from time import sleep from time import sleep
@ -87,7 +87,18 @@ class GunicornStatus():
return user_time + kernel_time return user_time + kernel_time
def print_config(): def print_config():
print "graph_title Gunicorn - Status" instance = None
name = os.path.basename(sys.argv[0])
if name != "gunicorn_status":
for r in ("^gunicorn_(.*?)_status$", "^gunicorn_status_(.*?)$"):
m = re.match(r, name, re.IGNORECASE)
if m:
instance = m.group(1)
break
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_args -l 0"
print "graph_vlabel Number of workers" print "graph_vlabel Number of workers"
print "graph_category gunicorn" print "graph_category gunicorn"