Projet

Général

Profil

Révision fbb6614e

IDfbb6614e15e5ee5097f744118eedb7830b4d7719
Parent 32f9909e
Enfant bcb9ed82

Ajouté par Lasse Karstensen il y a plus de 13 ans

Avoid ulimit kicking in when running ~1k nodes

Voir les différences:

tools/munin-node-from-hell/muninnode-from-hell
22 22
modules = {}
23 23

  
24 24
class MuninPlugin:
25
    def __init__(self):
26
        self.current_load = None
27
        self.current_locks = None
28

  
25 29
    def sleep_fetch(self, conf):
26 30
        period = None
27 31
        if conf.get("mode") == "sleepy" and conf.get("sleepyness"):
......
36 40
    def sleep_config(self, conf):
37 41
        return self.sleep_fetch(conf)
38 42

  
43
    def find_load(self):
44
        # At about a thousand node instances you get this:
45
        #IOError: [Errno 24] Too many open files: '/proc/loadavg'
46
        # cache it for a bit..
47
        if (not self.current_load) or random.randint(0,100) == 1:
48
            load = open("/proc/loadavg", "r").read()
49
            load, rest = load.split(" ", 1)
50
            self.current_load = float(load)
51
        return self.current_load
52
            
53
    def find_locks(self):
54
        if (not self.current_locks) or random.randint(0,100) == 1:
55
            fp = open("/proc/locks", "r")
56
            self.current_locks = len(fp.readlines())
57
        return self.current_locks 
39 58

  
40 59
class load(MuninPlugin):
41 60
    def fetch(self, conf):
42 61
        self.sleep_fetch(conf)
43
        load = open("/proc/loadavg", "r").read()
44
        load, rest = load.split(" ", 1)
45
        load = float(load)
46
        return "load.value %.2f" % load
62
        return "load.value %.2f" % self.find_load()
47 63

  
48 64
    def config(self, conf):
49 65
        self.sleep_config(conf)
......
60 76
class locks(MuninPlugin):
61 77
    def fetch(self, conf):
62 78
        self.sleep_fetch(conf)
63
        fp = open("/proc/locks", "r")
64
        fdata = fp.readlines()
65
        return "locks.value %i" % len(fdata)
79
        return "locks.value %i" % self.find_locks()
66 80

  
67 81
    def config(self, conf):
68 82
        self.sleep_config(conf)
......
171 185
class utf8_graphcat(MuninPlugin):
172 186
    "A plugin with a graph category which has UTF-8 in it"
173 187
    def fetch(self, conf):
174
        load = open("/proc/loadavg", "r").read()
175
        load, rest = load.split(" ", 1)
176
        load = float(load)
177
        return "apples.value %.2f" % load
188
        return "apples.value %.2f" % self.find_load()
178 189

  
179 190
    def config(self, conf):
180 191
        return """graph_title Example UTF-8 graph
......
188 199
class utf8_graphname(MuninPlugin):
189 200
    "A plugin with a UTF-8 name"
190 201
    def fetch(self, conf):
191
        load = open("/proc/loadavg", "r").read()
192
        load, rest = load.split(" ", 1)
193
        load = float(load)
194
        return "apples.value %.2f" % load
202
        return "apples.value %.2f" % self.find_load()
195 203

  
196 204
    def config(self, conf):
197 205
        return """graph_title Example UTF-8 graph

Formats disponibles : Unified diff