Skip to content

Commit fac58a0

Browse files
Merge pull request #662 from ct16k/master
memcached collector: support for mcrouter
2 parents f518e72 + cc2d726 commit fac58a0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/collectors/memcached/memcached.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def get_stats(self, host, port):
115115
'repcached_version', 'replication', 'accepting_conns',
116116
'pid')
117117
pid = None
118+
cmdline = None
118119

119120
stats = {}
120121
data = self.get_raw_stats(host, port)
@@ -127,6 +128,9 @@ def get_stats(self, host, port):
127128
elif pieces[1] == 'pid':
128129
pid = pieces[2]
129130
continue
131+
elif pieces[1] == 'commandargs':
132+
cmdline = pieces[2]
133+
continue
130134
if '.' in pieces[2]:
131135
stats[pieces[1]] = float(pieces[2])
132136
else:
@@ -135,13 +139,13 @@ def get_stats(self, host, port):
135139
# get max connection limit
136140
self.log.debug('pid %s', pid)
137141
try:
138-
cmdline = "/proc/%s/cmdline" % pid
139-
f = open(cmdline, 'r')
140-
m = re.search("-c\x00(\d+)", f.readline())
142+
if cmdline is None:
143+
with open("/proc/%s/cmdline" % pid, 'r') as f:
144+
cmdline = f.readline()
145+
m = re.search("-(?:c|-max-conns)\x00(\d+)", cmdline)
141146
if m is not None:
142147
self.log.debug('limit connections %s', m.group(1))
143148
stats['limit_maxconn'] = m.group(1)
144-
f.close()
145149
except:
146150
self.log.debug("Cannot parse command line options for memcached")
147151

0 commit comments

Comments
 (0)