From 77ed497e2a3777b681cc384c34437f5f4309d590 Mon Sep 17 00:00:00 2001 From: Casey Green Date: Thu, 6 Nov 2014 17:10:56 -0500 Subject: [PATCH] When parsing port, get last element after ':' instead of second The token parsed from netstat can take one of two forms: "0 0.0.0.0:6379" and ":::6379". If the for-loop hits the latter line first, then the line throws an exception. This modification ensures that both formats are supported. --- collectors/0/redis-stats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collectors/0/redis-stats.py b/collectors/0/redis-stats.py index 9f86ce5e..71f979f7 100755 --- a/collectors/0/redis-stats.py +++ b/collectors/0/redis-stats.py @@ -166,7 +166,7 @@ def scan_for_instances(): if not (line and 'redis-server' in line): continue pid = int(line.split()[6].split("/")[0]) - port = int(line.split()[3].split(":")[1]) + port = int(line.split()[3].split(":")[-1]) # now we have to get the command line. we look in the redis config file for # a special line that tells us what cluster this is. else we default to using