浏览代码

ZOOKEEPER-3935: Handle float metrics in check_zookeeper

After upgrading to Zookeeper 3.6, Nagios tests for zk_avg_latency started failing due to floating point metrics being compared as strings.

Author: Petter A. Urkedal <paurkedal@gmail.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes #1452 from paurkedal/check_zookeeper-float
Petter A. Urkedal 4 年之前
父节点
当前提交
efe83baeaa
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 6 4
      zookeeper-contrib/zookeeper-contrib-monitoring/check_zookeeper.py

+ 6 - 4
zookeeper-contrib/zookeeper-contrib-monitoring/check_zookeeper.py

@@ -311,10 +311,12 @@ class ZooKeeperServer(object):
         if not key:
             raise ValueError('The key is mandatory and should not be empty')
 
-        try:
-            value = int(value)
-        except (TypeError, ValueError):
-            pass
+        for typ in [int, float]:
+            try:
+                value = typ(value)
+                break
+            except (TypeError, ValueError):
+                pass
 
         return key, value