Projet

Général

Profil

Révision 7d58abe5

ID7d58abe5c53f41010a78ccbcd2a38978b459cee3
Parent c3018320
Enfant 0c7bdc92

Ajouté par Johann Schmitz il y a presque 10 ans

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

Voir les différences:

plugins/gunicorn/gunicorn_memory_status
22 22

  
23 23
"""
24 24

  
25
import sys, os
25
import sys, os, re
26 26
from subprocess import check_output
27 27

  
28 28
# set path to your gunicorn pid
......
44 44
        except:
45 45
            raise Exception("Couldn't read gunicorn pid information")
46 46

  
47

  
48 47
    def print_total_memory(self):
49 48
        print ('total_memory.value %d' % self._get_total_memory())
50 49

  
51

  
52 50
    def _get_master_pid(self):
53 51
        master_pid_file = open(GUNICORN_PID_PATH)
54 52
        self.master_pid = master_pid_file.read().rstrip()
......
74 72
        return worker_memory_usage
75 73

  
76 74
def print_config():
77
    print "graph_title Gunicorn - Memory Usage"
75
    instance = None
76
    name = os.path.basename(sys.argv[0])
77
    if name != "gunicorn_memory_status":
78
        for r in ("^gunicorn_(.*?)_memory_status$", "^gunicorn_memory_status_(.*?)$"):
79
            m = re.match(r, name, re.IGNORECASE)
80
            if m:
81
                instance = m.group(1)
82
                break
83
    graph_title = "graph_title Gunicorn - Memory Usage"
84
    if instance:
85
        graph_title = "%s - %s" % (graph_title, instance)
86
    print graph_title
78 87
    print "graph_args --base 1024 -l 0"
79 88
    print "graph_vlabel Megabytes"
80 89
    print "graph_category gunicorn"

Formats disponibles : Unified diff