From 99e3642dc3b6b0056e20cdb4a3c11a1f10b37e0f Mon Sep 17 00:00:00 2001 From: Charles Lu Date: Tue, 12 Aug 2014 23:57:31 +1200 Subject: Adjusted exluded user logic to work better with not authenticated users. Now ignores excluded users when counting not authenticated users --- murmur-munin.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/murmur-munin.py b/murmur-munin.py index 23ef51d..56509bf 100755 --- a/murmur-munin.py +++ b/murmur-munin.py @@ -134,18 +134,22 @@ except Murmur.InvalidSecretException: sys.exit(1) #count users -usersnotauth=0 users=server.getUsers() -for key in users.keys(): - if (users[key].userid == -1): - usersnotauth+=1 #count the number of users to exclude +#also count not authenticated users (who are not excluded) excludedusers=0 +usersnotauth=0 +notexludedflag=0 for key in users.keys(): for name_keyword in exclude_keywords: if (name_keyword in users[key].name): excludedusers+=1 + else: + notexludedflag=1 + if (users[key].userid == -1 and notexludedflag): + usersnotauth+=1 + notexludedflag=0 # more argument parsing for individual stats if (sys.argv[1:]): @@ -166,7 +170,7 @@ if (sys.argv[1:]): ice.shutdown() sys.exit(0) elif (sys.argv[1] == "usersnotauth"): - print "usersnotauth.value %i" % (usersnotauth-excludedusers) + print "usersnotauth.value %i" % (usersnotauth) ice.shutdown() sys.exit(0) elif (sys.argv[1] == "state"): -- cgit v1.2.3