Skip to content

Commit

Permalink
Merge pull request python-diamond#662 from ct16k/master
Browse files Browse the repository at this point in the history
memcached collector: support for mcrouter
  • Loading branch information
shortdudey123 authored Mar 2, 2022
2 parents f518e72 + cc2d726 commit fac58a0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/collectors/memcached/memcached.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def get_stats(self, host, port):
'repcached_version', 'replication', 'accepting_conns',
'pid')
pid = None
cmdline = None

stats = {}
data = self.get_raw_stats(host, port)
Expand All @@ -127,6 +128,9 @@ def get_stats(self, host, port):
elif pieces[1] == 'pid':
pid = pieces[2]
continue
elif pieces[1] == 'commandargs':
cmdline = pieces[2]
continue
if '.' in pieces[2]:
stats[pieces[1]] = float(pieces[2])
else:
Expand All @@ -135,13 +139,13 @@ def get_stats(self, host, port):
# get max connection limit
self.log.debug('pid %s', pid)
try:
cmdline = "/proc/%s/cmdline" % pid
f = open(cmdline, 'r')
m = re.search("-c\x00(\d+)", f.readline())
if cmdline is None:
with open("/proc/%s/cmdline" % pid, 'r') as f:
cmdline = f.readline()
m = re.search("-(?:c|-max-conns)\x00(\d+)", cmdline)
if m is not None:
self.log.debug('limit connections %s', m.group(1))
stats['limit_maxconn'] = m.group(1)
f.close()
except:
self.log.debug("Cannot parse command line options for memcached")

Expand Down

0 comments on commit fac58a0

Please sign in to comment.