From c17bfc268c9767513f205b319dd8d83495f8aa2b Mon Sep 17 00:00:00 2001 From: Albert Autin Date: Fri, 16 Aug 2019 11:24:12 -0600 Subject: [PATCH] minbucket fix, was comparing against value instead of key --- collector.go | 4 +++- stats.go | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/collector.go b/collector.go index 5d8e460..9dd7689 100644 --- a/collector.go +++ b/collector.go @@ -11,7 +11,8 @@ import ( var ( listenPort = flag.String("listenPort", ":9634", "listen address for prometheus") - nodeAddr = flag.String("node", "127.0.0.1", "aerospike node") + skipNodeCheck = flag.Bool("skipNodeCheck", false, "Used only for testing local code development. Do not use in production.") + nodeAddr = flag.String("nodeAddr", "127.0.0.1", "aerospike node") namespaceSets = flag.String("namespaceSets", "", "namespace:set comma delimited. Ex: 'myns:myset,myns2:myset3,myns3:,myns4:'- set optional, but colon is not") failOnClusterChange = flag.Bool("failOnClusterChange", false, "should we abort the scan on cluster change?") reportCount = flag.Int("reportCount", 300000, "How many records should be report on? Every records will cause an entry in the stdout") @@ -91,6 +92,7 @@ func init() { "-exportType": *exportType, "-exportTypeDivision": *exportTypeDivision, "-exportBucketMultiply": *exportBucketMultiply, + "-skipNodeCheck:": *skipNodeCheck, }).Info("Showing passable parameters and their current values.") if *namespaceSets == "" { diff --git a/stats.go b/stats.go index 6fa7561..b391ca9 100644 --- a/stats.go +++ b/stats.go @@ -70,6 +70,9 @@ func getLocalNode() *as.Node { log.Debug("Fetching membership list..") nodes := client.GetNodes() log.Debug("Looping through active cluster nodes") + if *skipNodeCheck { + return nodes[0] + } for _, node := range nodes { // convert the node to a string, then split that to find the addr @@ -169,8 +172,12 @@ func updateStats(namespace string, set string, namespaceSet string) string { var minBucket uint32 for key := range resultMap[namespaceSet] { skey := fmt.Sprint(key) - if minBucket == 0 || (key < minBucket && resultMap[namespaceSet][key] > 0) { + log.Debug("Checking to see if ", key, " should be our minBucket.") + if minBucket == 0 || (key < minBucket && key > 0) { minBucket = key + log.Debug("Setting minBucket to ", key) + } else { + log.Debug("minBucket is not ", key) } if *exportPercentages { percentInThisBucket := float64(resultMap[namespaceSet][key]) * float64(100) / float64(total)